Merge branch 'fa/remote-svn'
[git/raj.git] / t / t3506-cherry-pick-ff.sh
blob51ca391e472441d2d503e721795d609bfaad1100
1 #!/bin/sh
3 test_description='test cherry-picking with --ff option'
5 . ./test-lib.sh
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 &&
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
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)"
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)"
39 # We setup the following graph:
41 # B---C
42 # / /
43 # first---A
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 &&
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
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 -- &&
100 git rm file1 &&
101 echo first >file2 &&
102 git add file2 &&
103 git commit --amend -m "file2" &&
104 git cherry-pick --ff first &&
105 test "$(git rev-parse --verify HEAD)" = "1df192cd8bc58a2b275d842cede4d221ad9000d1"
108 test_done