Merge branch 'mm/phrase-remote-tracking' into next
[git/mingw/4msysgit.git] / t / t3501-revert-cherry-pick.sh
blobbc7aedd0484ed5ad1115cac0f22943445d658f47
1 #!/bin/sh
3 test_description='test cherry-pick and revert with renames
5 --
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
13 . ./test-lib.sh
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
20 done >oops &&
22 test_tick &&
23 git add oops &&
24 git commit -m initial &&
25 git tag initial &&
27 test_tick &&
28 echo "Add extra line at the end" >>oops &&
29 git commit -a -m added &&
30 git tag added &&
32 test_tick &&
33 git mv oops spoo &&
34 git commit -m rename1 &&
35 git tag rename1 &&
37 test_tick &&
38 git checkout -b side initial &&
39 git mv oops opos &&
40 git commit -m rename2 &&
41 git tag 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 grep '[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 grep '[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) &&
67 test -f opos &&
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 &&
76 git revert added &&
77 test $(git rev-parse HEAD^) = $(git rev-parse rename1) &&
78 test -f spoo &&
79 ! grep "Add extra line at the end" spoo &&
80 git reflog -1 | grep revert
84 test_expect_success 'revert forbidden on dirty working tree' '
86 echo content >extra_file &&
87 git add extra_file &&
88 test_must_fail git revert HEAD 2>errors &&
89 grep "Your local changes would be overwritten by " errors
93 test_done