Skip to content

Commit

Permalink
Merge branch 'db/am-skip-blank-at-the-beginning'
Browse files Browse the repository at this point in the history
* db/am-skip-blank-at-the-beginning:
  am: ignore leading whitespace before patch
  • Loading branch information
Junio C Hamano committed Aug 19, 2011
2 parents d8308c7 + 0e8341f commit beace29
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
11 changes: 8 additions & 3 deletions git-am.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions t/t4150-am.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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" &&
Expand Down

0 comments on commit beace29

Please sign in to comment.