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 after renaming branch' '
46 git checkout rename2 &&
47 git cherry-pick added &&
48 test $(git rev-parse HEAD^) = $(git rev-parse rename2) &&
50 grep "Add extra line at the end" opos &&
51 git reflog -1 | grep cherry-pick
55 test_expect_success
'revert after renaming branch' '
57 git checkout rename1 &&
59 test $(git rev-parse HEAD^) = $(git rev-parse rename1) &&
61 ! grep "Add extra line at the end" spoo &&
62 git reflog -1 | grep revert
66 test_expect_success
'revert forbidden on dirty working tree' '
68 echo content >extra_file &&
70 test_must_fail git revert HEAD 2>errors &&
71 grep "Your local changes would be overwritten by " errors