]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3504-cherry-pick-rerere.sh
The second batch
[thirdparty/git.git] / t / t3504-cherry-pick-rerere.sh
CommitLineData
aa1a0111
AMS
1#!/bin/sh
2
3test_description='cherry-pick should rerere for conflicts'
4
cbc75a12 5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
aa1a0111
AMS
8. ./test-lib.sh
9
10test_expect_success setup '
6f0e577e 11 test_commit foo &&
cbc75a12
JS
12 test_commit foo-main foo &&
13 test_commit bar-main bar &&
6f0e577e
PW
14
15 git checkout -b dev foo &&
16 test_commit foo-dev foo &&
8d8cb4b0 17 test_commit bar-dev bar &&
aa1a0111
AMS
18 git config rerere.enabled true
19'
20
21test_expect_success 'conflicting merge' '
cbc75a12 22 test_must_fail git merge main
aa1a0111
AMS
23'
24
25test_expect_success 'fixup' '
6f0e577e 26 echo foo-resolved >foo &&
8d8cb4b0 27 echo bar-resolved >bar &&
6f0e577e 28 git commit -am resolved &&
8d8cb4b0
PW
29 cp foo foo-expect &&
30 cp bar bar-expect &&
6f0e577e 31 git reset --hard HEAD^
aa1a0111
AMS
32'
33
8d8cb4b0 34test_expect_success 'cherry-pick conflict with --rerere-autoupdate' '
cbc75a12 35 test_must_fail git cherry-pick --rerere-autoupdate foo..bar-main &&
8d8cb4b0
PW
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
45test_expect_success 'cherry-pick conflict repsects rerere.autoUpdate' '
46 test_config rerere.autoUpdate true &&
cbc75a12 47 test_must_fail git cherry-pick foo..bar-main &&
8d8cb4b0
PW
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
57test_expect_success 'cherry-pick conflict with --no-rerere-autoupdate' '
58 test_config rerere.autoUpdate true &&
cbc75a12 59 test_must_fail git cherry-pick --no-rerere-autoupdate foo..bar-main &&
8d8cb4b0
PW
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
aa1a0111
AMS
69'
70
f826fb79 71test_expect_success 'cherry-pick --continue rejects --rerere-autoupdate' '
cbc75a12 72 test_must_fail git cherry-pick --rerere-autoupdate foo..bar-main &&
f826fb79
PW
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 &&
1108cea7 77 test_cmp expect actual &&
f826fb79
PW
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 &&
1108cea7 80 test_cmp expect actual &&
f826fb79
PW
81 git cherry-pick --abort
82'
83
8d8cb4b0 84test_expect_success 'cherry-pick --rerere-autoupdate more than once' '
cbc75a12 85 test_must_fail git cherry-pick --rerere-autoupdate --rerere-autoupdate foo..bar-main &&
8d8cb4b0
PW
86 test_cmp foo-expect foo &&
87 git diff-files --quiet &&
88 git cherry-pick --abort &&
cbc75a12 89 test_must_fail git cherry-pick --rerere-autoupdate --no-rerere-autoupdate --rerere-autoupdate foo..bar-main &&
8d8cb4b0
PW
90 test_cmp foo-expect foo &&
91 git diff-files --quiet &&
92 git cherry-pick --abort &&
cbc75a12 93 test_must_fail git cherry-pick --rerere-autoupdate --no-rerere-autoupdate foo..bar-main &&
8d8cb4b0
PW
94 test_must_fail git diff-files --quiet &&
95 git cherry-pick --abort
aa1a0111
AMS
96'
97
98test_expect_success 'cherry-pick conflict without rerere' '
8d8cb4b0 99 test_config rerere.enabled false &&
cbc75a12 100 test_must_fail git cherry-pick foo-main &&
e8a1c686
JS
101 grep ===== foo &&
102 grep foo-dev foo &&
cbc75a12 103 grep foo-main foo
aa1a0111
AMS
104'
105
106test_done