[PATCH v2 2/2] mailinfo: with -b, keep space after [foo]
- From
Thomas Rast <trast@student.ethz.ch>
- Date
- Jan 16, 2012, 10:53 UTC
- Message-ID
- <9d2d51087ec58150bdf0d25c4321dc6b7e75b192.1326710194.git.trast@student.ethz.ch>
- In-Reply-To
- <a804650f805fd8c89a843302cb92bbbdf36b8c0b.1326710194.git.trast@student.ethz.ch>
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> ---
Unchanged from last time.
builtin/mailinfo.c | 11 ++++++++++- t/t4150-am.sh | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index bfb32b7..eaf9e15 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 7e7c83c..8807b60 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -262,7 +262,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^ &&
-- 1.7.9.rc0.168.g3847c