@matheusbsbs / matheus-bagliano / commits / 11d6596709
Fork 0

revision.c: remove duplicated parents after history simplification

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 88494423 did, remove them much earlier, when the parent information actually gets rewritten. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jul 8, 2007 at 19:03 UTC 11d6596709e04b8d2b429f230b2ed570d013f812
1 file changed +20
revision.c
+20
@@ -1308,6 +1308,25 @@ static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp
1308 }
1309 }
1310
1311 +static void remove_duplicate_parents(struct commit *commit)
1312 +{
1313 + struct commit_list *p;
1314 + struct commit_list **pp = &commit->parents;
1315 +
1316 + /* Examine existing parents while marking ones we have seen... */
1317 + for (p = commit->parents; p; p = p->next) {
1318 + struct commit *parent = p->item;
1319 + if (parent->object.flags & TMP_MARK)
1320 + continue;
1321 + parent->object.flags |= TMP_MARK;
1322 + *pp = p;
1323 + pp = &p->next;
1324 + }
1325 + /* ... and clear the temporary mark */
1326 + for (p = commit->parents; p; p = p->next)
1327 + p->item->object.flags &= ~TMP_MARK;
1328 +}
1329 +
1330 static int rewrite_parents(struct rev_info *revs, struct commit *commit)
1331 {
1332 struct commit_list **pp = &commit->parents;
@@ -1324,6 +1343,7 @@ static int rewrite_parents(struct rev_info *revs, struct commit *commit)
1343 }
1344 pp = &parent->next;
1345 }
1346 + remove_duplicate_parents(commit);
1347 return 0;
1348 }
1349