Code

Fix up duplicate parents removal
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 21 Jul 2007 06:11:19 +0000 (23:11 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 21 Jul 2007 06:36:39 +0000 (23:36 -0700)
This removes duplicate parents properly, making gitk happy again.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c

index 28b5f2eacebf637323fa0af112ea568beb95c7f3..7036cf2246e8bd0c169716a12c9b9f2ecffdec8d 100644 (file)
@@ -1323,16 +1323,17 @@ 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;
+       struct commit_list **pp, *p;
 
        /* Examine existing parents while marking ones we have seen... */
-       for (p = commit->parents; p; p = p->next) {
+       pp = &commit->parents;
+       while ((p = *pp) != NULL) {
                struct commit *parent = p->item;
-               if (parent->object.flags & TMP_MARK)
+               if (parent->object.flags & TMP_MARK) {
+                       *pp = p->next;
                        continue;
+               }
                parent->object.flags |= TMP_MARK;
-               *pp = p;
                pp = &p->next;
        }
        /* ... and clear the temporary mark */