1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-13 16:36:13 +02:00

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>
This commit is contained in:
Jeff King 2008-06-14 03:27:45 -04:00 committed by Junio C Hamano
parent 44d86e910d
commit 4d9b53591f
2 changed files with 9 additions and 8 deletions

3
diff.c
View File

@ -922,7 +922,8 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)
total = add + del;
}
show_name(options->file, prefix, name, len, reset, set);
fprintf(options->file, "%5d ", added + deleted);
fprintf(options->file, "%5d%s", added + deleted,
added + deleted ? " " : "");
show_graph(options->file, '+', add, add_c, reset);
show_graph(options->file, '-', del, del_c, reset);
fprintf(options->file, "\n");

View File

@ -53,13 +53,13 @@ test_expect_success 'git diff --summary -M HEAD' '
'
cat >expect <<\EOF
pathname.1 => "Rpathname\twith HT.0" | 0
pathname.3 => "Rpathname\nwith LF.0" | 0
"pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0
pathname.2 => Rpathname with SP.0 | 0
"pathname\twith HT.2" => Rpathname with SP.1 | 0
pathname.0 => Rpathname.0 | 0
"pathname\twith HT.0" => Rpathname.1 | 0
pathname.1 => "Rpathname\twith HT.0" | 0
pathname.3 => "Rpathname\nwith LF.0" | 0
"pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0
pathname.2 => Rpathname with SP.0 | 0
"pathname\twith HT.2" => Rpathname with SP.1 | 0
pathname.0 => Rpathname.0 | 0
"pathname\twith HT.0" => Rpathname.1 | 0
7 files changed, 0 insertions(+), 0 deletions(-)
EOF
test_expect_success 'git diff --stat -M HEAD' '