]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3501-revert-cherry-pick.sh
t/README: document --root option
[thirdparty/git.git] / t / t3501-revert-cherry-pick.sh
CommitLineData
acb4441e
JH
1#!/bin/sh
2
3test_description='test cherry-pick and revert with renames
4
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
10
11'
12
13. ./test-lib.sh
14
15test_expect_success setup '
16
17 for l in a b c d e f g h i j k l m n o
18 do
19 echo $l$l$l$l$l$l$l$l$l
20 done >oops &&
21
22 test_tick &&
23 git add oops &&
24 git commit -m initial &&
25 git tag initial &&
26
27 test_tick &&
28 echo "Add extra line at the end" >>oops &&
29 git commit -a -m added &&
30 git tag added &&
31
32 test_tick &&
33 git mv oops spoo &&
34 git commit -m rename1 &&
35 git tag rename1 &&
36
37 test_tick &&
38 git checkout -b side initial &&
39 git mv oops opos &&
40 git commit -m rename2 &&
41 git tag rename2
42'
43
44test_expect_success 'cherry-pick after renaming branch' '
45
46 git checkout rename2 &&
9e54dc6c 47 git cherry-pick added &&
944019c8 48 test $(git rev-parse HEAD^) = $(git rev-parse rename2) &&
acb4441e
JH
49 test -f opos &&
50 grep "Add extra line at the end" opos
51
52'
53
54test_expect_success 'revert after renaming branch' '
55
56 git checkout rename1 &&
9e54dc6c 57 git revert added &&
944019c8 58 test $(git rev-parse HEAD^) = $(git rev-parse rename1) &&
acb4441e
JH
59 test -f spoo &&
60 ! grep "Add extra line at the end" spoo
61
62'
63
0f2d4476
JK
64test_expect_success 'revert forbidden on dirty working tree' '
65
66 echo content >extra_file &&
67 git add extra_file &&
68 test_must_fail git revert HEAD 2>errors &&
d38a30df 69 grep "Your local changes would be overwritten by " errors
0f2d4476
JK
70
71'
72
acb4441e 73test_done