3 test_description
='git-am command-line options override saved options'
5 TEST_PASSES_SANITIZE_LEAK
=true
9 git format-patch
--stdout -1 "$1" >"$1".eml
12 test_expect_success
'setup' '
13 test_commit initial file &&
14 test_commit first file &&
16 git checkout initial &&
19 git commit -m renamed-file &&
20 git tag renamed-file &&
22 git checkout -b side initial &&
23 test_commit side1 file &&
24 test_commit side2 file &&
30 test_expect_success
'--retry fails without in-progress operation' '
31 test_must_fail git am --retry 2>err &&
32 test_grep "operation not in progress" err
35 test_expect_success
'--3way overrides --no-3way' '
36 rm -fr .git/rebase-apply &&
38 git checkout renamed-file &&
40 # Applying side1 will fail as the file has been renamed.
41 test_must_fail git am --no-3way side[12].eml &&
42 test_path_is_dir .git/rebase-apply &&
43 test_cmp_rev renamed-file HEAD &&
44 test -z "$(git ls-files -u)" &&
46 # Applying side1 with am --3way will succeed due to the threeway-merge.
47 # Applying side2 will fail as --3way does not apply to it.
48 test_must_fail git am --retry --3way &&
49 test_path_is_dir .git/rebase-apply &&
50 test side1 = "$(cat file2)"
53 test_expect_success
'--no-quiet overrides --quiet' '
54 rm -fr .git/rebase-apply &&
58 # Applying side1 will be quiet.
59 test_must_fail git am --quiet side[123].eml >out &&
60 test_path_is_dir .git/rebase-apply &&
61 test_grep ! "^Applying: " out &&
65 # Applying side1 will not be quiet.
66 # Applying side2 will be quiet.
67 git am --no-quiet --continue >out &&
68 echo "Applying: side1" >expected &&
72 test_expect_success
'--signoff overrides --no-signoff' '
73 rm -fr .git/rebase-apply &&
77 test_must_fail git am --no-signoff side[12].eml &&
78 test_path_is_dir .git/rebase-apply &&
81 git am --signoff --continue &&
83 # Applied side1 will be signed off
84 echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected &&
85 git cat-file commit HEAD^ | grep "Signed-off-by:" >actual &&
86 test_cmp expected actual &&
88 # Applied side2 will not be signed off
89 test $(git cat-file commit HEAD | grep -c "Signed-off-by:") -eq 0
92 test_expect_success
'--reject overrides --no-reject' '
93 rm -fr .git/rebase-apply &&
98 test_must_fail git am --no-reject side1.eml &&
99 test_path_is_dir .git/rebase-apply &&
100 test_path_is_missing file.rej &&
102 test_must_fail git am --retry --reject </dev/zero &&
103 test_path_is_dir .git/rebase-apply &&
104 test_path_is_file file.rej