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

10 messages from 2014-12-01 to 2014-12-02. Participants: Sergey Organov, Junio C Hamano, David Kastrup, John Keeping.
Thread: https://gitlist.dev/t/38085

## Sergey Organov, 2014-12-01 11:50

Subject: [BUG] Documentation: git log: --exit-code undocumented?
Message-ID: <87zjb78u7g.fsf@osv.gnss.ru>
URL: https://gitlist.dev/e/87zjb78u7g.fsf%40osv.gnss.ru

```
Hello,

$ git help log | grep exit-code
           problems are found. Not compatible with --exit-code.
$

What --exit-code does in "git log"?

-- 
Sergey.

```

## Junio C Hamano, 2014-12-01 16:29

Subject: Re: [BUG] Documentation: git log: --exit-code undocumented?
Message-ID: <xmqqegsjqqox.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqegsjqqox.fsf%40gitster.dls.corp.google.com
In-Reply-To: <87zjb78u7g.fsf@osv.gnss.ru>

```
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.

```

## Sergey Organov, 2014-12-01 16:32

Subject: Re: [BUG] Documentation: git log: --exit-code undocumented?
Message-ID: <87wq6bgwl6.fsf@osv.gnss.ru>
URL: https://gitlist.dev/e/87wq6bgwl6.fsf%40osv.gnss.ru
In-Reply-To: <xmqqegsjqqox.fsf@gitster.dls.corp.google.com>

```
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?

-- 
Sergey.

```

## Junio C Hamano, 2014-12-01 16:37

Subject: Re: [BUG] Documentation: git log: --exit-code undocumented?
Message-ID: <xmqqa937qqb7.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqa937qqb7.fsf%40gitster.dls.corp.google.com
In-Reply-To: <87wq6bgwl6.fsf@osv.gnss.ru>

```
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.

```

## Sergey Organov, 2014-12-01 16:43

Subject: Re: [BUG] Documentation: git log: --exit-code undocumented?
Message-ID: <87oarngw2b.fsf@osv.gnss.ru>
URL: https://gitlist.dev/e/87oarngw2b.fsf%40osv.gnss.ru
In-Reply-To: <xmqqa937qqb7.fsf@gitster.dls.corp.google.com>

```
Junio C Hamano <gitster@pobox.com> writes:

> 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, 2014-12-01 17:32

Subject: Re: [BUG] Documentation: git log: --exit-code undocumented?
Message-ID: <874mtfl1hx.fsf@fencepost.gnu.org>
URL: https://gitlist.dev/e/874mtfl1hx.fsf%40fencepost.gnu.org
In-Reply-To: <xmqqegsjqqox.fsf@gitster.dls.corp.google.com>

```
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.

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, 2014-12-01 17:49

Subject: Re: [BUG] Documentation: git log: --exit-code undocumented?
Message-ID: <xmqqwq6bp8ey.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqwq6bp8ey.fsf%40gitster.dls.corp.google.com
In-Reply-To: <874mtfl1hx.fsf@fencepost.gnu.org>

```
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?

```

## David Kastrup, 2014-12-01 18:30

Subject: Re: [BUG] Documentation: git log: --exit-code undocumented?
Message-ID: <87zjb7jk8q.fsf@fencepost.gnu.org>
URL: https://gitlist.dev/e/87zjb7jk8q.fsf%40fencepost.gnu.org
In-Reply-To: <xmqqwq6bp8ey.fsf@gitster.dls.corp.google.com>

```
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.  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, 2014-12-02 11:30

Subject: Re: [BUG] Documentation: git log: --exit-code undocumented?
Message-ID: <87ppc2xp9k.fsf@osv.gnss.ru>
URL: https://gitlist.dev/e/87ppc2xp9k.fsf%40osv.gnss.ru
In-Reply-To: <xmqqwq6bp8ey.fsf@gitster.dls.corp.google.com>

```
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"?

-- 
Sergey.

```

## John Keeping, 2014-12-02 12:27

Subject: Re: [BUG] Documentation: git log: --exit-code undocumented?
Message-ID: <20141202122705.GA22967@serenity.lan>
URL: https://gitlist.dev/e/20141202122705.GA22967%40serenity.lan
In-Reply-To: <87ppc2xp9k.fsf@osv.gnss.ru>

```
On Tue, Dec 02, 2014 at 02:30:31PM +0300, Sergey Organov wrote:
> 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

```
