Release 0.19
[stgit.git] / t / t1600-delete-one.sh
blobcb72058a3f7db9a552c1d70a783381fab7fd1939
1 #!/bin/sh
2 # Copyright (c) 2006 Karl Hasselström
3 test_description='Test the delete command (deleting one patch at a time).'
4 . ./test-lib.sh
6 test_expect_success \
7 'Initialize the StGIT repository' \
8 'stg init'
10 test_expect_success \
11 'Create a patch' \
13 stg new foo -m foo &&
14 echo foo > foo.txt &&
15 stg add foo.txt &&
16 stg refresh
19 test_expect_success \
20 'Invalid arguments' \
22 command_error stg delete --top foo 2>&1 |
23 grep -e "Either --top or patches must be specified"
26 test_expect_success \
27 'Attempt delete --top with none applied' \
29 stg pop &&
30 command_error stg delete --top 2>&1 |
31 grep -e "No patches applied" &&
32 stg push
35 test_expect_success \
36 'No patches specified' \
38 command_error stg delete 2>&1 |
39 grep -e "No patches specified"
42 test_expect_success \
43 'Try to delete a non-existing patch' \
45 [ $(stg series --applied -c) -eq 1 ] &&
46 command_error stg delete bar &&
47 [ $(stg series --applied -c) -eq 1 ]
50 test_expect_success \
51 'Try to delete the topmost patch while dirty' \
53 echo dirty >> foo.txt &&
54 [ $(stg series --applied -c) -eq 1 ] &&
55 command_error stg delete foo &&
56 [ $(stg series --applied -c) -eq 1 ] &&
57 git reset --hard
60 test_expect_success \
61 'Delete the topmost patch' \
63 [ $(stg series --applied -c) -eq 1 ] &&
64 stg delete foo &&
65 [ $(stg series --applied -c) -eq 0 ]
68 test_expect_success \
69 'Create an unapplied patch' \
71 stg new foo -m foo &&
72 echo foo > foo.txt &&
73 stg add foo.txt &&
74 stg refresh &&
75 stg pop
78 test_expect_success \
79 'Delete an unapplied patch' \
81 [ $(stg series --unapplied -c) -eq 1 ] &&
82 stg delete foo &&
83 [ $(stg series --unapplied -c) -eq 0 ]
86 test_expect_success \
87 'Create three patches' \
89 stg new foo -m foo &&
90 echo foo > foo.txt &&
91 stg add foo.txt &&
92 stg refresh &&
93 stg new bar -m bar &&
94 echo bar > bar.txt &&
95 stg add bar.txt &&
96 stg refresh &&
97 stg new baz -m baz &&
98 echo baz > baz.txt &&
99 stg add baz.txt &&
100 stg refresh
103 test_expect_success \
104 'Try to delete a topmost patch with --top option' \
106 [ $(stg series --applied -c) -eq 3 ] &&
107 stg delete --top &&
108 [ $(stg series --applied -c) -eq 2 ]
111 test_expect_success \
112 'Try to delete a non-topmost applied patch' \
114 [ $(stg series --applied -c) -eq 2 ] &&
115 stg delete foo &&
116 [ $(stg series --applied -c) -eq 1 ]
119 test_expect_success \
120 'Create another branch, and put one patch in each branch' \
122 stg branch --create br &&
123 stg new baz -m baz &&
124 echo baz > baz.txt &&
125 stg add baz.txt &&
126 stg refresh &&
127 stg branch master &&
128 stg new baz -m baz &&
129 echo baz > baz.txt &&
130 stg add baz.txt &&
131 stg refresh
134 test_expect_success \
135 'Delete a patch in another branch' \
137 [ $(stg series --applied -c) -eq 2 ] &&
138 [ $(stg series --applied -b br -c) -eq 1 ] &&
139 stg delete -b br baz &&
140 [ $(stg series --applied -c) -eq 2 ] &&
141 [ $(stg series --applied -b br -c) -eq 0 ]
144 test_done