X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=revision.c;h=f03b7031e5217ffae37f102a0d4c1efe3f93d85d;hb=36ed1913e1d5de0930e59db6eeec3ccb2bd58bd9;hp=c46cfaa3e4d2f06fd67ccd71c7ba47891796fd60;hpb=b9575e78e504d0fed4747bb2325aa09e2626b6e9;p=git.git diff --git a/revision.c b/revision.c index c46cfaa3e..f03b7031e 100644 --- a/revision.c +++ b/revision.c @@ -368,7 +368,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit) static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit) { struct commit_list **pp, *parent; - int tree_changed = 0, tree_same = 0; + int tree_changed = 0, tree_same = 0, nth_parent = 0; /* * If we don't do pruning, everything is interesting @@ -396,6 +396,14 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit) while ((parent = *pp) != NULL) { struct commit *p = parent->item; + /* + * Do not compare with later parents when we care only about + * the first parent chain, in order to avoid derailing the + * traversal to follow a side branch that brought everything + * in the path we are limited to by the pathspec. + */ + if (revs->first_parent_only && nth_parent++) + break; if (parse_commit(p) < 0) die("cannot simplify commit %s (because of %s)", sha1_to_hex(commit->object.sha1),