git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Prasad Deshpande <prasadgdeshpande@yahoo.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: git log --quiet bug?
Date: Tue, 8 Nov 2011 18:20:43 -0500	[thread overview]
Message-ID: <20111108232043.GA21957@sigill.intra.peff.net> (raw)
In-Reply-To: <1320791465.67359.YahooMailNeo@web84006.mail.mud.yahoo.com>

On Tue, Nov 08, 2011 at 02:31:05PM -0800, Prasad Deshpande wrote:

> 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

  parent reply	other threads:[~2011-11-08 23:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-08 14:36 git log --quiet bug? Prasad Deshpande
2011-11-08 21:29 ` Jeff King
2011-11-08 21:37   ` Junio C Hamano
     [not found]   ` <1320791465.67359.YahooMailNeo@web84006.mail.mud.yahoo.com>
2011-11-08 23:20     ` Jeff King [this message]
2011-11-09  0:04       ` Junio C Hamano
2011-11-09  0:59         ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111108232043.GA21957@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=prasadgdeshpande@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).