3 test_description
='test cherry-picking many commits'
7 test_expect_success setup
'
11 git commit -m "first" &&
14 git checkout -b other &&
15 for val in second third fourth
20 git commit -m "$val" &&
25 test_expect_success
'cherry-pick first..fourth works' '
26 git checkout -f master &&
27 git reset --hard first &&
29 git cherry-pick first..fourth &&
30 git diff --quiet other &&
31 git diff --quiet HEAD other &&
32 test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
35 test_expect_success
'cherry-pick --ff first..fourth works' '
36 git checkout -f master &&
37 git reset --hard first &&
39 git cherry-pick --ff first..fourth &&
40 git diff --quiet other &&
41 git diff --quiet HEAD other &&
42 test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify fourth)"
45 test_expect_success
'cherry-pick -n first..fourth works' '
46 git checkout -f master &&
47 git reset --hard first &&
49 git cherry-pick -n first..fourth &&
50 git diff --quiet other &&
51 git diff --cached --quiet other &&
52 git diff --quiet HEAD first
55 test_expect_success
'revert first..fourth works' '
56 git checkout -f master &&
57 git reset --hard fourth &&
59 git revert first..fourth &&
60 git diff --quiet first &&
61 git diff --cached --quiet first &&
62 git diff --quiet HEAD first
65 test_expect_success
'revert ^first fourth works' '
66 git checkout -f master &&
67 git reset --hard fourth &&
69 git revert ^first fourth &&
70 git diff --quiet first &&
71 git diff --cached --quiet first &&
72 git diff --quiet HEAD first
75 test_expect_success
'revert fourth fourth~1 fourth~2 works' '
76 git checkout -f master &&
77 git reset --hard fourth &&
79 git revert fourth fourth~1 fourth~2 &&
80 git diff --quiet first &&
81 git diff --cached --quiet first &&
82 git diff --quiet HEAD first
85 test_expect_failure
'cherry-pick -3 fourth works' '
86 git checkout -f master &&
87 git reset --hard first &&
89 git cherry-pick -3 fourth &&
90 git diff --quiet other &&
91 git diff --quiet HEAD other &&
92 test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
95 test_expect_success
'cherry-pick --stdin works' '
96 git checkout -f master &&
97 git reset --hard first &&
99 git rev-list --reverse first..fourth | git cherry-pick --stdin &&
100 git diff --quiet other &&
101 git diff --quiet HEAD other &&
102 test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"