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