]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3510-cherry-pick-sequence.sh
revert: Introduce --reset to remove sequencer state
[thirdparty/git.git] / t / t3510-cherry-pick-sequence.sh
1 #!/bin/sh
2
3 test_description='Test cherry-pick continuation features
4
5 + anotherpick: rewrites foo to d
6 + picked: rewrites foo to c
7 + unrelatedpick: rewrites unrelated to reallyunrelated
8 + base: rewrites foo to b
9 + initial: writes foo as a, unrelated as unrelated
10
11 '
12
13 . ./test-lib.sh
14
15 pristine_detach () {
16 git cherry-pick --reset &&
17 git checkout -f "$1^0" &&
18 git read-tree -u --reset HEAD &&
19 git clean -d -f -f -q -x
20 }
21
22 test_expect_success setup '
23 echo unrelated >unrelated &&
24 git add unrelated &&
25 test_commit initial foo a &&
26 test_commit base foo b &&
27 test_commit unrelatedpick unrelated reallyunrelated &&
28 test_commit picked foo c &&
29 test_commit anotherpick foo d &&
30 git config advice.detachedhead false
31
32 '
33
34 test_expect_success 'cherry-pick persists data on failure' '
35 pristine_detach initial &&
36 test_must_fail git cherry-pick -s base..anotherpick &&
37 test_path_is_dir .git/sequencer &&
38 test_path_is_file .git/sequencer/head &&
39 test_path_is_file .git/sequencer/todo &&
40 test_path_is_file .git/sequencer/opts
41 '
42
43 test_expect_success 'cherry-pick persists opts correctly' '
44 pristine_detach initial &&
45 test_must_fail git cherry-pick -s -m 1 --strategy=recursive -X patience -X ours base..anotherpick &&
46 test_path_is_dir .git/sequencer &&
47 test_path_is_file .git/sequencer/head &&
48 test_path_is_file .git/sequencer/todo &&
49 test_path_is_file .git/sequencer/opts &&
50 echo "true" >expect &&
51 git config --file=.git/sequencer/opts --get-all options.signoff >actual &&
52 test_cmp expect actual &&
53 echo "1" >expect &&
54 git config --file=.git/sequencer/opts --get-all options.mainline >actual &&
55 test_cmp expect actual &&
56 echo "recursive" >expect &&
57 git config --file=.git/sequencer/opts --get-all options.strategy >actual &&
58 test_cmp expect actual &&
59 cat >expect <<-\EOF &&
60 patience
61 ours
62 EOF
63 git config --file=.git/sequencer/opts --get-all options.strategy-option >actual &&
64 test_cmp expect actual
65 '
66
67 test_expect_success 'cherry-pick cleans up sequencer state upon success' '
68 pristine_detach initial &&
69 git cherry-pick initial..picked &&
70 test_path_is_missing .git/sequencer
71 '
72
73 test_expect_success '--reset does not complain when no cherry-pick is in progress' '
74 pristine_detach initial &&
75 git cherry-pick --reset
76 '
77
78 test_expect_success '--reset cleans up sequencer state' '
79 pristine_detach initial &&
80 test_must_fail git cherry-pick base..picked &&
81 git cherry-pick --reset &&
82 test_path_is_missing .git/sequencer
83 '
84
85 test_done