cherry-pick: add tests for new --ff option
Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Mar 6, 2010 at 21:34 UTC
b5c1a28b4c7d7e1324fa3e88ae03801d4fe9f6bb
1 file changed
+98
t/t3506-cherry-pick-ff.sh
new
+98
@@ -0,0 +1,98 @@
1
+#!/bin/sh
2
+
3
+test_description='test cherry-picking with --ff option'
4
+
5
+. ./test-lib.sh
6
+
7
+test_expect_success setup '
8
+ echo first > file1 &&
9
+ git add file1 &&
10
+ test_tick &&
11
+ git commit -m "first" &&
12
+ git tag first &&
13
+
14
+ git checkout -b other &&
15
+ echo second >> file1 &&
16
+ git add file1 &&
17
+ test_tick &&
18
+ git commit -m "second" &&
19
+ git tag second
20
+'
21
+
22
+test_expect_success 'cherry-pick using --ff fast forwards' '
23
+ git checkout master &&
24
+ git reset --hard first &&
25
+ test_tick &&
26
+ git cherry-pick --ff second &&
27
+ test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify second)"
28
+'
29
+
30
+test_expect_success 'cherry-pick not using --ff does not fast forwards' '
31
+ git checkout master &&
32
+ git reset --hard first &&
33
+ test_tick &&
34
+ git cherry-pick second &&
35
+ test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify second)"
36
+'
37
+
38
+#
39
+# We setup the following graph:
40
+#
41
+# B---C
42
+# / /
43
+# first---A
44
+#
45
+# (This has been taken from t3502-cherry-pick-merge.sh)
46
+#
47
+test_expect_success 'merge setup' '
48
+ git checkout master &&
49
+ git reset --hard first &&
50
+ echo new line >A &&
51
+ git add A &&
52
+ test_tick &&
53
+ git commit -m "add line to A" A &&
54
+ git tag A &&
55
+ git checkout -b side first &&
56
+ echo new line >B &&
57
+ git add B &&
58
+ test_tick &&
59
+ git commit -m "add line to B" B &&
60
+ git tag B &&
61
+ git checkout master &&
62
+ git merge side &&
63
+ git tag C &&
64
+ git checkout -b new A
65
+'
66
+
67
+test_expect_success 'cherry-pick a non-merge with --ff and -m should fail' '
68
+ git reset --hard A -- &&
69
+ test_must_fail git cherry-pick --ff -m 1 B &&
70
+ git diff --exit-code A --
71
+'
72
+
73
+test_expect_success 'cherry pick a merge with --ff but without -m should fail' '
74
+ git reset --hard A -- &&
75
+ test_must_fail git cherry-pick --ff C &&
76
+ git diff --exit-code A --
77
+'
78
+
79
+test_expect_success 'cherry pick with --ff a merge (1)' '
80
+ git reset --hard A -- &&
81
+ git cherry-pick --ff -m 1 C &&
82
+ git diff --exit-code C &&
83
+ test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify C)"
84
+'
85
+
86
+test_expect_success 'cherry pick with --ff a merge (2)' '
87
+ git reset --hard B -- &&
88
+ git cherry-pick --ff -m 2 C &&
89
+ git diff --exit-code C &&
90
+ test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify C)"
91
+'
92
+
93
+test_expect_success 'cherry pick a merge relative to nonexistent parent with --ff should fail' '
94
+ git reset --hard B -- &&
95
+ test_must_fail git cherry-pick --ff -m 3 C
96
+'
97
+
98
+test_done