interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t3504-cherry-pick-rerere.sh

106 lines · 3306 bytes Raw Blame History
1#!/bin/sh
2
3test_description='cherry-pick should rerere for conflicts'
4
5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8. ./test-lib.sh
9
10test_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
21test_expect_success 'conflicting merge' '
22 test_must_fail git merge main
23'
24
25test_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
34test_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
45test_expect_success 'cherry-pick conflict respects 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
57test_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
71test_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
84test_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
98test_expect_success 'cherry-pick conflict without rerere' '
99 test_config rerere.enabled false &&
100 test_must_fail git cherry-pick foo-main &&
101 test_grep ===== foo &&
102 test_grep foo-dev foo &&
103 test_grep foo-main foo
104'
105
106test_done