{"thread":{"id":"41539","subject":"BUG? git log --no-merges shows grafted merges in shallow clones","startedAt":"2016-02-26T19:49:45Z","lastAt":"2016-02-26T20:13:34Z","messageCount":4,"participants":["Matthieu Moy","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"279560","messageId":"vpq4mcvs146.fsf@anie.imag.fr","threadId":"41539","inReplyTo":null,"subject":"BUG? git log --no-merges shows grafted merges in shallow clones","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2016-02-26T19:49:45Z","receivedAt":"2016-02-26T19:49:45Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Hi,\n\nI don't think that's intended. When running \"git log --no-merges\" in a\nshallow clone, and the last commit in the history is a merge commit,\n\"git log --no-merges\" still shows it.\n\nI've just hit this in a test running on a --depth=50 clone on Travis-CI\non git-multimail:\n\n$ git cat-file -p c3c1cc25b27d448e9ef67b265a11be8735ff2df4\ntree c341dd60c4b639eac1d6dcc3caffb5d7201c2245\nparent b312e3f90dfef73ba0288999981694b09affdf6b\nparent 842ac6e867885af041499723dc46f2197705204c\nauthor Matthieu Moy <Matthieu.Moy@imag.fr> 1441031540 +0200\ncommitter Matthieu Moy <Matthieu.Moy@imag.fr> 1441031540 +0200\n\nMerge remote-tracking branch 'edward/utf-8-email-support4'\n\n$ git log --no-merges c3c1cc25b27d448e9ef67b265a11be8735ff2df4\ncommit c3c1cc25b27d448e9ef67b265a11be8735ff2df4 (grafted)\nAuthor: Matthieu Moy <Matthieu.Moy@imag.fr>\nDate:   Mon Aug 31 16:32:20 2015 +0200\n\n    Merge remote-tracking branch 'edward/utf-8-email-support4'\n\nI guess Git counts the number of parents that are actually in the\nrepository, but it could check the number of \"parents\" field in the\nobject (cat-file -p was still able to show 2).\n\nThanks,\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"279561","messageId":"xmqqfuwfjl8e.fsf@gitster.mtv.corp.google.com","threadId":"41539","inReplyTo":"vpq4mcvs146.fsf@anie.imag.fr","subject":"Re: BUG? git log --no-merges shows grafted merges in shallow clones","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-26T20:00:01Z","receivedAt":"2016-02-26T20:00:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Hi,\n>\n> I don't think that's intended. When running \"git log --no-merges\" in a\n> shallow clone, and the last commit in the history is a merge commit,\n> \"git log --no-merges\" still shows it.\n>\n> I've just hit this in a test running on a --depth=50 clone on Travis-CI\n> on git-multimail:\n>\n> $ git cat-file -p c3c1cc25b27d448e9ef67b265a11be8735ff2df4\n> tree c341dd60c4b639eac1d6dcc3caffb5d7201c2245\n> parent b312e3f90dfef73ba0288999981694b09affdf6b\n> parent 842ac6e867885af041499723dc46f2197705204c\n> author Matthieu Moy <Matthieu.Moy@imag.fr> 1441031540 +0200\n> committer Matthieu Moy <Matthieu.Moy@imag.fr> 1441031540 +0200\n>\n> Merge remote-tracking branch 'edward/utf-8-email-support4'\n>\n> $ git log --no-merges c3c1cc25b27d448e9ef67b265a11be8735ff2df4\n> commit c3c1cc25b27d448e9ef67b265a11be8735ff2df4 (grafted)\n> Author: Matthieu Moy <Matthieu.Moy@imag.fr>\n> Date:   Mon Aug 31 16:32:20 2015 +0200\n>\n>     Merge remote-tracking branch 'edward/utf-8-email-support4'\n>\n> I guess Git counts the number of parents that are actually in the\n> repository, but it could check the number of \"parents\" field in the\n> object (cat-file -p was still able to show 2).\n\nI do not think this is limited to shallow but for grafts in\ngeneral.  cat-file is low-level to show the bare metal, but by using\nthese facility you asked Git to give you an imaginary history where\nthat commit is the root commit--and that is why it is shown, I\nthink.\n\nWhat does it do if you say \"git -c log.showRoot=false log -p\"?\n"},{"id":"279562","messageId":"vpqwpprqlt4.fsf@anie.imag.fr","threadId":"41539","inReplyTo":"xmqqfuwfjl8e.fsf@gitster.mtv.corp.google.com","subject":"Re: BUG? git log --no-merges shows grafted merges in shallow clones","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2016-02-26T20:05:43Z","receivedAt":"2016-02-26T20:05:43Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> I do not think this is limited to shallow but for grafts in\n> general.  \n\nProbably yes. I happen to only use grafts in shallow clones ;-).\n\n> cat-file is low-level to show the bare metal, but by using these\n> facility you asked Git to give you an imaginary history where that\n> commit is the root commit--and that is why it is shown, I think.\n>\n> What does it do if you say \"git -c log.showRoot=false log -p\"?\n\nI get the commit without the patch:\n\ncommit c3c1cc25b27d448e9ef67b265a11be8735ff2df4 (grafted)\nAuthor: Matthieu Moy <Matthieu.Moy@imag.fr>\nDate:   Mon Aug 31 16:32:20 2015 +0200\n\n    Merge remote-tracking branch 'edward/utf-8-email-support4'\n\nWithout \"-c log.showRoot=false\" I get a big patch (diff of the commit\nagainst the empty tree).\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"279563","messageId":"xmqqbn73jklt.fsf@gitster.mtv.corp.google.com","threadId":"41539","inReplyTo":"vpqwpprqlt4.fsf@anie.imag.fr","subject":"Re: BUG? git log --no-merges shows grafted merges in shallow clones","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-26T20:13:34Z","receivedAt":"2016-02-26T20:13:34Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> I do not think this is limited to shallow but for grafts in\n>> general.  \n>\n> Probably yes. I happen to only use grafts in shallow clones ;-).\n>\n>> cat-file is low-level to show the bare metal, but by using these\n>> facility you asked Git to give you an imaginary history where that\n>> commit is the root commit--and that is why it is shown, I think.\n>>\n>> What does it do if you say \"git -c log.showRoot=false log -p\"?\n>\n> I get the commit without the patch:\n>\n> commit c3c1cc25b27d448e9ef67b265a11be8735ff2df4 (grafted)\n> Author: Matthieu Moy <Matthieu.Moy@imag.fr>\n> Date:   Mon Aug 31 16:32:20 2015 +0200\n>\n>     Merge remote-tracking branch 'edward/utf-8-email-support4'\n>\n> Without \"-c log.showRoot=false\" I get a big patch (diff of the commit\n> against the empty tree).\n\n... which shows that Git is consistently pretending as if that\ncommit is the root commit, which in turn means that it is correct\nfor \"log --no-merges\" to not peek into the information at \"cat-file\ncommit\" level.\n"}]}