Skip to content

Commit

Permalink
revision.c: remove duplicated parents after history simplification
Browse files Browse the repository at this point in the history
When we simplify history due to path limits, the parents list
for a rewritten commit can end up having duplicates.  Instead of
filtering them out in the output codepath like earlier commit
8849442 did, remove them much earlier, when the parent
information actually gets rewritten.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Jul 9, 2007
1 parent ae7aa49 commit 11d6596
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,25 @@ static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp
}
}

static void remove_duplicate_parents(struct commit *commit)
{
struct commit_list *p;
struct commit_list **pp = &commit->parents;

/* Examine existing parents while marking ones we have seen... */
for (p = commit->parents; p; p = p->next) {
struct commit *parent = p->item;
if (parent->object.flags & TMP_MARK)
continue;
parent->object.flags |= TMP_MARK;
*pp = p;
pp = &p->next;
}
/* ... and clear the temporary mark */
for (p = commit->parents; p; p = p->next)
p->item->object.flags &= ~TMP_MARK;
}

static int rewrite_parents(struct rev_info *revs, struct commit *commit)
{
struct commit_list **pp = &commit->parents;
Expand All @@ -1324,6 +1343,7 @@ static int rewrite_parents(struct rev_info *revs, struct commit *commit)
}
pp = &parent->next;
}
remove_duplicate_parents(commit);
return 0;
}

Expand Down

0 comments on commit 11d6596

Please sign in to comment.