# BUG? git log --no-merges shows grafted merges in shallow clones

4 messages from 2016-02-26 to 2016-02-26. Participants: Matthieu Moy, Junio C Hamano.
Thread: https://gitlist.dev/t/41539

## Matthieu Moy, 2016-02-26 19:49

Subject: BUG? git log --no-merges shows grafted merges in shallow clones
Message-ID: <vpq4mcvs146.fsf@anie.imag.fr>
URL: https://gitlist.dev/e/vpq4mcvs146.fsf%40anie.imag.fr

```
Hi,

I don't think that's intended. When running "git log --no-merges" in a
shallow clone, and the last commit in the history is a merge commit,
"git log --no-merges" still shows it.

I've just hit this in a test running on a --depth=50 clone on Travis-CI
on git-multimail:

$ git cat-file -p c3c1cc25b27d448e9ef67b265a11be8735ff2df4
tree c341dd60c4b639eac1d6dcc3caffb5d7201c2245
parent b312e3f90dfef73ba0288999981694b09affdf6b
parent 842ac6e867885af041499723dc46f2197705204c
author Matthieu Moy <Matthieu.Moy@imag.fr> 1441031540 +0200
committer Matthieu Moy <Matthieu.Moy@imag.fr> 1441031540 +0200

Merge remote-tracking branch 'edward/utf-8-email-support4'

$ git log --no-merges c3c1cc25b27d448e9ef67b265a11be8735ff2df4
commit c3c1cc25b27d448e9ef67b265a11be8735ff2df4 (grafted)
Author: Matthieu Moy <Matthieu.Moy@imag.fr>
Date:   Mon Aug 31 16:32:20 2015 +0200

    Merge remote-tracking branch 'edward/utf-8-email-support4'

I guess Git counts the number of parents that are actually in the
repository, but it could check the number of "parents" field in the
object (cat-file -p was still able to show 2).

Thanks,

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Junio C Hamano, 2016-02-26 20:00

Subject: Re: BUG? git log --no-merges shows grafted merges in shallow clones
Message-ID: <xmqqfuwfjl8e.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqfuwfjl8e.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <vpq4mcvs146.fsf@anie.imag.fr>

```
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Hi,
>
> I don't think that's intended. When running "git log --no-merges" in a
> shallow clone, and the last commit in the history is a merge commit,
> "git log --no-merges" still shows it.
>
> I've just hit this in a test running on a --depth=50 clone on Travis-CI
> on git-multimail:
>
> $ git cat-file -p c3c1cc25b27d448e9ef67b265a11be8735ff2df4
> tree c341dd60c4b639eac1d6dcc3caffb5d7201c2245
> parent b312e3f90dfef73ba0288999981694b09affdf6b
> parent 842ac6e867885af041499723dc46f2197705204c
> author Matthieu Moy <Matthieu.Moy@imag.fr> 1441031540 +0200
> committer Matthieu Moy <Matthieu.Moy@imag.fr> 1441031540 +0200
>
> Merge remote-tracking branch 'edward/utf-8-email-support4'
>
> $ git log --no-merges c3c1cc25b27d448e9ef67b265a11be8735ff2df4
> commit c3c1cc25b27d448e9ef67b265a11be8735ff2df4 (grafted)
> Author: Matthieu Moy <Matthieu.Moy@imag.fr>
> Date:   Mon Aug 31 16:32:20 2015 +0200
>
>     Merge remote-tracking branch 'edward/utf-8-email-support4'
>
> I guess Git counts the number of parents that are actually in the
> repository, but it could check the number of "parents" field in the
> object (cat-file -p was still able to show 2).

I do not think this is limited to shallow but for grafts in
general.  cat-file is low-level to show the bare metal, but by using
these facility you asked Git to give you an imaginary history where
that commit is the root commit--and that is why it is shown, I
think.

What does it do if you say "git -c log.showRoot=false log -p"?

```

## Matthieu Moy, 2016-02-26 20:05

Subject: Re: BUG? git log --no-merges shows grafted merges in shallow clones
Message-ID: <vpqwpprqlt4.fsf@anie.imag.fr>
URL: https://gitlist.dev/e/vpqwpprqlt4.fsf%40anie.imag.fr
In-Reply-To: <xmqqfuwfjl8e.fsf@gitster.mtv.corp.google.com>

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

> I do not think this is limited to shallow but for grafts in
> general.  

Probably yes. I happen to only use grafts in shallow clones ;-).

> cat-file is low-level to show the bare metal, but by using these
> facility you asked Git to give you an imaginary history where that
> commit is the root commit--and that is why it is shown, I think.
>
> What does it do if you say "git -c log.showRoot=false log -p"?

I get the commit without the patch:

commit c3c1cc25b27d448e9ef67b265a11be8735ff2df4 (grafted)
Author: Matthieu Moy <Matthieu.Moy@imag.fr>
Date:   Mon Aug 31 16:32:20 2015 +0200

    Merge remote-tracking branch 'edward/utf-8-email-support4'

Without "-c log.showRoot=false" I get a big patch (diff of the commit
against the empty tree).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Junio C Hamano, 2016-02-26 20:13

Subject: Re: BUG? git log --no-merges shows grafted merges in shallow clones
Message-ID: <xmqqbn73jklt.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqbn73jklt.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <vpqwpprqlt4.fsf@anie.imag.fr>

```
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>> I do not think this is limited to shallow but for grafts in
>> general.  
>
> Probably yes. I happen to only use grafts in shallow clones ;-).
>
>> cat-file is low-level to show the bare metal, but by using these
>> facility you asked Git to give you an imaginary history where that
>> commit is the root commit--and that is why it is shown, I think.
>>
>> What does it do if you say "git -c log.showRoot=false log -p"?
>
> I get the commit without the patch:
>
> commit c3c1cc25b27d448e9ef67b265a11be8735ff2df4 (grafted)
> Author: Matthieu Moy <Matthieu.Moy@imag.fr>
> Date:   Mon Aug 31 16:32:20 2015 +0200
>
>     Merge remote-tracking branch 'edward/utf-8-email-support4'
>
> Without "-c log.showRoot=false" I get a big patch (diff of the commit
> against the empty tree).

... which shows that Git is consistently pretending as if that
commit is the root commit, which in turn means that it is correct
for "log --no-merges" to not peek into the information at "cat-file
commit" level.

```
