diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-08-18 22:07:57 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-08-18 22:07:57 -0700 |
commit | beace29a0437068a36bc5963d905fac482724196 (patch) | |
tree | ab6c9dbb2e883e33e513b762cb1e9850b206b7f8 | |
parent | d8308c79fc2cae2d1891f92b9e0f9ec0361fe7df (diff) | |
parent | 0e8341f29d6541f661cc52f27f96877c0fd469c2 (diff) | |
download | git-beace29a0437068a36bc5963d905fac482724196.tar.gz |
Merge branch 'db/am-skip-blank-at-the-beginning'
* db/am-skip-blank-at-the-beginning:
am: ignore leading whitespace before patch
-rwxr-xr-x | git-am.sh | 11 | ||||
-rwxr-xr-x | t/t4150-am.sh | 18 |
2 files changed, 26 insertions, 3 deletions
@@ -197,10 +197,15 @@ check_patch_format () { return 0 fi - # otherwise, check the first few lines of the first patch to try - # to detect its format + # otherwise, check the first few non-blank lines of the first + # patch to try to detect its format { - read l1 + # Start from first line containing non-whitespace + l1= + while test -z "$l1" + do + read l1 + done read l2 read l3 case "$l1" in diff --git a/t/t4150-am.sh b/t/t4150-am.sh index 151404e090..d7d9ccc1c8 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -96,6 +96,13 @@ test_expect_success setup ' echo "X-Fake-Field: Line Three" && git format-patch --stdout first | sed -e "1d" } | append_cr >patch1-crlf.eml && + { + printf "%255s\\n" "" + 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-ws.eml && sed -n -e "3,\$p" msg >file && git add file && @@ -167,6 +174,17 @@ test_expect_success 'am applies patch e-mail not in a mbox with CRLF' ' test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)" ' +test_expect_success 'am applies patch e-mail with preceding whitespace' ' + rm -fr .git/rebase-apply && + git reset --hard && + git checkout first && + git am patch1-ws.eml && + ! test -d .git/rebase-apply && + git diff --exit-code second && + test "$(git rev-parse second)" = "$(git rev-parse HEAD)" && + test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)" +' + test_expect_success 'setup: new author and committer' ' GIT_AUTHOR_NAME="Another Thor" && GIT_AUTHOR_EMAIL="a.thor@example.com" && |