Skip to content

Commit f3219fb

Browse files
author
Junio C Hamano
committed
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: 461cf59 Signed-off-by: Junio C Hamano <[email protected]>
1 parent eb0e002 commit f3219fb

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

revision.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ static int same_tree_as_empty(struct tree *t1)
282282
static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
283283
{
284284
struct commit_list **pp, *parent;
285+
int tree_changed = 0;
285286

286287
if (!commit->tree)
287288
return;
@@ -296,14 +297,19 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
296297
while ((parent = *pp) != NULL) {
297298
struct commit *p = parent->item;
298299

299-
if (p->object.flags & UNINTERESTING) {
300-
pp = &parent->next;
301-
continue;
302-
}
303-
304300
parse_commit(p);
305301
switch (compare_tree(p->tree, commit->tree)) {
306302
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+
}
307313
parent->next = NULL;
308314
commit->parents = parent;
309315
return;
@@ -315,12 +321,14 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
315321
}
316322
/* fallthrough */
317323
case TREE_DIFFERENT:
324+
tree_changed = 1;
318325
pp = &parent->next;
319326
continue;
320327
}
321328
die("bad tree compare for commit %s", sha1_to_hex(commit->object.sha1));
322329
}
323-
commit->object.flags |= TREECHANGE;
330+
if (tree_changed)
331+
commit->object.flags |= TREECHANGE;
324332
}
325333

326334
static void add_parents_to_list(struct rev_info *revs, struct commit *commit, struct commit_list **list)

0 commit comments

Comments
 (0)