When trying to find how many merges and how many octopus merges (merges with more than two parents) are in git.git repository I have encountered the following strange output of git-log: 1000:jnareb@roke:~/git> git log --parents --full-history --max-count=1 \ 211232bae64bcc60bbf5d1b5e5b2344c22ed767e -- a//b commit 211232bae64bcc60bbf5d1b5e5b2344c22ed767e <last parent repeated> Merge: d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b... [...] while git-show gives correct output 1005:jnareb@roke:~/git> git show 211232bae64bcc60bbf5d1b5e5b2344c22ed767e commit 211232bae64bcc60bbf5d1b5e5b2344c22ed767e Merge: fc54a9c... 9e30dd7... c4b83e6... 6602659... b28858b... [...] Same with git-rev-list, also shows correct output: 1005:jnareb@roke:~/git> git rev-list --header --parents --max-count=1 \ 211232bae64bcc60bbf5d1b5e5b2344c22ed767e 211232bae64bcc60bbf5d1b5e5b2344c22ed767e [...] tree cdafa88fa4ed7fcc7bb6c64d62e2d7c4d3b65e42 parent fc54a9c30ccad3fde5890d2c0ca2e2acc0848fbc parent 9e30dd7c0ecc9f10372f31539d0122db97418353 parent c4b83e618f1df7d8ecc9392fa40e5bebccbe6b5a parent 660265909fc178581ef327076716dfd3550e6e7b parent b28858bf65d4fd6d8bb070865518ec43817fe7f3 [...] 1008:jnareb@roke:~/git> git --version git version 1.4.2.1 -- Jakub Narebski Warsaw, Poland ShadeHawk on #git -
Hi, This happens because a//b rewrites the history, i.e. the parents are edited. IMHO it makes no sense at all to show the parents in such a case, since they are bogus. Ciao, Dscho -
Or rather it has no sense to _repeat_ rewritten parent the number of times
the commit has parents originally. Compare git-log and git-rev-list results:
1010:jnareb@roke:~/git> git rev-list --full-history --header --parents \
--max-count=2 211232bae64bcc60bbf5d1b5e5b2344c22ed767e -- a//b
211232bae64bcc60bbf5d1b5e5b2344c22ed767e d0d0d0bd3c2c4591ffbc292d7e082e8ad8f2057f
tree cdafa88fa4ed7fcc7bb6c64d62e2d7c4d3b65e42
parent fc54a9c30ccad3fde5890d2c0ca2e2acc0848fbc
parent 9e30dd7c0ecc9f10372f31539d0122db97418353
parent c4b83e618f1df7d8ecc9392fa40e5bebccbe6b5a
parent 660265909fc178581ef327076716dfd3550e6e7b
parent b28858bf65d4fd6d8bb070865518ec43817fe7f3
author Junio C Hamano <junkio@cox.net> 1115335014 -0700
committer Junio C Hamano <junkio@cox.net> 1115335014 -0700
Octopus merge of the following five patches.
Update git-apply-patch-script for symbolic links.
Make git-prune-script executable again.
Do not write out new index if nothing has changed.
diff-cache shows differences for unmerged paths without --cache.
Update diff engine for symlinks stored in the cache.
Signed-off-by: Junio C Hamano <junkio@cox.net>
d0d0d0bd3c2c4591ffbc292d7e082e8ad8f2057f 54c26fb9d0cdff94c7717125d0a222b324bfea8a
[...]
1014:jnareb@roke:~/git> PAGER= git log --full-history --parents \
--max-count=2 211232bae64bcc60bbf5d1b5e5b2344c22ed767e -- a//b
commit 211232bae64bcc60bbf5d1b5e5b2344c22ed767e d0d0d0bd3c2c4591ffbc292d7e082e8ad8f2057f d0d0d0bd3c2c4591ffbc292d7e082e8ad8f2057f d0d0d0bd3c2c4591ffbc292d7e082e8ad8f2057f d0d0d0bd3c2c4591ffbc292d7e082e8ad8f2057f d0d0d0bd3c2c4591ffbc292d7e082e8ad8f2057f
Merge: d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b...
Author: Junio C Hamano <junkio@cox.net>
Date: Thu May 5 16:16:54 2005 -0700
Octopus merge of the following five patches.
Update git-apply-patch-script for symbolic links.
Make git-prune-script executable again.
Do not write out new index if nothing has changed.
...Earlier, when calling
git log --parents some-ref -- path/file
it was possible that in case of merges, multiple parents would be
rewritten as the _same_ commit, which would happily be printed
multiple times.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
Subject: Re: [BUG] git-log shows first parent and repeated last
for octopus merge
On Wed, 18 Oct 2006, Jakub Narebski wrote:
> Johannes Schindelin wrote:
> > On Wed, 18 Oct 2006, Jakub Narebski wrote:
> >
> > > When trying to find how many merges and how many octopus
> > > merges (merges with more than two parents) are in git.git
> > > repository I have encountered the following strange output
> > > of git-log:
> > >
> > > 1000:jnareb@roke:~/git> git log --parents --full-history \
> > > --max-count=1 211232bae64bcc60bbf5d1b5e5b2344c22ed767e -- a//b
> > > commit 211232bae64bcc60bbf5d1b5e5b2344c22ed767e <...>
> > > Merge: d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b... d0d0d0b...
> > > [...]
> >
> > This happens because a//b rewrites the history, i.e. the
> > parents are edited. IMHO it makes no sense at all to show the
> > parents in such a case, since they are bogus.
>
> Or rather it has no sense to _repeat_ rewritten parent the
> number of times the commit has parents originally.
Here you are.
revision.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/revision.c b/revision.c
index 280e92b..8a2ca52 100644
--- a/revision.c
+++ b/revision.c
@@ -1086,12 +1086,23 @@ static int rewrite_one(struct rev_info *
}
}
+static int parent_is_duplicate(struct commit_list *parents,
+ struct commit_list *current)
+{
+ for (; parents != current; parents = parents->next)
+ if (parents->item == current->item)
+ return 1;
+ return 0;
+}
+
static void rewrite_parents(struct rev_info *revs, struct commit *commit)
{
struct commit_list **pp = &commit->parents;
while (*pp) {
struct commit_list *parent ...If the command line did not have --full-history, I would agree with you. The caller explicitly told us not to remove side branches that do not end up modifying the paths, and also told us, with --parent, to show parenthood information after removing intermediate commits that do not change the tree shape (with respect to the specified paths). So it is showing what the user asked -- the user may not have understood what he was asking, but that is a separate problem, I would think. -
Maybe the following will find what you're looking for:
git-rev-list master --parents \
|sed -e 's/[0-9a-f]\{40\}//' -e 's/ [0-9a-f]\{40\}/*/g' \
|sort \
|uniq -c
-
