]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3504-cherry-pick-rerere.sh
The third batch
[thirdparty/git.git] / t / t3504-cherry-pick-rerere.sh
1 #!/bin/sh
2
3 test_description='cherry-pick should rerere for conflicts'
4
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8 . ./test-lib.sh
9
10 test_expect_success setup '
11 test_commit foo &&
12 test_commit foo-main foo &&
13 test_commit bar-main bar &&
14
15 git checkout -b dev foo &&
16 test_commit foo-dev foo &&
17 test_commit bar-dev bar &&
18 git config rerere.enabled true
19 '
20
21 test_expect_success 'conflicting merge' '
22 test_must_fail git merge main
23 '
24
25 test_expect_success 'fixup' '
26 echo foo-resolved >foo &&
27 echo bar-resolved >bar &&
28 git commit -am resolved &&
29 cp foo foo-expect &&
30 cp bar bar-expect &&
31 git reset --hard HEAD^
32 '
33
34 test_expect_success 'cherry-pick conflict with --rerere-autoupdate' '
35 test_must_fail git cherry-pick --rerere-autoupdate foo..bar-main &&
36 test_cmp foo-expect foo &&
37 git diff-files --quiet &&
38 test_must_fail git cherry-pick --continue &&
39 test_cmp bar-expect bar &&
40 git diff-files --quiet &&
41 git cherry-pick --continue &&
42 git reset --hard bar-dev
43 '
44
45 test_expect_success 'cherry-pick conflict repsects rerere.autoUpdate' '
46 test_config rerere.autoUpdate true &&
47 test_must_fail git cherry-pick foo..bar-main &&
48 test_cmp foo-expect foo &&
49 git diff-files --quiet &&
50 test_must_fail git cherry-pick --continue &&
51 test_cmp bar-expect bar &&
52 git diff-files --quiet &&
53 git cherry-pick --continue &&
54 git reset --hard bar-dev
55 '
56
57 test_expect_success 'cherry-pick conflict with --no-rerere-autoupdate' '
58 test_config rerere.autoUpdate true &&
59 test_must_fail git cherry-pick --no-rerere-autoupdate foo..bar-main &&
60 test_cmp foo-expect foo &&
61 test_must_fail git diff-files --quiet &&
62 git add foo &&
63 test_must_fail git cherry-pick --continue &&
64 test_cmp bar-expect bar &&
65 test_must_fail git diff-files --quiet &&
66 git add bar &&
67 git cherry-pick --continue &&
68 git reset --hard bar-dev
69 '
70
71 test_expect_success 'cherry-pick --continue rejects --rerere-autoupdate' '
72 test_must_fail git cherry-pick --rerere-autoupdate foo..bar-main &&
73 test_cmp foo-expect foo &&
74 git diff-files --quiet &&
75 test_must_fail git cherry-pick --continue --rerere-autoupdate >actual 2>&1 &&
76 echo "fatal: cherry-pick: --rerere-autoupdate cannot be used with --continue" >expect &&
77 test_cmp expect actual &&
78 test_must_fail git cherry-pick --continue --no-rerere-autoupdate >actual 2>&1 &&
79 echo "fatal: cherry-pick: --no-rerere-autoupdate cannot be used with --continue" >expect &&
80 test_cmp expect actual &&
81 git cherry-pick --abort
82 '
83
84 test_expect_success 'cherry-pick --rerere-autoupdate more than once' '
85 test_must_fail git cherry-pick --rerere-autoupdate --rerere-autoupdate foo..bar-main &&
86 test_cmp foo-expect foo &&
87 git diff-files --quiet &&
88 git cherry-pick --abort &&
89 test_must_fail git cherry-pick --rerere-autoupdate --no-rerere-autoupdate --rerere-autoupdate foo..bar-main &&
90 test_cmp foo-expect foo &&
91 git diff-files --quiet &&
92 git cherry-pick --abort &&
93 test_must_fail git cherry-pick --rerere-autoupdate --no-rerere-autoupdate foo..bar-main &&
94 test_must_fail git diff-files --quiet &&
95 git cherry-pick --abort
96 '
97
98 test_expect_success 'cherry-pick conflict without rerere' '
99 test_config rerere.enabled false &&
100 test_must_fail git cherry-pick foo-main &&
101 grep ===== foo &&
102 grep foo-dev foo &&
103 grep foo-main foo
104 '
105
106 test_done