1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-31 22:37:54 +01:00

Merge branch 'ns/am-raw-email'

* ns/am-raw-email:
  git-am: print fair error message when format detection fails
  am: allow individual e-mail files as input
This commit is contained in:
Junio C Hamano 2009-08-10 22:16:42 -07:00
commit 38a9f35d1f
2 changed files with 34 additions and 1 deletions

View file

@ -191,6 +191,20 @@ check_patch_format () {
esac
;;
esac
if test -z "$patch_format" &&
test -n "$l1" &&
test -n "$l2" &&
test -n "$l3"
then
# This begins with three non-empty lines. Is this a
# piece of e-mail a-la RFC2822? Grab all the headers,
# discarding the indented remainder of folded lines,
# and see if it looks like that they all begin with the
# header field names...
sed -n -e '/^$/q' -e '/^[ ]/d' -e p "$1" |
egrep -v '^[A-Za-z]+(-[A-Za-z]+)*:' >/dev/null ||
patch_format=mbox
fi
} < "$1" || clean_abort
}
@ -254,7 +268,11 @@ split_patches () {
msgnum=
;;
*)
clean_abort "Patch format $patch_format is not supported."
if test -n "$parse_patch" ; then
clean_abort "Patch format $patch_format is not supported."
else
clean_abort "Patch format detection failed."
fi
;;
esac
}

View file

@ -77,6 +77,12 @@ test_expect_success setup '
git commit -s -F msg &&
git tag second &&
git format-patch --stdout first >patch1 &&
{
echo "X-Fake-Field: Line One" &&
echo "X-Fake-Field: Line Two" &&
echo "X-Fake-Field: Line Three" &&
git format-patch --stdout first | sed -e "1d"
} > patch1.eml &&
sed -n -e "3,\$p" msg >file &&
git add file &&
test_tick &&
@ -108,6 +114,15 @@ test_expect_success 'am applies patch correctly' '
test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
'
test_expect_success 'am applies patch e-mail not in a mbox' '
git checkout first &&
git am patch1.eml &&
! test -d .git/rebase-apply &&
test -z "$(git diff second)" &&
test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
'
GIT_AUTHOR_NAME="Another Thor"
GIT_AUTHOR_EMAIL="a.thor@example.com"
GIT_COMMITTER_NAME="Co M Miter"