diff options
author | Edmundo Carmona Antoranz <eantoranz@gmail.com> | 2022-04-06 20:13:20 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-04-06 22:29:59 +0200 |
commit | e5f5d7d42effb1d0d404897ac782783f742e9daa (patch) | |
tree | f6c7fe3f53ac77de4a59ff5872c5cca5e7bd3a3e /builtin/blame.c | |
parent | Git 2.35.1 (diff) | |
download | git-e5f5d7d42effb1d0d404897ac782783f742e9daa.tar.xz git-e5f5d7d42effb1d0d404897ac782783f742e9daa.zip |
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 'builtin/blame.c')
-rw-r--r-- | builtin/blame.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/builtin/blame.c b/builtin/blame.c index 7fafeac408..832478e88c 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -897,6 +897,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix) unsigned int range_i; long anchor; const int hexsz = the_hash_algo->hexsz; + long num_lines = 0; setup_default_color_by_age(); git_config(git_blame_config, &output_option); @@ -1127,7 +1128,10 @@ parse_done: for (range_i = ranges.nr; range_i > 0; --range_i) { const struct range *r = &ranges.ranges[range_i - 1]; ent = blame_entry_prepend(ent, r->start, r->end, o); + num_lines += (r->end - r->start); } + if (!num_lines) + num_lines = sb.num_lines; o->suspects = ent; prio_queue_put(&sb.commits, o->commit); @@ -1156,7 +1160,7 @@ parse_done: sb.found_guilty_entry = &found_guilty_entry; sb.found_guilty_entry_data = π if (show_progress) - pi.progress = start_delayed_progress(_("Blaming lines"), sb.num_lines); + pi.progress = start_delayed_progress(_("Blaming lines"), num_lines); assign_blame(&sb, opt); |