@matheusbsbs / matheus-bagliano / commits / f3219fbbba
Fork 0

try_to_simplify_commit(): do not skip inspecting tree change at boundary.

When git-rev-list (and git-log) collapsed ancestry chain to commits that touch specified paths, we failed to inspect and notice tree changes when we are about to hit uninteresting parent. This resulted in "git rev-list since.. -- file" to always show the child commit after the lower bound, even if it does not touch the file. This commit fixes it. Thanks for Catalin for reporting this. See also: 461cf59f8924f174d7a0dcc3d77f576d93ed29a4 Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Mar 10, 2006 at 21:59 UTC f3219fbbba32b5100430c17468524b776eb869d6
1 file changed +14 -6
revision.c
+14 -6
@@ -282,6 +282,7 @@ static int same_tree_as_empty(struct tree *t1)
282 static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
283 {
284 struct commit_list **pp, *parent;
285 + int tree_changed = 0;
286
287 if (!commit->tree)
288 return;
@@ -296,14 +297,19 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
297 while ((parent = *pp) != NULL) {
298 struct commit *p = parent->item;
299
299 - if (p->object.flags & UNINTERESTING) {
300 - pp = &parent->next;
301 - continue;
302 - }
303 -
300 parse_commit(p);
301 switch (compare_tree(p->tree, commit->tree)) {
302 case TREE_SAME:
303 + if (p->object.flags & UNINTERESTING) {
304 + /* Even if a merge with an uninteresting
305 + * side branch brought the entire change
306 + * we are interested in, we do not want
307 + * to lose the other branches of this
308 + * merge, so we just keep going.
309 + */
310 + pp = &parent->next;
311 + continue;
312 + }
313 parent->next = NULL;
314 commit->parents = parent;
315 return;
@@ -315,12 +321,14 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
321 }
322 /* fallthrough */
323 case TREE_DIFFERENT:
324 + tree_changed = 1;
325 pp = &parent->next;
326 continue;
327 }
328 die("bad tree compare for commit %s", sha1_to_hex(commit->object.sha1));
329 }
323 - commit->object.flags |= TREECHANGE;
330 + if (tree_changed)
331 + commit->object.flags |= TREECHANGE;
332 }
333
334 static void add_parents_to_list(struct rev_info *revs, struct commit *commit, struct commit_list **list)