* git log --quiet bug?
@ 2011-11-08 14:36 Prasad Deshpande
2011-11-08 21:29 ` Jeff King
0 siblings, 1 reply; 6+ messages in thread
From: Prasad Deshpande @ 2011-11-08 14:36 UTC (permalink / raw)
To: git@vger.kernel.org
Hi,
I am new to the list so please let me know if I need to take this question somewhere else.
I am seeing a bug with git log --quiet. It doesn't seem to be quiet :-). Also I have seen cases where the exit status returned is not correct i.e. its 0 even if there is some output (although I cant seem to reproduce that problem at present).
--------------------------------------------------
[~/Work/ws/tools-common] git --version
git version 1.7.0.4
$ git log origin..HEAD
commit 632ff3eed4004ad76b7cd253643c66ce0f9223f1
Author: XXX
Date: Tue Nov 8 09:30:31 2011 -0500
test
$ git log origin..HEAD --quiet
commit 632ff3eed4004ad76b7cd253643c66ce0f9223f1
Author: XXX
Date: Tue Nov 8 09:30:31 2011 -0500
test
[~/Work/ws/tools-common] echo $?
1
--------------------------------------------------
thanks
-prasad
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: git log --quiet bug?
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>
0 siblings, 2 replies; 6+ messages in thread
From: Jeff King @ 2011-11-08 21:29 UTC (permalink / raw)
To: Prasad Deshpande; +Cc: Junio C Hamano, git@vger.kernel.org
On Tue, Nov 08, 2011 at 06:36:18AM -0800, Prasad Deshpande wrote:
> I am seeing a bug with git log --quiet. It doesn't seem to be quiet
> :-). Also I have seen cases where the exit status returned is not
> correct i.e. its 0 even if there is some output (although I cant seem
> to reproduce that problem at present).
I think the description of "--quiet" in the git-log manpage is
accidentally inherited by including the diff options. In "git diff", it
stops output and makes the exit code useful for determining whether
there were changes. But what does the exit code even mean in the context
of "git log"?
It does look like there is code in "git log" to handle --quiet, and
convert it to "no diff output" (i.e., like "-s"). But it doesn't seem to
do anything. If I manually specify a format like "git log -p --quiet", I
still get output. And if I don't say "-p", then I wouldn't get diff
output anyway. It does seem to have an impact on other log variants that
have output by default (e.g., "git whatchanged --quiet" won't show the
usual raw diffs).
I think we should probably just excise it from the git-log manpage, like
this:
-- >8 --
Subject: [PATCH] docs: don't mention --quiet or --exit-code in git-log(1)
These are diff-options, but they don't actually make sense
in the context of log.
Signed-off-by: Jeff King <peff@peff.net>
---
Documentation/diff-options.txt | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 08b581f..9f7cba2 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -412,15 +412,17 @@ endif::git-format-patch[]
--function-context::
Show whole surrounding functions of changes.
ifndef::git-format-patch[]
+ifndef::git-log[]
--exit-code::
Make the program exit with codes similar to diff(1).
That is, it exits with 1 if there were differences and
0 means no differences.
--quiet::
Disable all output of the program. Implies `--exit-code`.
+endif::git-log[]
endif::git-format-patch[]
--ext-diff::
Allow an external diff helper to be executed. If you set an
--
1.7.7.2.7.g9f96f
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: git log --quiet bug?
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>
1 sibling, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2011-11-08 21:37 UTC (permalink / raw)
To: Jeff King; +Cc: Prasad Deshpande, git@vger.kernel.org
Thanks, the patch makes sense to me.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: git log --quiet bug?
[not found] ` <1320791465.67359.YahooMailNeo@web84006.mail.mud.yahoo.com>
@ 2011-11-08 23:20 ` Jeff King
2011-11-09 0:04 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Jeff King @ 2011-11-08 23:20 UTC (permalink / raw)
To: Prasad Deshpande; +Cc: Junio C Hamano, git@vger.kernel.org
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: git log --quiet bug?
2011-11-08 23:20 ` Jeff King
@ 2011-11-09 0:04 ` Junio C Hamano
2011-11-09 0:59 ` Jeff King
0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2011-11-09 0:04 UTC (permalink / raw)
To: Jeff King; +Cc: Prasad Deshpande, Junio C Hamano, git@vger.kernel.org
Jeff King <peff@peff.net> writes:
> 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.
Doesn't some variant of "branch -v" show the ahead/behind information for
all branches?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: git log --quiet bug?
2011-11-09 0:04 ` Junio C Hamano
@ 2011-11-09 0:59 ` Jeff King
0 siblings, 0 replies; 6+ messages in thread
From: Jeff King @ 2011-11-09 0:59 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Prasad Deshpande, git@vger.kernel.org
On Tue, Nov 08, 2011 at 04:04:50PM -0800, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> > 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.
>
> Doesn't some variant of "branch -v" show the ahead/behind information for
> all branches?
Yeah, but I thought the question was how to figure this out
programatically in a script.
-Peff
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-11-09 0:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2011-11-09 0:04 ` Junio C Hamano
2011-11-09 0:59 ` Jeff King
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).