Skip to content

Commit ae3b2b0

Browse files
Eric Wonggitster
authored andcommitted
rebase: use mboxrd format to avoid split errors
The mboxrd format allows the use of embedded "From " lines in commit messages without being misinterpreted by mailsplit Reported-by: Florian Weimer <[email protected]> Signed-off-by: Eric Wong <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5a1f5c3 commit ae3b2b0

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

git-rebase--am.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ else
5353

5454
git format-patch -k --stdout --full-index --cherry-pick --right-only \
5555
--src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \
56+
--pretty=mboxrd \
5657
$git_format_patch_opt \
5758
"$revisions" ${restrict_revision+^$restrict_revision} \
5859
>"$GIT_DIR/rebased-patches"
@@ -83,6 +84,7 @@ else
8384
fi
8485

8586
git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
87+
--patch-format=mboxrd \
8688
$allow_rerere_autoupdate \
8789
${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
8890
ret=$?

t/t3400-rebase.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,26 @@ test_expect_success 'rebase commit with an ancient timestamp' '
255255
grep "author .* 34567 +0600$" actual
256256
'
257257

258+
test_expect_success 'rebase with "From " line in commit message' '
259+
git checkout -b preserve-from master~1 &&
260+
cat >From_.msg <<EOF &&
261+
Somebody embedded an mbox in a commit message
262+
263+
This is from so-and-so:
264+
265+
From a@b Mon Sep 17 00:00:00 2001
266+
From: John Doe <[email protected]>
267+
Date: Sat, 11 Nov 2017 00:00:00 +0000
268+
Subject: not this message
269+
270+
something
271+
EOF
272+
>From_ &&
273+
git add From_ &&
274+
git commit -F From_.msg &&
275+
git rebase master &&
276+
git log -1 --pretty=format:%B >out &&
277+
test_cmp From_.msg out
278+
'
279+
258280
test_done

0 commit comments

Comments
 (0)