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" &&
22 test_expect_success 'cherry-pick using --ff fast forwards' '
23 git checkout master &&
24 git reset --hard first &&
26 git cherry-pick --ff second &&
27 test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify second)"
30 test_expect_success 'cherry-pick not using --ff does not fast forwards' '
31 git checkout master &&
32 git reset --hard first &&
34 git cherry-pick second &&
35 test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify second)"
39 # We setup the following graph:
45 # (This has been taken from t3502-cherry-pick-merge.sh)
47 test_expect_success 'merge setup' '
48 git checkout master &&
49 git reset --hard first &&
53 git commit -m "add line to A" A &&
55 git checkout -b side first &&
59 git commit -m "add line to B" B &&
61 git checkout master &&
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 --
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 --
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)"
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)"
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
98 test_expect_success 'cherry pick a root commit with --ff' '
99 git reset --hard first -- &&
103 git commit --amend -m "file2" &&
104 git cherry-pick --ff first &&
105 test "$(git rev-parse --verify HEAD)" = "1df192cd8bc58a2b275d842cede4d221ad9000d1"