From: Thomas Rast <trast@student.ethz.ch>
To: <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 3/3] mailinfo: with -b, keep space after [foo]
Date: Wed, 11 Jan 2012 21:13:44 +0100 [thread overview]
Message-ID: <673657ccd5577ef5c2b6be2c7d0039218c31596d.1326312730.git.trast@student.ethz.ch> (raw)
In-Reply-To: <e915a551c9bbf12f4d8fd929e9ed24f3223790ee.1326312730.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>
---
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
prev parent reply other threads:[~2012-01-11 20:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-11 20:13 [PATCH 1/3] mailinfo documentation: accurately describe non -k case Thomas Rast
2012-01-11 20:13 ` [PATCH 2/3] am: learn passing -b to mailinfo Thomas Rast
2012-01-12 1:35 ` Junio C Hamano
2012-01-12 8:52 ` Thomas Rast
2012-01-16 10:53 ` [PATCH v2 1/2] " Thomas Rast
2012-01-16 10:53 ` [PATCH v2 2/2] mailinfo: with -b, keep space after [foo] Thomas Rast
2012-01-19 21:26 ` [PATCH v2 1/2] am: learn passing -b to mailinfo Junio C Hamano
2012-01-20 13:04 ` Thomas Rast
2012-01-11 20:13 ` Thomas Rast [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=673657ccd5577ef5c2b6be2c7d0039218c31596d.1326312730.git.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).