Skip to content

Commit 2936824

Browse files
committed
Merge branch 'ls/maint-mailinfo-no-inbody' into maint
* ls/maint-mailinfo-no-inbody: git am/mailinfo: Don't look at in-body headers when rebasing
2 parents 3c362d4 + d25e515 commit 2936824

16 files changed

+122
-5
lines changed

builtin-mailinfo.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static struct strbuf charset = STRBUF_INIT;
2626
static int patch_lines;
2727
static struct strbuf **p_hdr_data, **s_hdr_data;
2828
static int use_scissors;
29+
static int use_inbody_headers = 1;
2930

3031
#define MAX_HDR_PARSED 10
3132
#define MAX_BOUNDARIES 5
@@ -774,10 +775,17 @@ static int handle_commit_msg(struct strbuf *line)
774775
strbuf_ltrim(line);
775776
if (!line->len)
776777
return 0;
778+
}
779+
780+
if (use_inbody_headers && still_looking) {
777781
still_looking = check_header(line, s_hdr_data, 0);
778782
if (still_looking)
779783
return 0;
780-
}
784+
} else
785+
/* Only trim the first (blank) line of the commit message
786+
* when ignoring in-body headers.
787+
*/
788+
still_looking = 0;
781789

782790
/* normalize the log message to UTF-8. */
783791
if (metainfo_charset)
@@ -1033,6 +1041,8 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)
10331041
use_scissors = 1;
10341042
else if (!strcmp(argv[1], "--no-scissors"))
10351043
use_scissors = 0;
1044+
else if (!strcmp(argv[1], "--no-inbody-headers"))
1045+
use_inbody_headers = 0;
10361046
else
10371047
usage(mailinfo_usage);
10381048
argc--; argv++;

git-am.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ split_patches () {
289289
prec=4
290290
dotest="$GIT_DIR/rebase-apply"
291291
sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
292-
resolvemsg= resume= scissors=
292+
resolvemsg= resume= scissors= no_inbody_headers=
293293
git_apply_opt=
294294
committer_date_is_author_date=
295295
ignore_date=
@@ -322,7 +322,7 @@ do
322322
--abort)
323323
abort=t ;;
324324
--rebasing)
325-
rebasing=t threeway=t keep=t scissors=f ;;
325+
rebasing=t threeway=t keep=t scissors=f no_inbody_headers=t ;;
326326
-d|--dotest)
327327
die "-d option is no longer supported. Do not use."
328328
;;
@@ -448,6 +448,7 @@ else
448448
echo "$utf8" >"$dotest/utf8"
449449
echo "$keep" >"$dotest/keep"
450450
echo "$scissors" >"$dotest/scissors"
451+
echo "$no_inbody_headers" >"$dotest/no_inbody_headers"
451452
echo "$GIT_QUIET" >"$dotest/quiet"
452453
echo 1 >"$dotest/next"
453454
if test -n "$rebasing"
@@ -495,6 +496,12 @@ t)
495496
f)
496497
scissors=--no-scissors ;;
497498
esac
499+
if test "$(cat "$dotest/no_inbody_headers")" = t
500+
then
501+
no_inbody_headers=--no-inbody-headers
502+
else
503+
no_inbody_headers=
504+
fi
498505
if test "$(cat "$dotest/quiet")" = t
499506
then
500507
GIT_QUIET=t
@@ -549,7 +556,7 @@ do
549556
# by the user, or the user can tell us to do so by --resolved flag.
550557
case "$resume" in
551558
'')
552-
git mailinfo $keep $scissors $utf8 "$dotest/msg" "$dotest/patch" \
559+
git mailinfo $keep $no_inbody_headers $scissors $utf8 "$dotest/msg" "$dotest/patch" \
553560
<"$dotest/$msgnum" >"$dotest/info" ||
554561
stop_here $this
555562

t/t5100-mailinfo.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test_expect_success 'split sample box' \
1111
'git mailsplit -o. "$TEST_DIRECTORY"/t5100/sample.mbox >last &&
1212
last=`cat last` &&
1313
echo total is $last &&
14-
test `cat last` = 14'
14+
test `cat last` = 16'
1515

1616
check_mailinfo () {
1717
mail=$1 opt=$2
@@ -30,6 +30,10 @@ do
3030
if test -f "$TEST_DIRECTORY"/t5100/msg$mail--scissors
3131
then
3232
check_mailinfo $mail --scissors
33+
fi &&
34+
if test -f "$TEST_DIRECTORY"/t5100/msg$mail--no-inbody-headers
35+
then
36+
check_mailinfo $mail --no-inbody-headers
3337
fi
3438
'
3539
done

t/t5100/info0015

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Author:
2+
Email:
3+
Subject: check bogus body header (from)
4+
Date: Fri, 9 Jun 2006 00:44:16 -0700
5+

t/t5100/info0015--no-inbody-headers

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Author: A U Thor
2+
3+
Subject: check bogus body header (from)
4+
Date: Fri, 9 Jun 2006 00:44:16 -0700
5+

t/t5100/info0016

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Author: A U Thor
2+
3+
Subject: check bogus body header (date)
4+
Date: bogus
5+

t/t5100/info0016--no-inbody-headers

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Author: A U Thor
2+
3+
Subject: check bogus body header (date)
4+
Date: Fri, 9 Jun 2006 00:44:16 -0700
5+

t/t5100/msg0015

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- a list
2+
- of stuff

t/t5100/msg0015--no-inbody-headers

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
From: bogosity
2+
- a list
3+
- of stuff

t/t5100/msg0016

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
and some content
2+

0 commit comments

Comments
 (0)