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