{"thread":{"id":"5948","subject":"[BUG] git-log shows first parent and repeated last for octopus merge","startedAt":"2006-10-18T11:11:35Z","lastAt":"2006-10-18T19:02:19Z","messageCount":6,"participants":["Jakub Narebski","Johannes Schindelin","A Large Angry SCM","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"29105","messageId":"eh5242$rar$1@sea.gmane.org","threadId":"5948","inReplyTo":null,"subject":"[BUG] git-log shows first parent and repeated last for octopus merge","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-18T11:11:35Z","receivedAt":"2006-10-18T11:11:35Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"When trying to find how many merges and how many octopus merges (merges with\nmore than two parents) are in git.git repository I have encountered the\nfollowing strange output of git-log:\n\n 1000:jnareb@roke:~/git> git log --parents --full-history --max-count=1 \\\n   211232bae64bcc60bbf5d1b5e5b2344c22ed767e -- a//b\n commit 211232bae64bcc60bbf5d1b5e5b2344c22ed767e <last parent repeated>\n Merge: d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b...\n [...]\n\nwhile git-show gives correct output\n\n 1005:jnareb@roke:~/git> git show 211232bae64bcc60bbf5d1b5e5b2344c22ed767e\n commit 211232bae64bcc60bbf5d1b5e5b2344c22ed767e\n Merge: fc54a9c... 9e30dd7... c4b83e6... 6602659... b28858b...\n [...]\n\nSame with git-rev-list, also shows correct output:\n\n 1005:jnareb@roke:~/git> git rev-list --header --parents --max-count=1 \\\n   211232bae64bcc60bbf5d1b5e5b2344c22ed767e\n 211232bae64bcc60bbf5d1b5e5b2344c22ed767e [...] \n tree cdafa88fa4ed7fcc7bb6c64d62e2d7c4d3b65e42\n parent fc54a9c30ccad3fde5890d2c0ca2e2acc0848fbc\n parent 9e30dd7c0ecc9f10372f31539d0122db97418353\n parent c4b83e618f1df7d8ecc9392fa40e5bebccbe6b5a\n parent 660265909fc178581ef327076716dfd3550e6e7b\n parent b28858bf65d4fd6d8bb070865518ec43817fe7f3\n [...]\n\n1008:jnareb@roke:~/git> git --version\ngit version 1.4.2.1\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"29116","messageId":"Pine.LNX.4.63.0610181551150.14200@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"5948","inReplyTo":"eh5242$rar$1@sea.gmane.org","subject":"Re: [BUG] git-log shows first parent and repeated last for octopus merge","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-10-18T13:53:23Z","receivedAt":"2006-10-18T13:53:23Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 18 Oct 2006, Jakub Narebski wrote:\n\n> When trying to find how many merges and how many octopus merges (merges with\n> more than two parents) are in git.git repository I have encountered the\n> following strange output of git-log:\n> \n>  1000:jnareb@roke:~/git> git log --parents --full-history --max-count=1 \\\n>    211232bae64bcc60bbf5d1b5e5b2344c22ed767e -- a//b\n>  commit 211232bae64bcc60bbf5d1b5e5b2344c22ed767e <last parent repeated>\n>  Merge: d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b...\n>  [...]\n\nThis happens because a//b rewrites the history, i.e. the parents are \nedited. IMHO it makes no sense at all to show the parents in such a case, \nsince they are bogus.\n\nCiao,\nDscho\n"},{"id":"29117","messageId":"200610181602.36856.jnareb@gmail.com","threadId":"5948","inReplyTo":"Pine.LNX.4.63.0610181551150.14200@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [BUG] git-log shows first parent and repeated last for octopus merge","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-18T14:02:36Z","receivedAt":"2006-10-18T14:02:36Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Johannes Schindelin wrote:\n> On Wed, 18 Oct 2006, Jakub Narebski wrote:\n> \n> > When trying to find how many merges and how many octopus merges (merges with\n> > more than two parents) are in git.git repository I have encountered the\n> > following strange output of git-log:\n> > \n> >  1000:jnareb@roke:~/git> git log --parents --full-history --max-count=1 \\\n> >    211232bae64bcc60bbf5d1b5e5b2344c22ed767e -- a//b\n> >  commit 211232bae64bcc60bbf5d1b5e5b2344c22ed767e <last parent repeated>\n> >  Merge: d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b...\n> >  [...]\n> \n> This happens because a//b rewrites the history, i.e. the parents are \n> edited. IMHO it makes no sense at all to show the parents in such a case, \n> since they are bogus.\n\nOr rather it has no sense to _repeat_ rewritten parent the number of times\nthe commit has parents originally. Compare git-log and git-rev-list results:\n\n1010:jnareb@roke:~/git> git rev-list --full-history --header --parents \\\n  --max-count=2 211232bae64bcc60bbf5d1b5e5b2344c22ed767e -- a//b\n211232bae64bcc60bbf5d1b5e5b2344c22ed767e d0d0d0bd3c2c4591ffbc292d7e082e8ad8f2057f\ntree cdafa88fa4ed7fcc7bb6c64d62e2d7c4d3b65e42\nparent fc54a9c30ccad3fde5890d2c0ca2e2acc0848fbc\nparent 9e30dd7c0ecc9f10372f31539d0122db97418353\nparent c4b83e618f1df7d8ecc9392fa40e5bebccbe6b5a\nparent 660265909fc178581ef327076716dfd3550e6e7b\nparent b28858bf65d4fd6d8bb070865518ec43817fe7f3\nauthor Junio C Hamano <junkio@cox.net> 1115335014 -0700\ncommitter Junio C Hamano <junkio@cox.net> 1115335014 -0700\n\n    Octopus merge of the following five patches.\n    \n      Update git-apply-patch-script for symbolic links.\n      Make git-prune-script executable again.\n      Do not write out new index if nothing has changed.\n      diff-cache shows differences for unmerged paths without --cache.\n      Update diff engine for symlinks stored in the cache.\n    \n    Signed-off-by: Junio C Hamano <junkio@cox.net>\nd0d0d0bd3c2c4591ffbc292d7e082e8ad8f2057f 54c26fb9d0cdff94c7717125d0a222b324bfea8a\n[...]\n\n1014:jnareb@roke:~/git> PAGER= git log --full-history --parents \\\n  --max-count=2 211232bae64bcc60bbf5d1b5e5b2344c22ed767e -- a//b\ncommit 211232bae64bcc60bbf5d1b5e5b2344c22ed767e d0d0d0bd3c2c4591ffbc292d7e082e8ad8f2057f d0d0d0bd3c2c4591ffbc292d7e082e8ad8f2057f d0d0d0bd3c2c4591ffbc292d7e082e8ad8f2057f d0d0d0bd3c2c4591ffbc292d7e082e8ad8f2057f d0d0d0bd3c2c4591ffbc292d7e082e8ad8f2057f\nMerge: d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b...\nAuthor: Junio C Hamano <junkio@cox.net>\nDate:   Thu May 5 16:16:54 2005 -0700\n\n    Octopus merge of the following five patches.\n    \n      Update git-apply-patch-script for symbolic links.\n      Make git-prune-script executable again.\n      Do not write out new index if nothing has changed.\n      diff-cache shows differences for unmerged paths without --cache.\n      Update diff engine for symlinks stored in the cache.\n    \n    Signed-off-by: Junio C Hamano <junkio@cox.net>\n\ncommit d0d0d0bd3c2c4591ffbc292d7e082e8ad8f2057f 54c26fb9d0cdff94c7717125d0a222b324bfea8a 54c26fb9d0cdff94c7717125d0a222b324bfea8a\n[...]\n\n-- \nJakub Narebski\nPoland\n"},{"id":"29118","messageId":"Pine.LNX.4.63.0610181622320.14200@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"5948","inReplyTo":"200610181602.36856.jnareb@gmail.com","subject":"[PATCH] When rewriting parents, cull duplicates","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-10-18T14:26:56Z","receivedAt":"2006-10-18T14:26:56Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nEarlier, when calling\n\n\tgit log --parents some-ref -- path/file\n\nit was possible that in case of merges, multiple parents would be\nrewritten as the _same_ commit, which would happily be printed\nmultiple times.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n\tSubject: Re: [BUG] git-log shows first parent and repeated last \n\tfor octopus merge\n\n\tOn Wed, 18 Oct 2006, Jakub Narebski wrote:\n\n\t> Johannes Schindelin wrote:\n\t> > On Wed, 18 Oct 2006, Jakub Narebski wrote:\n\t> > \n\t> > > When trying to find how many merges and how many octopus \n\t> > > merges (merges with more than two parents) are in git.git \n\t> > > repository I have encountered the following strange output \n\t> > > of git-log:\n\t> > > \n\t> > > 1000:jnareb@roke:~/git> git log --parents --full-history \\\n\t> > > --max-count=1 211232bae64bcc60bbf5d1b5e5b2344c22ed767e -- a//b\n\t> > >  commit 211232bae64bcc60bbf5d1b5e5b2344c22ed767e <...>\n\t> > >  Merge: d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b...\n\t> > >  [...]\n\t> > \n\t> > This happens because a//b rewrites the history, i.e. the \n\t> > parents are edited. IMHO it makes no sense at all to show the \n\t> > parents in such a case, since they are bogus.\n\t> \n\t> Or rather it has no sense to _repeat_ rewritten parent the \n\t> number of times the commit has parents originally.\n\n\tHere you are.\n\n revision.c |   13 ++++++++++++-\n 1 files changed, 12 insertions(+), 1 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 280e92b..8a2ca52 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1086,12 +1086,23 @@ static int rewrite_one(struct rev_info *\n \t}\n }\n \n+static int parent_is_duplicate(struct commit_list *parents,\n+\t\tstruct commit_list *current)\n+{\n+\tfor (; parents != current; parents = parents->next)\n+\t\tif (parents->item == current->item)\n+\t\t\treturn 1;\n+\treturn 0;\n+}\n+\n static void rewrite_parents(struct rev_info *revs, struct commit *commit)\n {\n \tstruct commit_list **pp = &commit->parents;\n \twhile (*pp) {\n \t\tstruct commit_list *parent = *pp;\n-\t\tif (rewrite_one(revs, &parent->item) < 0) {\n+\t\tif (rewrite_one(revs, &parent->item) < 0 ||\n+\t\t\t\t/* cull duplicates */\n+\t\t\t\tparent_is_duplicate(commit->parents, parent)) {\n \t\t\t*pp = parent->next;\n \t\t\tcontinue;\n \t\t}\n-- \n1.4.2.4.g21cef-dirty\n"},{"id":"29129","messageId":"453657D4.70502@gmail.com","threadId":"5948","inReplyTo":"eh5242$rar$1@sea.gmane.org","subject":"Re: [BUG] git-log shows first parent and repeated last for octopus merge","fromName":"A Large Angry SCM","fromEmail":"gitzilla@gmail.com","sentAt":"2006-10-18T16:35:32Z","receivedAt":"2006-10-18T16:35:32Z","isPatch":false,"sender":{"key":"gitzilla@gmail.com","avatar":"https://gravatar.com/avatar/354625c442439908ff3dd99757dee330e29e9df7847472384faf7a00add247fb?d=mp&s=160"},"body":"Jakub Narebski wrote:\n> When trying to find how many merges and how many octopus merges (merges with\n> more than two parents) are in git.git repository I have encountered the\n> following strange output of git-log:\n\nMaybe the following will find what you're looking for:\n\ngit-rev-list master --parents \\\n\t|sed -e 's/[0-9a-f]\\{40\\}//' -e 's/ [0-9a-f]\\{40\\}/*/g' \\\n\t|sort \\\n\t|uniq -c\n"},{"id":"29135","messageId":"7v3b9l30sk.fsf@assigned-by-dhcp.cox.net","threadId":"5948","inReplyTo":"Pine.LNX.4.63.0610181551150.14200@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [BUG] git-log shows first parent and repeated last for octopus merge","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-10-18T19:02:19Z","receivedAt":"2006-10-18T19:02:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Hi,\n>\n> On Wed, 18 Oct 2006, Jakub Narebski wrote:\n>\n>> When trying to find how many merges and how many octopus merges (merges with\n>> more than two parents) are in git.git repository I have encountered the\n>> following strange output of git-log:\n>> \n>>  1000:jnareb@roke:~/git> git log --parents --full-history --max-count=1 \\\n>>    211232bae64bcc60bbf5d1b5e5b2344c22ed767e -- a//b\n>>  commit 211232bae64bcc60bbf5d1b5e5b2344c22ed767e <last parent repeated>\n>>  Merge: d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b...\n>>  [...]\n>\n> This happens because a//b rewrites the history, i.e. the parents are \n> edited. IMHO it makes no sense at all to show the parents in such a case, \n> since they are bogus.\n\nIf the command line did not have --full-history, I would agree\nwith you.  The caller explicitly told us not to remove side\nbranches that do not end up modifying the paths, and also told\nus, with --parent, to show parenthood information after removing\nintermediate commits that do not change the tree shape (with\nrespect to the specified paths).\n\nSo it is showing what the user asked -- the user may not have\nunderstood what he was asking, but that is a separate problem, I\nwould think.\n"}]}