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@xxxxxx> --- 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 = *pp; - if (rewrite_one(revs, &parent->item) < 0) { + if (rewrite_one(revs, &parent->item) < 0 || + /* cull duplicates */ + parent_is_duplicate(commit->parents, parent)) { *pp = parent->next; continue; } -- 1.4.2.4.g21cef-dirty - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html