diff options
author | Edmundo Carmona Antoranz <eantoranz@gmail.com> | 2022-04-06 21:13:20 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-04-06 23:29:59 +0300 |
commit | e5f5d7d42effb1d0d404897ac782783f742e9daa (patch) | |
tree | f6c7fe3f53ac77de4a59ff5872c5cca5e7bd3a3e /t/annotate-tests.sh | |
parent | 4c53a8c20f8984adb226293a3ffd7b88c3f4ac1a (diff) |
blame: report correct number of lines in progress when using ranges
When using ranges, use the range sizes as the limit for progress
instead of the size of the full file.
Before:
$ git blame --progress builtin/blame.c > /dev/null
Blaming lines: 100% (1210/1210), done.
$ git blame --progress -L 100,120 -L 200,300 builtin/blame.c > /dev/null
Blaming lines: 10% (122/1210), done.
$
After:
$ ./git blame --progress builtin/blame.c > /dev/null
Blaming lines: 100% (1210/1210), done.
$ ./git blame --progress -L 100,120 -L 200,300 builtin/blame.c > /dev/null
Blaming lines: 100% (122/122), done.
$
Signed-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/annotate-tests.sh')
-rw-r--r-- | t/annotate-tests.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index 09e86f9ba0..cc01d89150 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -56,6 +56,10 @@ check_count () { ' "$@" <actual } +get_progress_result () { + tr '\015' '\012' | tail -n 1 +} + test_expect_success 'setup A lines' ' echo "1A quick brown fox jumps over the" >file && echo "lazy dog" >>file && @@ -604,3 +608,39 @@ test_expect_success 'blame -L X,-N (non-numeric N)' ' test_expect_success 'blame -L ,^/RE/' ' test_must_fail $PROG -L1,^/99/ file ' + +test_expect_success 'blame progress on a full file' ' + cat >expect <<-\EOF && + Blaming lines: 100% (10/10), done. + EOF + + GIT_PROGRESS_DELAY=0 \ + git blame --progress hello.c 2>stderr && + + get_progress_result <stderr >actual && + test_cmp expect actual +' + +test_expect_success 'blame progress on a single range' ' + cat >expect <<-\EOF && + Blaming lines: 100% (4/4), done. + EOF + + GIT_PROGRESS_DELAY=0 \ + git blame --progress -L 3,6 hello.c 2>stderr && + + get_progress_result <stderr >actual && + test_cmp expect actual +' + +test_expect_success 'blame progress on multiple ranges' ' + cat >expect <<-\EOF && + Blaming lines: 100% (7/7), done. + EOF + + GIT_PROGRESS_DELAY=0 \ + git blame --progress -L 3,6 -L 8,10 hello.c 2>stderr && + + get_progress_result <stderr >actual && + test_cmp expect actual +' |