Subject: Re: [BUG] Documentation: git log: --exit-code undocumented?

From: David Kastrup <[email-masked]>
Date: Mon, 01 Dec 2014 19:30:29 +0100

Junio C Hamano <[email-masked]> writes:

> David Kastrup <[email-masked]> writes:
>
>> I disagree that --exit-code does nothing: it indicates whether the
>> listed log is empty.  So for example
>>
>> git log -1 --exit-code a..b > /dev/null
>>
>> can be used to figure out whether "a" is a proper ancestor of "b" or
>> not.
>
> Hmph.
>
>     $ git log --exit-code master..maint >/dev/null; echo $?
>     0
>     $ git log --exit-code maint..master >/dev/null; echo $?
>     1
>
> That is a strange way to use --exit-code.  I suspect that if you did
> this, you will get 0 from the log between HEAD~..HEAD
>
>     $ git checkout master^0
>     $ git commit --allow-empty -m empty
>     $ git log --exit-code HEAD~..HEAD
>
> even though HEAD~ is a proper ancestor of HEAD, so it is not giving
> us anything useful.  Isn't it a mere artifact that "log" happens to
> share the underlying machinery with "diff" that --exit-code shows a
> non-zero exit when there is any single commit in the range that has
> any change?

Possibly: I haven't checked the underlying code for the details.  At any
rate, it is an option git log accepts for whatever reason.

-- 
David Kastrup