Regression test for "stg import"
[stgit/ydirson.git] / t / t1600-delete-one.sh
blobdf03d79c860db85377e3bac80eab8c1aca83f6ab
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 'Try to delete a non-existing patch' \
22 [ $(stg applied | wc -l) -eq 1 ] &&
23 ! stg delete bar &&
24 [ $(stg applied | wc -l) -eq 1 ]
27 test_expect_success \
28 'Try to delete the topmost patch while dirty' \
30 echo dirty >> foo.txt &&
31 [ $(stg applied | wc -l) -eq 1 ] &&
32 ! stg delete foo &&
33 [ $(stg applied | wc -l) -eq 1 ] &&
34 git reset --hard
37 test_expect_success \
38 'Delete the topmost patch' \
40 [ $(stg applied | wc -l) -eq 1 ] &&
41 stg delete foo &&
42 [ $(stg applied | wc -l) -eq 0 ]
45 test_expect_success \
46 'Create an unapplied patch' \
48 stg new foo -m foo &&
49 echo foo > foo.txt &&
50 stg add foo.txt &&
51 stg refresh &&
52 stg pop
55 test_expect_success \
56 'Delete an unapplied patch' \
58 [ $(stg unapplied | wc -l) -eq 1 ] &&
59 stg delete foo &&
60 [ $(stg unapplied | wc -l) -eq 0 ]
63 test_expect_success \
64 'Create two patches' \
66 stg new foo -m foo &&
67 echo foo > foo.txt &&
68 stg add foo.txt &&
69 stg refresh &&
70 stg new bar -m bar &&
71 echo bar > bar.txt &&
72 stg add bar.txt &&
73 stg refresh
76 test_expect_success \
77 'Try to delete a non-topmost applied patch' \
79 [ $(stg applied | wc -l) -eq 2 ] &&
80 ! stg delete foo &&
81 [ $(stg applied | wc -l) -eq 2 ]
84 test_expect_success \
85 'Create another branch, and put one patch in each branch' \
87 stg branch --create br &&
88 stg new baz -m baz &&
89 echo baz > baz.txt &&
90 stg add baz.txt &&
91 stg refresh &&
92 stg branch master &&
93 stg new baz -m baz &&
94 echo baz > baz.txt &&
95 stg add baz.txt &&
96 stg refresh
99 test_expect_success \
100 'Delete a patch in another branch' \
102 [ $(stg applied | wc -l) -eq 3 ] &&
103 [ $(stg applied -b br | wc -l) -eq 1 ] &&
104 stg delete -b br baz &&
105 [ $(stg applied | wc -l) -eq 3 ] &&
106 [ $(stg applied -b br | wc -l) -eq 0 ]
109 test_done