summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2014-10-27 14:13:15 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-10-27 14:13:59 -0700
commitd55aeb7687448189327ad058096b55431da5ea42 (patch)
treef49cf287c3a38b19db06547572a316ffd7fc923e /t
parentMerge branch 'maint-2.0' into maint (diff)
downloadtgif-d55aeb7687448189327ad058096b55431da5ea42.tar.xz
strbuf_add_commented_lines(): avoid SP-HT sequence in commented lines
The strbuf_add_commented_lines() function passes a pair of prefixes, one to be used for a non-empty line, and the other for an empty line, to underlying add_lines(). The former is set to a comment char followed by a SP, while the latter is set to just the comment char. This is designed to give a SP after the comment character, e.g. "# <user text>\n", on a line with some text, and to avoid emitting an unsightly "# \n" for an empty line. Teach this machinery to also use the latter space-less prefix when the payload line begins with a tab, to show e.g. "#\t<user text>\n"; otherwise we will end up showing "# \t<user text>\n" which is similarly unsightly. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t0030-stripspace.sh6
1 files changed, 6 insertions, 0 deletions
diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh
index 0333dd9875..29e91d861c 100755
--- a/t/t0030-stripspace.sh
+++ b/t/t0030-stripspace.sh
@@ -432,4 +432,10 @@ test_expect_success '-c with changed comment char' '
test_cmp expect actual
'
+test_expect_success 'avoid SP-HT sequence in commented line' '
+ printf "#\tone\n#\n# two\n" >expect &&
+ printf "\tone\n\ntwo\n" | git stripspace -c >actual &&
+ test_cmp expect actual
+'
+
test_done