mailinfo: with -b, keep space after [foo]
The logic for the -b mode, where [PATCH] is dropped but [foo] is not, silently ate all spaces after the ]. Fix this by keeping the next isspace() character, if there is any. Being more thorough is pointless, as the later cleanup_space() call will normalize any sequence of whitespace to a single ' '. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Thomas Rast committed
Jan 16, 2012 at 11:53 UTC
ee2d1cb402a7ccda0028b221f2252801b3cb7eef
2 files changed
+11
-2
builtin/mailinfo.c
+10
-1
@@ -250,8 +250,17 @@ static void cleanup_subject(struct strbuf *subject)
250
(7 <= remove &&
251
memmem(subject->buf + at, remove, "PATCH", 5)))
252
strbuf_remove(subject, at, remove);
253
- else
253
+ else {
254
at += remove;
255
+ /*
256
+ * If the input had a space after the ], keep
257
+ * it. We don't bother with finding the end of
258
+ * the space, since we later normalize it
259
+ * anyway.
260
+ */
261
+ if (isspace(subject->buf[at]))
262
+ at += 1;
263
+ }
264
continue;
265
}
266
break;
t/t4150-am.sh
+1
-1
@@ -244,7 +244,7 @@ test_expect_success 'am --keep really keeps the subject' '
244
grep "Re: Re: Re: \[PATCH 1/5 v2\] \[foo\] third" actual
245
'
246
247
-test_expect_failure 'am --keep-non-patch really keeps the non-patch part' '
247
+test_expect_success 'am --keep-non-patch really keeps the non-patch part' '
248
rm -fr .git/rebase-apply &&
249
git reset --hard &&
250
git checkout HEAD^ &&