File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,20 @@ check_patch_format () {
191191 esac
192192 ;;
193193 esac
194+ if test -z " $patch_format " &&
195+ test -n " $l1 " &&
196+ test -n " $l2 " &&
197+ test -n " $l3 "
198+ then
199+ # This begins with three non-empty lines. Is this a
200+ # piece of e-mail a-la RFC2822? Grab all the headers,
201+ # discarding the indented remainder of folded lines,
202+ # and see if it looks like that they all begin with the
203+ # header field names...
204+ sed -n -e ' /^$/q' -e ' /^[ ]/d' -e p " $1 " |
205+ egrep -v ' ^[A-Za-z]+(-[A-Za-z]+)*:' > /dev/null ||
206+ patch_format=mbox
207+ fi
194208 } < " $1 " || clean_abort
195209}
196210
@@ -254,7 +268,11 @@ split_patches () {
254268 msgnum=
255269 ;;
256270 * )
257- clean_abort " Patch format $patch_format is not supported."
271+ if test -n " $parse_patch " ; then
272+ clean_abort " Patch format $patch_format is not supported."
273+ else
274+ clean_abort " Patch format detection failed."
275+ fi
258276 ;;
259277 esac
260278}
Original file line number Diff line number Diff line change @@ -77,6 +77,12 @@ test_expect_success setup '
7777 git commit -s -F msg &&
7878 git tag second &&
7979 git format-patch --stdout first >patch1 &&
80+ {
81+ echo "X-Fake-Field: Line One" &&
82+ echo "X-Fake-Field: Line Two" &&
83+ echo "X-Fake-Field: Line Three" &&
84+ git format-patch --stdout first | sed -e "1d"
85+ } > patch1.eml &&
8086 sed -n -e "3,\$p" msg >file &&
8187 git add file &&
8288 test_tick &&
@@ -108,6 +114,15 @@ test_expect_success 'am applies patch correctly' '
108114 test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
109115'
110116
117+ test_expect_success ' am applies patch e-mail not in a mbox' '
118+ git checkout first &&
119+ git am patch1.eml &&
120+ ! test -d .git/rebase-apply &&
121+ test -z "$(git diff second)" &&
122+ test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
123+ test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
124+ '
125+
111126GIT_AUTHOR_NAME=" Another Thor"
112127GIT_AUTHOR_EMAIL=
" [email protected] " 113128GIT_COMMITTER_NAME=" Co M Miter"
You can’t perform that action at this time.
0 commit comments