summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--strbuf.c3
-rwxr-xr-xt/t0030-stripspace.sh6
2 files changed, 8 insertions, 1 deletions
diff --git a/strbuf.c b/strbuf.c
index 0346e74a47..88cafd4a70 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -229,7 +229,8 @@ static void add_lines(struct strbuf *out,
const char *next = memchr(buf, '\n', size);
next = next ? (next + 1) : (buf + size);
- prefix = (prefix2 && buf[0] == '\n') ? prefix2 : prefix1;
+ prefix = ((prefix2 && (buf[0] == '\n' || buf[0] == '\t'))
+ ? prefix2 : prefix1);
strbuf_addstr(out, prefix);
strbuf_add(out, buf, next - buf);
size -= next - buf;
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