git-fetch.txt: document fetch output
[gitweb.git] / t / t4014-format-patch.sh
index edf07eefd4d7f5508547a835955adfdb8fb59373..805dc9012d5f765eb40a67e58c1572b1fe316bd6 100755 (executable)
@@ -549,7 +549,7 @@ test_expect_success 'cover-letter inherits diff options' '
 
        git mv file foo &&
        git commit -m foo &&
-       git format-patch --cover-letter -1 &&
+       git format-patch --no-renames --cover-letter -1 &&
        check_patch 0000-cover-letter.patch &&
        ! grep "file => foo .* 0 *\$" 0000-cover-letter.patch &&
        git format-patch --cover-letter -1 -M &&
@@ -703,7 +703,7 @@ test_expect_success 'options no longer allowed for format-patch' '
 
 test_expect_success 'format-patch --numstat should produce a patch' '
        git format-patch --numstat --stdout master..side > output &&
-       test 6 = $(grep "^diff --git a/" output | wc -l)'
+       test 5 = $(grep "^diff --git a/" output | wc -l)'
 
 test_expect_success 'format-patch -- <path>' '
        git format-patch master..side -- file 2>error &&
@@ -1072,7 +1072,7 @@ test_expect_success '--from omits redundant in-body header' '
 '
 
 test_expect_success 'in-body headers trigger content encoding' '
-       GIT_AUTHOR_NAME="éxötìc" test_commit exotic &&
+       test_env GIT_AUTHOR_NAME="éxötìc" test_commit exotic &&
        test_when_finished "git reset --hard HEAD^" &&
        git format-patch -1 --stdout --from >patch &&
        cat >expect <<-\EOF &&
@@ -1507,4 +1507,62 @@ test_expect_success 'format-patch --base errors out when base commit is not ance
        test_cmp expected actual
 '
 
+test_expect_success 'format-patch --base=auto' '
+       git checkout -b upstream master &&
+       git checkout -b local upstream &&
+       git branch --set-upstream-to=upstream &&
+       test_commit N1 &&
+       test_commit N2 &&
+       git format-patch --stdout --base=auto -2 >patch &&
+       grep "^base-commit:" patch >actual &&
+       echo "base-commit: $(git rev-parse upstream)" >expected &&
+       test_cmp expected actual
+'
+
+test_expect_success 'format-patch errors out when history involves criss-cross' '
+       # setup criss-cross history
+       #
+       #   B---M1---D
+       #  / \ /
+       # A   X
+       #  \ / \
+       #   C---M2---E
+       #
+       git checkout master &&
+       test_commit A &&
+       git checkout -b xb master &&
+       test_commit B &&
+       git checkout -b xc master &&
+       test_commit C &&
+       git checkout -b xbc xb -- &&
+       git merge xc &&
+       git checkout -b xcb xc -- &&
+       git branch --set-upstream-to=xbc &&
+       git merge xb &&
+       git checkout xbc &&
+       test_commit D &&
+       git checkout xcb &&
+       test_commit E &&
+       test_must_fail  git format-patch --base=auto -1
+'
+
+test_expect_success 'format-patch format.useAutoBaseoption' '
+       test_when_finished "git config --unset format.useAutoBase" &&
+       git checkout local &&
+       git config format.useAutoBase true &&
+       git format-patch --stdout -1 >patch &&
+       grep "^base-commit:" patch >actual &&
+       echo "base-commit: $(git rev-parse upstream)" >expected &&
+       test_cmp expected actual
+'
+
+test_expect_success 'format-patch --base overrides format.useAutoBase' '
+       test_when_finished "git config --unset format.useAutoBase" &&
+       git config format.useAutoBase true &&
+       git format-patch --stdout --base=HEAD~1 -1 >patch &&
+       grep "^base-commit:" patch >actual &&
+       echo "base-commit: $(git rev-parse HEAD~1)" >expected &&
+       test_cmp expected actual
+'
+
 test_done