Merge branch 'ja/doc-synopsis-markup'
[git/gitster.git] / t / t4153-am-resume-override-opts.sh
blobdd6ad8f7a80d9627ee9a6dde5534a0db2f01c64a
1 #!/bin/sh
3 test_description='git-am command-line options override saved options'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 format_patch () {
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 &&
17 git mv file file2 &&
18 test_tick &&
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 &&
26 format_patch side1 &&
27 format_patch side2
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 &&
37 git reset --hard &&
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 &&
55 git reset --hard &&
56 git checkout first &&
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 &&
62 echo side1 >file &&
63 git add file &&
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 &&
69 test_cmp expected out
72 test_expect_success '--signoff overrides --no-signoff' '
73 rm -fr .git/rebase-apply &&
74 git reset --hard &&
75 git checkout first &&
77 test_must_fail git am --no-signoff side[12].eml &&
78 test_path_is_dir .git/rebase-apply &&
79 echo side1 >file &&
80 git add file &&
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 &&
94 git reset --hard &&
95 git checkout first &&
96 rm -f file.rej &&
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 &&
103 test_path_is_dir .git/rebase-apply &&
104 test_path_is_file file.rej
107 test_done