Skip to content

Commit ee2d1cb

Browse files
trastgitster
authored andcommitted
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>
1 parent f7e5ea1 commit ee2d1cb

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

builtin/mailinfo.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,17 @@ static void cleanup_subject(struct strbuf *subject)
250250
(7 <= remove &&
251251
memmem(subject->buf + at, remove, "PATCH", 5)))
252252
strbuf_remove(subject, at, remove);
253-
else
253+
else {
254254
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+
}
255264
continue;
256265
}
257266
break;

t/t4150-am.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ test_expect_success 'am --keep really keeps the subject' '
244244
grep "Re: Re: Re: \[PATCH 1/5 v2\] \[foo\] third" actual
245245
'
246246

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' '
248248
rm -fr .git/rebase-apply &&
249249
git reset --hard &&
250250
git checkout HEAD^ &&

0 commit comments

Comments
 (0)