2 # Copyright (c) 2006 Karl Hasselström
3 test_description
='Test the delete command (deleting one patch at a time).'
7 'Initialize the StGIT repository' \
22 command_error stg delete --top foo 2>&1 |
23 grep -e "Either --top or patches must be specified"
27 'Attempt delete --top with none applied' \
30 command_error stg delete --top 2>&1 |
31 grep -e "No patches applied" &&
36 'No patches specified' \
38 command_error stg delete 2>&1 |
39 grep -e "No patches specified"
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 ]
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 ] &&
61 'Delete the topmost patch' \
63 [ $(stg series --applied -c) -eq 1 ] &&
65 [ $(stg series --applied -c) -eq 0 ]
69 'Create an unapplied patch' \
79 'Delete an unapplied patch' \
81 [ $(stg series --unapplied -c) -eq 1 ] &&
83 [ $(stg series --unapplied -c) -eq 0 ]
87 'Create three patches' \
103 test_expect_success \
104 'Try to delete a topmost patch with --top option' \
106 [ $(stg series --applied -c) -eq 3 ] &&
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 ] &&
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 &&
128 stg new baz -m baz &&
129 echo baz > baz.txt &&
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 ]