3 test_description
='test cherry-pick and revert with renames
6 + rename2: renames oops to opos
7 + rename1: renames oops to spoo
8 + added: adds extra line to oops
9 ++ initial: has lines in oops
15 test_expect_success setup
'
17 for l in a b c d e f g h i j k l m n o
19 echo $l$l$l$l$l$l$l$l$l
24 git commit -m initial &&
28 echo "Add extra line at the end" >>oops &&
29 git commit -a -m added &&
34 git commit -m rename1 &&
38 git checkout -b side initial &&
40 git commit -m rename2 &&
44 test_expect_success
'cherry-pick --nonsense' '
46 pos=$(git rev-parse HEAD) &&
47 git diff --exit-code HEAD &&
48 test_must_fail git cherry-pick --nonsense 2>msg &&
49 git diff --exit-code HEAD "$pos" &&
50 test_i18ngrep '[Uu
]sage
:' msg
53 test_expect_success
'revert --nonsense' '
55 pos=$(git rev-parse HEAD) &&
56 git diff --exit-code HEAD &&
57 test_must_fail git revert --nonsense 2>msg &&
58 git diff --exit-code HEAD "$pos" &&
59 test_i18ngrep '[Uu
]sage
:' msg
62 test_expect_success
'cherry-pick after renaming branch' '
64 git checkout rename2 &&
65 git cherry-pick added &&
66 test $(git rev-parse HEAD^) = $(git rev-parse rename2) &&
68 grep "Add extra line at the end" opos &&
69 git reflog -1 | grep cherry-pick
73 test_expect_success
'revert after renaming branch' '
75 git checkout rename1 &&
77 test $(git rev-parse HEAD^) = $(git rev-parse rename1) &&
79 ! grep "Add extra line at the end" spoo &&
80 git reflog -1 | grep revert
84 test_expect_success
'cherry-pick on stat-dirty working tree' '
88 git checkout initial &&
89 test-chmtime +40 oops &&
94 test_expect_success
'revert forbidden on dirty working tree' '
96 echo content >extra_file &&
98 test_must_fail git revert HEAD 2>errors &&
99 test_i18ngrep "Your local changes would be overwritten by " errors
103 test_expect_success
'cherry-pick on unborn branch' '
104 git checkout --orphan unborn &&
105 git rm --cached -r . &&
107 git cherry-pick initial &&
108 git diff --quiet initial &&
109 ! test_cmp_rev initial HEAD
112 test_expect_success
'cherry-pick "-" to pick from previous branch' '
113 git checkout unborn &&
114 test_commit to-pick actual content &&
115 git checkout master &&
117 echo content >expect &&
118 test_cmp expect actual
121 test_expect_success
'cherry-pick "-" is meaningless without checkout' '
122 test_create_repo afresh &&
128 test_must_fail git cherry-pick -