From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Lea Wiemann <lewiemann@gmail.com>, git@vger.kernel.org
Subject: [PATCH 3/4] avoid trailing whitespace in zero-change diffstat lines
Date: Sat, 14 Jun 2008 02:56:14 -0400 [thread overview]
Message-ID: <20080614065614.GC9006@sigill.intra.peff.net> (raw)
In-Reply-To: <20080614064857.GA8930@sigill.intra.peff.net>
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>
---
I can't imagine any programs actually depend on the trailing space, but
the output change does make this the only contentious patch.
diff.c | 3 ++-
t/t4016-diff-quote.sh | 14 +++++++-------
2 files changed, 9 insertions(+), 8 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");
diff --git a/t/t4016-diff-quote.sh b/t/t4016-diff-quote.sh
index 0950250..f07035a 100755
--- a/t/t4016-diff-quote.sh
+++ b/t/t4016-diff-quote.sh
@@ -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' '
--
1.5.6.rc2.183.g04614
next prev parent reply other threads:[~2008-06-14 6:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-12 22:35 [PATCH] t/.gitattributes: only ignore whitespace errors in test files Lea Wiemann
2008-06-13 6:06 ` Jeff King
2008-06-13 7:49 ` [PATCH v2] " Lea Wiemann
2008-06-13 10:00 ` [PATCH] " Junio C Hamano
2008-06-14 6:48 ` Jeff King
2008-06-14 6:51 ` [PATCH 1/4] fix whitespace violations in test scripts Jeff King
2008-06-14 7:01 ` Jeff King
2008-06-14 7:20 ` Junio C Hamano
2008-06-14 7:22 ` Jeff King
2008-06-14 7:25 ` [PATCH v2 1/5] " Jeff King
2008-06-14 7:26 ` [PATCH v2 2/5] mask necessary whitespace policy " Jeff King
2008-06-14 7:27 ` [PATCH v2 3/5] avoid whitespace on empty line in automatic usage message Jeff King
2008-06-14 7:27 ` [PATCH v2 4/5] avoid trailing whitespace in zero-change diffstat lines Jeff King
2008-06-14 7:28 ` [PATCH v2 5/5] enable whitespace checking of test scripts Jeff King
2008-06-14 6:54 ` [PATCH 2/4] mask necessary whitespace policy violations in " Jeff King
2008-06-14 6:56 ` Jeff King [this message]
2008-06-14 7:22 ` [PATCH 3/4] avoid trailing whitespace in zero-change diffstat lines Junio C Hamano
2008-06-14 7:30 ` Jeff King
2008-06-14 6:56 ` [PATCH 4/4] enable whitespace checking of test scripts Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080614065614.GC9006@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=lewiemann@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).