git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How to check repository/working tree status from a script

From
Jeff King <peff@peff.net>
Date
May 21, 2009, 15:37 UTC
Message-ID
<20090521153745.GA23463@coredump.intra.peff.net>
In-Reply-To
<20090521132457.GB5625@torres.zugschlus.de>
On Thu, May 21, 2009 at 03:24:57PM +0200, Marc Haber wrote:
Show 6 quoted lines
> I am now looking for a solution for (b). I tried 
> 
> git log -n1 --pretty=oneline master..origin/master
> 
> but that seems to always give empty output even if a later issued git
> pull will actually pull in changes.

Try running "git fetch" beforehand, which will actually update origin/master with what is on the remote.

Also, if you are just checking to see whether there is any output, you can use the plumbing "git rev-list" instead of "git log". So something like:

  git fetch origin || { echo >&2 unable to fetch; exit 1; }
  test -z "`git rev-list -1 master..origin/master`"
-Peff
Previous: Marc HaberNext: Marc Haber
Message 14 of 15 in “How to check repository/working tree status from a script”
  1. Marc HaberMay 19, 2009
  2. Tony FinchMay 19, 2009
  3. Marc HaberMay 19, 2009
  4. Tony FinchMay 19, 2009
  5. Marc HaberMay 20, 2009
  6. Linus TorvaldsMay 19, 2009
  7. Linus TorvaldsMay 19, 2009
  8. Marc HaberMay 20, 2009
  9. Marc HaberMay 20, 2009
  10. Santi BéjarMay 20, 2009
  11. Johannes SixtMay 20, 2009
  12. Marc HaberMay 20, 2009
  13. Marc HaberMay 21, 2009
  14. Jeff KingMay 21, 2009
  15. Marc HaberMay 23, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.