summaryrefslogtreecommitdiff
path: root/t/t3502-cherry-pick-merge.sh
blob: 0ab52da902c8d602e9c4d64660aa4a7e8e35544f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/sh

test_description='cherry picking and reverting a merge

		b---c
	       /   /
	initial---a

'

. ./test-lib.sh

test_expect_success setup '

	>A &&
	>B &&
	git add A B &&
	git commit -m "Initial" &&
	git tag initial &&
	git branch side &&
	echo new line >A &&
	git commit -m "add line to A" A &&
	git tag a &&
	git checkout side &&
	echo new line >B &&
	git commit -m "add line to B" B &&
	git tag b &&
	git checkout master &&
	git merge side &&
	git tag c

'

test_expect_success 'cherry-pick a non-merge with -m should fail' '

	git reset --hard &&
	git checkout a^0 &&
	test_must_fail git cherry-pick -m 1 b &&
	git diff --exit-code a --

'

test_expect_success 'cherry pick a merge without -m should fail' '

	git reset --hard &&
	git checkout a^0 &&
	test_must_fail git cherry-pick c &&
	git diff --exit-code a --

'

test_expect_success 'cherry pick a merge (1)' '

	git reset --hard &&
	git checkout a^0 &&
	git cherry-pick -m 1 c &&
	git diff --exit-code c

'

test_expect_success 'cherry pick a merge (2)' '

	git reset --hard &&
	git checkout b^0 &&
	git cherry-pick -m 2 c &&
	git diff --exit-code c

'

test_expect_success 'cherry pick a merge relative to nonexistent parent should fail' '

	git reset --hard &&
	git checkout b^0 &&
	test_must_fail git cherry-pick -m 3 c

'

test_expect_success 'revert a non-merge with -m should fail' '

	git reset --hard &&
	git checkout c^0 &&
	test_must_fail git revert -m 1 b &&
	git diff --exit-code c

'

test_expect_success 'revert a merge without -m should fail' '

	git reset --hard &&
	git checkout c^0 &&
	test_must_fail git revert c &&
	git diff --exit-code c

'

test_expect_success 'revert a merge (1)' '

	git reset --hard &&
	git checkout c^0 &&
	git revert -m 1 c &&
	git diff --exit-code a --

'

test_expect_success 'revert a merge (2)' '

	git reset --hard &&
	git checkout c^0 &&
	git revert -m 2 c &&
	git diff --exit-code b --

'

test_expect_success 'revert a merge relative to nonexistent parent should fail' '

	git reset --hard &&
	git checkout c^0 &&
	test_must_fail git revert -m 3 c &&
	git diff --exit-code c

'

test_done