threads / bug / 38085

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

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

## tl;dr

10 messages between Dec 1, 2014 and Dec 2, 2014.

replies: 9people: 4as markdown or json

Junio C Hamano· Dec 1, 2014, 16:29 UTC · re: Sergey Organov · lore

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

Sergey Organov <sorganov@gmail.com> writes:
Show 7 quoted lines
> Hello,
>
> $ git help log | grep exit-code
>            problems are found. Not compatible with --exit-code.
> $
>
> What --exit-code does in "git log"?
It doesn't.  That is why it is not listed.
Sergey Organov· Dec 1, 2014, 16:32 UTC · re: Junio C Hamano · lore

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

Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> Sergey Organov <sorganov@gmail.com> writes:
>
>> Hello,
>>
>> $ git help log | grep exit-code
>>            problems are found. Not compatible with --exit-code.
>> $
>>
>> What --exit-code does in "git log"?
>
> It doesn't.  That is why it is not listed.
Then, how can --check possibly interfer with it?
-- 
Sergey.
Junio C Hamano· Dec 1, 2014, 16:37 UTC · re: Sergey Organov · lore

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

Sergey Organov <sorganov@gmail.com> writes:
Show 15 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Sergey Organov <sorganov@gmail.com> writes:
>>
>>> Hello,
>>>
>>> $ git help log | grep exit-code
>>>            problems are found. Not compatible with --exit-code.
>>> $
>>>
>>> What --exit-code does in "git log"?
>>
>> It doesn't.  That is why it is not listed.
>
> Then, how can --check possibly interfer with it?

The description is shared with "git diff" and friends, which is invoked via "git log -p". As "log" does not give the exit code of individual "diff-tree" invocation for each commit, --exit-code option is irrelevant.

Sergey Organov· Dec 1, 2014, 16:43 UTC · re: Junio C Hamano · lore

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

Junio C Hamano <gitster@pobox.com> writes:
Show 22 quoted lines
> Sergey Organov <sorganov@gmail.com> writes:
>
>> Junio C Hamano <gitster@pobox.com> writes:
>>
>>> Sergey Organov <sorganov@gmail.com> writes:
>>>
>>>> Hello,
>>>>
>>>> $ git help log | grep exit-code
>>>>            problems are found. Not compatible with --exit-code.
>>>> $
>>>>
>>>> What --exit-code does in "git log"?
>>>
>>> It doesn't.  That is why it is not listed.
>>
>> Then, how can --check possibly interfer with it?
>
> The description is shared with "git diff" and friends, which is
> invoked via "git log -p".  As "log" does not give the exit code
> of individual "diff-tree" invocation for each commit, --exit-code
> option is irrelevant.

Do you agree there is some minor problem here? First, "git log" silently eats the --exit-code option that does nothing. Next, git-log manual page doesn't include --exit-log description while refers to it elsewhere. What's proposed resulution?

-- 
Sergey.
David Kastrup· Dec 1, 2014, 17:32 UTC · re: Junio C Hamano · lore

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

Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> Sergey Organov <sorganov@gmail.com> writes:
>
>> Hello,
>>
>> $ git help log | grep exit-code
>>            problems are found. Not compatible with --exit-code.
>> $
>>
>> What --exit-code does in "git log"?
>
> It doesn't.  That is why it is not listed.

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.

-- 
David Kastrup
Junio C Hamano· Dec 1, 2014, 17:49 UTC · re: David Kastrup · lore

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

David Kastrup <dak@gnu.org> writes:
Show 7 quoted lines
> 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?

David Kastrup· Dec 1, 2014, 18:30 UTC · re: Junio C Hamano · lore

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

Junio C Hamano <gitster@pobox.com> writes:
Show 29 quoted lines
> David Kastrup <dak@gnu.org> 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
Sergey Organov· Dec 2, 2014, 11:30 UTC · re: Junio C Hamano · lore

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

Junio C Hamano <gitster@pobox.com> writes:
Show 18 quoted lines
> David Kastrup <dak@gnu.org> 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.
What's the best way then to tell if "a" is an ancestor of "b"?
-- 
Sergey.
John Keeping· Dec 2, 2014, 12:27 UTC · re: Sergey Organov · lore

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

On Tue, Dec 02, 2014 at 02:30:31PM +0300, Sergey Organov wrote:
Show 22 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> 
> > David Kastrup <dak@gnu.org> 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.
> 
> What's the best way then to tell if "a" is an ancestor of "b"?
git merge-base --is-ancestor a b

← back to recent threads