Skip to content

Commit bff64a9

Browse files
committed
Merge branch 'tr/maint-mailinfo'
* tr/maint-mailinfo: mailinfo: with -b, keep space after [foo] am: learn passing -b to mailinfo Conflicts: git-am.sh
2 parents 1082fb2 + ee2d1cb commit bff64a9

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

Documentation/git-am.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ OPTIONS
4040
--keep::
4141
Pass `-k` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
4242

43+
--keep-non-patch::
44+
Pass `-b` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
45+
4346
--keep-cr::
4447
--no-keep-cr::
4548
With `--keep-cr`, call 'git mailsplit' (see linkgit:git-mailsplit[1])

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;

git-am.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ q,quiet be quiet
1515
s,signoff add a Signed-off-by line to the commit message
1616
u,utf8 recode into utf8 (default)
1717
k,keep pass -k flag to git-mailinfo
18+
keep-non-patch pass -b flag to git-mailinfo
1819
keep-cr pass --keep-cr flag to git-mailsplit for mbox format
1920
no-keep-cr do not pass --keep-cr flag to git-mailsplit independent of am.keepcr
2021
c,scissors strip everything before a scissors line
@@ -387,6 +388,8 @@ do
387388
utf8= ;;
388389
-k|--keep)
389390
keep=t ;;
391+
--keep-non-patch)
392+
keep=b ;;
390393
-c|--scissors)
391394
scissors=t ;;
392395
--no-scissors)
@@ -565,16 +568,25 @@ case "$resolved" in
565568
fi
566569
esac
567570

571+
# Now, decide what command line options we will give to the git
572+
# commands we invoke, based on the result of parsing command line
573+
# options and previous invocation state stored in $dotest/ files.
574+
568575
if test "$(cat "$dotest/utf8")" = t
569576
then
570577
utf8=-u
571578
else
572579
utf8=-n
573580
fi
574-
if test "$(cat "$dotest/keep")" = t
575-
then
576-
keep=-k
577-
fi
581+
keep=$(cat "$dotest/keep")
582+
case "$keep" in
583+
t)
584+
keep=-k ;;
585+
b)
586+
keep=-b ;;
587+
*)
588+
keep= ;;
589+
esac
578590
case "$(cat "$dotest/scissors")" in
579591
t)
580592
scissors=--scissors ;;

t/t4150-am.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ test_expect_success 'am stays in branch' '
237237

238238
test_expect_success 'am --signoff does not add Signed-off-by: line if already there' '
239239
git format-patch --stdout HEAD^ >patch3 &&
240-
sed -e "/^Subject/ s,\[PATCH,Re: Re: Re: & 1/5 v2," patch3 >patch4 &&
240+
sed -e "/^Subject/ s,\[PATCH,Re: Re: Re: & 1/5 v2] [foo," patch3 >patch4 &&
241241
rm -fr .git/rebase-apply &&
242242
git reset --hard &&
243243
git checkout HEAD^ &&
@@ -259,7 +259,17 @@ test_expect_success 'am --keep really keeps the subject' '
259259
git am --keep patch4 &&
260260
! test -d .git/rebase-apply &&
261261
git cat-file commit HEAD >actual &&
262-
grep "Re: Re: Re: \[PATCH 1/5 v2\] third" actual
262+
grep "Re: Re: Re: \[PATCH 1/5 v2\] \[foo\] third" actual
263+
'
264+
265+
test_expect_success 'am --keep-non-patch really keeps the non-patch part' '
266+
rm -fr .git/rebase-apply &&
267+
git reset --hard &&
268+
git checkout HEAD^ &&
269+
git am --keep-non-patch patch4 &&
270+
! test -d .git/rebase-apply &&
271+
git cat-file commit HEAD >actual &&
272+
grep "^\[foo\] third" actual
263273
'
264274

265275
test_expect_success 'am -3 falls back to 3-way merge' '

0 commit comments

Comments
 (0)