Memorialize Python 3.7 support
[stgit.git] / t / t1300-uncommit.sh
blob8b5d86ba8125309f2e3602c6fa32dd46d0c12684
1 #!/bin/sh
3 # Copyright (c) 2006 Catalin Marinas
6 test_description='Test the uncommit command.
10 . ./test-lib.sh
12 test_expect_success \
13 'Initialize the StGIT repository' \
14 'stg init
17 test_expect_success \
18 'Create the first patch' \
20 stg new foo -m "Foo Patch" &&
21 echo foo > test &&
22 stg add test &&
23 stg refresh
26 test_expect_success \
27 'Create the second patch' \
29 stg new bar -m "Bar Patch" &&
30 echo bar > test &&
31 stg add test &&
32 stg refresh
35 test_expect_success \
36 'Commit the patches' \
38 stg commit --all
41 test_expect_success \
42 'Invalid --to and --number arguments' \
44 command_error stg uncommit --to HEAD^ --number 1 2>&1 |
45 grep -e "cannot give both --to and --number"
48 test_expect_success \
49 'Invalid --to with patch args' \
51 command_error stg uncommit --to HEAD^ p0 2>&1 |
52 grep -e "cannot specify patch name with --to"
55 test_expect_success \
56 'Invalid --number' \
58 command_error stg uncommit --number -1 2>&1 |
59 grep -e "invalid value passed to --number"
62 test_expect_success \
63 'Too many patch names with --number' \
65 command_error stg uncommit --number 2 p0 p1 2>&1 |
66 grep -e "when using --number, specify at most one patch name"
69 test_expect_success \
70 'Uncommit the patches using names' \
72 stg uncommit bar foo &&
73 [ "$(stg id foo)" = "$(stg id bar^)" ] &&
74 stg commit --all
77 test_expect_success \
78 'Uncommit the patches using prefix' \
80 stg uncommit --number=2 foobar &&
81 [ "$(stg id foobar1)" = "$(stg id foobar2^)" ] &&
82 stg commit --all
85 test_expect_success \
86 'Uncommit the patches using auto names' \
88 stg uncommit --number=2 &&
89 [ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] &&
90 stg commit --all
93 test_expect_success \
94 'Uncommit the patches one by one' \
96 stg uncommit &&
97 stg uncommit &&
98 [ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] &&
99 stg commit --all
102 test_expect_success \
103 'Uncommit the patches with --to' '
104 stg uncommit --to HEAD^ &&
105 [ "$(stg id foo-patch)" = "$(stg id bar-patch^)" ] &&
106 stg commit --all
109 test_expect_success \
110 'Use --exclusive' \
112 stg uncommit --to HEAD^ --exclusive &&
113 [ "$(echo $(stg series --applied --noprefix))" = "bar-patch" ] &&
114 stg commit --all
117 test_expect_success 'Attempt to reuse patch name' '
118 stg uncommit &&
119 [ "$(echo $(stg series --applied --noprefix))" = "bar-patch" ] &&
120 command_error stg uncommit bar-patch 2>&1 |
121 grep -e "Patch name \"bar-patch\" already taken" &&
122 stg commit --all
125 test_expect_success 'Uncommit a commit with not precisely one parent' '
126 command_error stg uncommit -n 5 &&
127 [ "$(echo $(stg series))" = "" ]
130 # stg uncommit should work even when top != head, and should not touch
131 # the head.
132 test_expect_success 'Uncommit when top != head' '
133 stg new -m foo &&
134 git reset --hard HEAD^ &&
135 h=$(git rev-parse HEAD)
136 stg uncommit bar &&
137 test "$(git rev-parse HEAD)" = "$h" &&
138 test "$(echo $(stg series))" = "+ bar > foo"
141 test_done