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

Re: git log --quiet bug?

From
Jeff King <peff@peff.net>
Date
Nov 8, 2011, 23:20 UTC
Message-ID
<20111108232043.GA21957@sigill.intra.peff.net>
In-Reply-To
<1320791465.67359.YahooMailNeo@web84006.mail.mud.yahoo.com>
On Tue, Nov 08, 2011 at 02:31:05PM -0800, Prasad Deshpande wrote:
Show 19 quoted lines
> Thanks for your response. I was actually trying to write a script to
> determine if a workspace has commits which haven't been pushed to the
> repository. 
> For this I was using the following in a bash script:
> 
>   ..
>   git log origin..HEAD --quiet
>   if [ $? -ne 0 ]
>   then
>     echo
> 
>     echo "git log shows files committed but not pushed.. ABORTING"
>     echo
>     echo "************* `pwd` ***************"
>     git log origin..HEAD --color --graph --stat
>     exit 1
>   fi
> 
>   What is the recommended way to do this?
Try:
  test -z "$(git rev-list -1 origin..HEAD)" &&
  echo nothing that needs pushing

You can also use --count to get the exact number, but if you just care whether there is something or nothing, using "-1" lets git stop the graph traversal immediately.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 6 in “git log --quiet bug?”
  1. Prasad DeshpandeNov 8, 2011
  2. Jeff KingNov 8, 2011
  3. Junio C HamanoNov 8, 2011
  4. Jeff KingNov 8, 2011
  5. Junio C HamanoNov 9, 2011
  6. Jeff KingNov 9, 2011

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.