Skip to content

Commit

Permalink
revision: disable min_age optimization with line-log
Browse files Browse the repository at this point in the history
If one of the options --before, --min-age or --until is given,
limit_list() filters out younger commits early on.  Line-log needs all
those commits to trace the movement of line ranges, though.  Skip this
optimization if both are used together.

Reported-by: Мария Долгополова <[email protected]>
Signed-off-by: René Scharfe <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
rscharfe authored and gitster committed Jul 7, 2020
1 parent a08a83d commit 01faa91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,8 @@ static int limit_list(struct rev_info *revs)
continue;
break;
}
if (revs->min_age != -1 && (commit->date > revs->min_age))
if (revs->min_age != -1 && (commit->date > revs->min_age) &&
!revs->line_level_traverse)
continue;
date = commit->date;
p = &commit_list_insert(commit, p)->next;
Expand Down
8 changes: 8 additions & 0 deletions t/t4211-line-log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,12 @@ test_expect_success 'setup for checking line-log and parent oids' '
EOF
git add file.c &&
test_tick &&
first_tick=$test_tick &&
git commit -m "Add func1() and func2() in file.c" &&
echo 1 >other-file &&
git add other-file &&
test_tick &&
git commit -m "Add other-file" &&
sed -e "s/F1/F1 + 1/" file.c >tmp &&
Expand Down Expand Up @@ -283,4 +285,10 @@ test_expect_success 'parent oids with parent rewriting' '
test_cmp expect actual
'

test_expect_success 'line-log with --before' '
echo $root_oid >expect &&
git log --format=%h --no-patch -L:func2:file.c --before=$first_tick >actual &&
test_cmp expect actual
'

test_done

0 comments on commit 01faa91

Please sign in to comment.