Code

git-pickaxe: simplify Octopus merges further
authorJunio C Hamano <junkio@cox.net>
Sat, 4 Nov 2006 20:20:09 +0000 (12:20 -0800)
committerJunio C Hamano <junkio@cox.net>
Sat, 4 Nov 2006 20:20:18 +0000 (12:20 -0800)
If more than one parents in an Octopus merge have the same
origin, ignore later ones because it would not make any
difference in the outcome.

Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-pickaxe.c

index 97b3732419b248eba72880972e7a609e63fbcf5f..082ff45fe84d9b6cfa08f85ac05ee2860b0d64b2 100644 (file)
@@ -915,6 +915,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
                     i < MAXPARENT && parent;
                     parent = parent->next, i++) {
                        struct commit *p = parent->item;
+                       int j, same;
 
                        if (parent_origin[i])
                                continue;
@@ -934,7 +935,16 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
                                origin_decref(porigin);
                                goto finish;
                        }
-                       parent_origin[i] = porigin;
+                       for (j = same = 0; j < i; j++)
+                               if (!hashcmp(parent_origin[j]->blob_sha1,
+                                            porigin->blob_sha1)) {
+                                       same = 1;
+                                       break;
+                               }
+                       if (!same)
+                               parent_origin[i] = porigin;
+                       else
+                               origin_decref(porigin);
                }
        }