]>
Commit | Line | Data |
---|---|---|
852a1710 PT |
1 | #!/bin/sh |
2 | ||
3 | test_description='git-am command-line options override saved options' | |
4 | ||
5 | . ./test-lib.sh | |
6 | . "$TEST_DIRECTORY"/lib-terminal.sh | |
7 | ||
8 | format_patch () { | |
9 | git format-patch --stdout -1 "$1" >"$1".eml | |
10 | } | |
11 | ||
12 | test_expect_success 'setup' ' | |
13 | test_commit initial file && | |
14 | test_commit first file && | |
15 | ||
16 | git checkout initial && | |
17 | git mv file file2 && | |
18 | test_tick && | |
19 | git commit -m renamed-file && | |
20 | git tag renamed-file && | |
21 | ||
22 | git checkout -b side initial && | |
23 | test_commit side1 file && | |
24 | test_commit side2 file && | |
25 | ||
26 | format_patch side1 && | |
27 | format_patch side2 | |
28 | ' | |
29 | ||
30 | test_expect_success TTY '--3way overrides --no-3way' ' | |
31 | rm -fr .git/rebase-apply && | |
32 | git reset --hard && | |
33 | git checkout renamed-file && | |
34 | ||
35 | # Applying side1 will fail as the file has been renamed. | |
36 | test_must_fail git am --no-3way side[12].eml && | |
37 | test_path_is_dir .git/rebase-apply && | |
38 | test_cmp_rev renamed-file HEAD && | |
39 | test -z "$(git ls-files -u)" && | |
40 | ||
41 | # Applying side1 with am --3way will succeed due to the threeway-merge. | |
42 | # Applying side2 will fail as --3way does not apply to it. | |
43 | test_must_fail test_terminal git am --3way </dev/zero && | |
44 | test_path_is_dir .git/rebase-apply && | |
45 | test side1 = "$(cat file2)" | |
46 | ' | |
47 | ||
48 | test_expect_success '--no-quiet overrides --quiet' ' | |
49 | rm -fr .git/rebase-apply && | |
50 | git reset --hard && | |
51 | git checkout first && | |
52 | ||
53 | # Applying side1 will be quiet. | |
54 | test_must_fail git am --quiet side[123].eml >out && | |
55 | test_path_is_dir .git/rebase-apply && | |
de5ea4c6 | 56 | test_i18ngrep ! "^Applying: " out && |
852a1710 PT |
57 | echo side1 >file && |
58 | git add file && | |
59 | ||
60 | # Applying side1 will not be quiet. | |
61 | # Applying side2 will be quiet. | |
62 | git am --no-quiet --continue >out && | |
63 | echo "Applying: side1" >expected && | |
64 | test_i18ncmp expected out | |
65 | ' | |
66 | ||
b5e82359 PT |
67 | test_expect_success '--signoff overrides --no-signoff' ' |
68 | rm -fr .git/rebase-apply && | |
69 | git reset --hard && | |
70 | git checkout first && | |
71 | ||
72 | test_must_fail git am --no-signoff side[12].eml && | |
73 | test_path_is_dir .git/rebase-apply && | |
74 | echo side1 >file && | |
75 | git add file && | |
76 | git am --signoff --continue && | |
77 | ||
78 | # Applied side1 will be signed off | |
79 | echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected && | |
80 | git cat-file commit HEAD^ | grep "Signed-off-by:" >actual && | |
81 | test_cmp expected actual && | |
82 | ||
83 | # Applied side2 will not be signed off | |
84 | test $(git cat-file commit HEAD | grep -c "Signed-off-by:") -eq 0 | |
85 | ' | |
86 | ||
852a1710 PT |
87 | test_expect_success TTY '--reject overrides --no-reject' ' |
88 | rm -fr .git/rebase-apply && | |
89 | git reset --hard && | |
90 | git checkout first && | |
91 | rm -f file.rej && | |
92 | ||
93 | test_must_fail git am --no-reject side1.eml && | |
94 | test_path_is_dir .git/rebase-apply && | |
95 | test_path_is_missing file.rej && | |
96 | ||
97 | test_must_fail test_terminal git am --reject </dev/zero && | |
98 | test_path_is_dir .git/rebase-apply && | |
99 | test_path_is_file file.rej | |
100 | ' | |
101 | ||
102 | test_done |