simplify-merges: drop merge from irrelevant side branch
[gitweb.git] / revision.c
index 33cb207f281f97f0eb1c24dd0b5200feda49848d..3536635a887c3c6c43cdc5c6d280a98d174b4a81 100644 (file)
@@ -1424,6 +1424,22 @@ static struct merge_simplify_state *locate_simplify_state(struct rev_info *revs,
        return st;
 }
 
+static void remove_treesame_parents(struct commit *commit)
+{
+       struct commit_list **pp, *p;
+
+       pp = &commit->parents;
+       while ((p = *pp) != NULL) {
+               struct commit *parent = p->item;
+               if (parent->object.flags & TREESAME) {
+                       *pp = p->next;
+                       free(p);
+                       continue;
+               }
+               pp = &p->next;
+       }
+}
+
 static struct commit_list **simplify_one(struct rev_info *revs, struct commit *commit, struct commit_list **tail)
 {
        struct commit_list *p;
@@ -1469,6 +1485,13 @@ static struct commit_list **simplify_one(struct rev_info *revs, struct commit *c
                pst = locate_simplify_state(revs, p->item);
                p->item = pst->simplified;
        }
+
+       /*
+        * A merge with a tree-same parent is useless
+        */
+       if (commit->parents && commit->parents->next)
+               remove_treesame_parents(commit);
+
        cnt = remove_duplicate_parents(commit);
 
        /*