summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/mailinfo.c11
-rwxr-xr-xt/t4150-am.sh2
2 files changed, 11 insertions, 2 deletions
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index bfb32b7233..eaf9e157a3 100644
--- a/builtin/mailinfo.c
+++ b/builtin/mailinfo.c
@@ -250,8 +250,17 @@ static void cleanup_subject(struct strbuf *subject)
(7 <= remove &&
memmem(subject->buf + at, remove, "PATCH", 5)))
strbuf_remove(subject, at, remove);
- else
+ else {
at += remove;
+ /*
+ * If the input had a space after the ], keep
+ * it. We don't bother with finding the end of
+ * the space, since we later normalize it
+ * anyway.
+ */
+ if (isspace(subject->buf[at]))
+ at += 1;
+ }
continue;
}
break;
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index efcff3c51d..a087254f64 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -244,7 +244,7 @@ test_expect_success 'am --keep really keeps the subject' '
grep "Re: Re: Re: \[PATCH 1/5 v2\] \[foo\] third" actual
'
-test_expect_failure 'am --keep-non-patch really keeps the non-patch part' '
+test_expect_success 'am --keep-non-patch really keeps the non-patch part' '
rm -fr .git/rebase-apply &&
git reset --hard &&
git checkout HEAD^ &&