summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2008-06-14 07:27:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-06-14 18:39:16 (GMT)
commit4d9b53591f64a11da0af4c2b8f11fd4730ce52dd (patch)
tree87ba9bcc306a62256c573ed0a61ab5c5fc54dcf0 /diff.c
parent44d86e910d61dab4f059d86705599bbb2747b10f (diff)
downloadgit-4d9b53591f64a11da0af4c2b8f11fd4730ce52dd.zip
git-4d9b53591f64a11da0af4c2b8f11fd4730ce52dd.tar.gz
git-4d9b53591f64a11da0af4c2b8f11fd4730ce52dd.tar.bz2
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>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index 62fdc54..f77f9e9 100644
--- a/diff.c
+++ b/diff.c
@@ -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");