avoid trailing whitespace in zero-change diffstat lines
In some cases, we produce a diffstat line even though no lines have changed (e.g., because of an exact rename). In this case, there is no +/- "graph" after the number of changed lines. However, we output the space separator unconditionally, meaning that these lines contained a trailing space character. This isn't a huge problem, but in cleaning up the output we are able to eliminate some trailing whitespace from a test vector. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jun 14, 2008 at 03:27 UTC
4d9b53591f64a11da0af4c2b8f11fd4730ce52dd
2 files changed
+9
-8
diff.c
+2
-1
@@ -922,7 +922,8 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)
922
total = add + del;
923
}
924
show_name(options->file, prefix, name, len, reset, set);
925
- fprintf(options->file, "%5d ", added + deleted);
925
+ fprintf(options->file, "%5d%s", added + deleted,
926
+ added + deleted ? " " : "");
927
show_graph(options->file, '+', add, add_c, reset);
928
show_graph(options->file, '-', del, del_c, reset);
929
fprintf(options->file, "\n");
t/t4016-diff-quote.sh
+7
-7
@@ -53,13 +53,13 @@ test_expect_success 'git diff --summary -M HEAD' '
53
'
54
55
cat >expect <<\EOF
56
- pathname.1 => "Rpathname\twith HT.0" | 0
57
- pathname.3 => "Rpathname\nwith LF.0" | 0
58
- "pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0
59
- pathname.2 => Rpathname with SP.0 | 0
60
- "pathname\twith HT.2" => Rpathname with SP.1 | 0
61
- pathname.0 => Rpathname.0 | 0
62
- "pathname\twith HT.0" => Rpathname.1 | 0
56
+ pathname.1 => "Rpathname\twith HT.0" | 0
57
+ pathname.3 => "Rpathname\nwith LF.0" | 0
58
+ "pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0
59
+ pathname.2 => Rpathname with SP.0 | 0
60
+ "pathname\twith HT.2" => Rpathname with SP.1 | 0
61
+ pathname.0 => Rpathname.0 | 0
62
+ "pathname\twith HT.0" => Rpathname.1 | 0
63
7 files changed, 0 insertions(+), 0 deletions(-)
64
EOF
65
test_expect_success 'git diff --stat -M HEAD' '