3 test_description
='test cherry-picking with --ff option'
7 test_expect_success setup
'
11 git commit -m "first" &&
14 git checkout -b other &&
15 echo second >> file1 &&
18 git commit -m "second" &&
21 cp_ff sha1:1df192cd8bc58a2b275d842cede4d221ad9000d1
22 cp_ff sha256:e70d6b7fc064bddb516b8d512c9057094b96ce6ff08e12080acc4fe7f1d60a1d
26 test_expect_success
'cherry-pick using --ff fast forwards' '
27 git checkout master &&
28 git reset --hard first &&
30 git cherry-pick --ff second &&
31 test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify second)"
34 test_expect_success
'cherry-pick not using --ff does not fast forwards' '
35 git checkout master &&
36 git reset --hard first &&
38 git cherry-pick second &&
39 test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify second)"
43 # We setup the following graph:
49 # (This has been taken from t3502-cherry-pick-merge.sh)
51 test_expect_success
'merge setup' '
52 git checkout master &&
53 git reset --hard first &&
57 git commit -m "add line to A" A &&
59 git checkout -b side first &&
63 git commit -m "add line to B" B &&
65 git checkout master &&
71 test_expect_success
'cherry-pick explicit first parent of a non-merge with --ff' '
72 git reset --hard A -- &&
73 git cherry-pick --ff -m 1 B &&
74 git diff --exit-code C --
77 test_expect_success
'cherry pick a merge with --ff but without -m should fail' '
78 git reset --hard A -- &&
79 test_must_fail git cherry-pick --ff C &&
80 git diff --exit-code A --
83 test_expect_success
'cherry pick with --ff a merge (1)' '
84 git reset --hard A -- &&
85 git cherry-pick --ff -m 1 C &&
86 git diff --exit-code C &&
87 test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify C)"
90 test_expect_success
'cherry pick with --ff a merge (2)' '
91 git reset --hard B -- &&
92 git cherry-pick --ff -m 2 C &&
93 git diff --exit-code C &&
94 test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify C)"
97 test_expect_success
'cherry pick a merge relative to nonexistent parent with --ff should fail' '
98 git reset --hard B -- &&
99 test_must_fail git cherry-pick --ff -m 3 C
102 test_expect_success
'cherry pick a root commit with --ff' '
103 git reset --hard first -- &&
107 git commit --amend -m "file2" &&
108 git cherry-pick --ff first &&
109 test "$(git rev-parse --verify HEAD)" = "$(test_oid cp_ff)"
112 test_expect_success
'cherry-pick --ff on unborn branch' '
113 git checkout --orphan unborn &&
114 git rm --cached -r . &&
116 git cherry-pick --ff first &&
117 test_cmp_rev first HEAD