summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4a2284b)
raw | patch | inline | side by side (parent: 4a2284b)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Sat, 13 Mar 2010 10:25:12 +0000 (11:25 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 13 Mar 2010 20:04:17 +0000 (12:04 -0800) |
Correct the calculation of the number of digits for line counts of the
form 10^n-1 (9, 99, ...) in lineno_width(). This makes blame stop
printing an extra space before the line numbers of files with that many
total lines.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
form 10^n-1 (9, 99, ...) in lineno_width(). This makes blame stop
printing an extra space before the line numbers of files with that many
total lines.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-blame.c | patch | blob | history | |
t/t8003-blame.sh | patch | blob | history |
diff --git a/builtin-blame.c b/builtin-blame.c
index 10f7eacf6e881cdb54a6b4a4c0aafc5f9751e5a9..fc1586350f94ae48e7e48a51818517b465e7a40d 100644 (file)
--- a/builtin-blame.c
+++ b/builtin-blame.c
{
int i, width;
- for (width = 1, i = 10; i <= lines + 1; width++)
+ for (width = 1, i = 10; i <= lines; width++)
i *= 10;
return width;
}
diff --git a/t/t8003-blame.sh b/t/t8003-blame.sh
index 3bbddd03cbfcf5cbdff6ed2987d68da9402ed993..230143cf318705fb01e61f10072a096e86186934 100755 (executable)
--- a/t/t8003-blame.sh
+++ b/t/t8003-blame.sh
echo B B B B B >two &&
echo C C C C C >tres &&
echo ABC >mouse &&
- git add one two tres mouse &&
+ for i in 1 2 3 4 5 6 7 8 9
+ do
+ echo $i
+ done >nine_lines &&
+ for i in 1 2 3 4 5 6 7 8 9 a
+ do
+ echo $i
+ done >ten_lines &&
+ git add one two tres mouse nine_lines ten_lines &&
test_tick &&
GIT_AUTHOR_NAME=Initial git commit -m Initial &&
grep "has only 2 lines" errors
'
+test_expect_success 'indent of line numbers, nine lines' '
+ git blame nine_lines >actual &&
+ test $(grep -c " " actual) = 0
+'
+
+test_expect_success 'indent of line numbers, ten lines' '
+ git blame ten_lines >actual &&
+ test $(grep -c " " actual) = 9
+'
+
test_done