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 () {
191
191
esac
192
192
;;
193
193
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
194
208
} < " $1 " || clean_abort
195
209
}
196
210
@@ -254,7 +268,11 @@ split_patches () {
254
268
msgnum=
255
269
;;
256
270
* )
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
258
276
;;
259
277
esac
260
278
}
Original file line number Diff line number Diff line change @@ -77,6 +77,12 @@ test_expect_success setup '
77
77
git commit -s -F msg &&
78
78
git tag second &&
79
79
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 &&
80
86
sed -n -e "3,\$p" msg >file &&
81
87
git add file &&
82
88
test_tick &&
@@ -108,6 +114,15 @@ test_expect_success 'am applies patch correctly' '
108
114
test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
109
115
'
110
116
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
+
111
126
GIT_AUTHOR_NAME=" Another Thor"
112
127
GIT_AUTHOR_EMAIL=
" [email protected] "
113
128
GIT_COMMITTER_NAME=" Co M Miter"
You can’t perform that action at this time.
0 commit comments