Remove the assert in CommitData.parse() function
[stgit] / t / t1600-delete-one.sh
CommitLineData
87bcf96e
KH
1#!/bin/sh
2# Copyright (c) 2006 Karl Hasselström
3test_description='Test the delete command (deleting one patch at a time).'
4. ./test-lib.sh
5
6test_expect_success \
7 'Initialize the StGIT repository' \
8 'stg init'
9
10test_expect_success \
11 'Create a patch' \
12 '
13 stg new foo -m foo &&
14 echo foo > foo.txt &&
c7506039 15 stg add foo.txt &&
87bcf96e
KH
16 stg refresh
17 '
18
19test_expect_success \
20 'Try to delete a non-existing patch' \
21 '
f9d9a062 22 [ $(stg series --applied -c) -eq 1 ] &&
f03004e2 23 command_error stg delete bar &&
f9d9a062 24 [ $(stg series --applied -c) -eq 1 ]
87bcf96e
KH
25 '
26
27test_expect_success \
28 'Try to delete the topmost patch while dirty' \
29 '
30 echo dirty >> foo.txt &&
f9d9a062 31 [ $(stg series --applied -c) -eq 1 ] &&
f03004e2 32 command_error stg delete foo &&
f9d9a062 33 [ $(stg series --applied -c) -eq 1 ] &&
87bcf96e
KH
34 git reset --hard
35 '
36
37test_expect_success \
38 'Delete the topmost patch' \
39 '
f9d9a062 40 [ $(stg series --applied -c) -eq 1 ] &&
87bcf96e 41 stg delete foo &&
f9d9a062 42 [ $(stg series --applied -c) -eq 0 ]
87bcf96e
KH
43 '
44
45test_expect_success \
46 'Create an unapplied patch' \
47 '
48 stg new foo -m foo &&
49 echo foo > foo.txt &&
c7506039 50 stg add foo.txt &&
87bcf96e
KH
51 stg refresh &&
52 stg pop
53 '
54
55test_expect_success \
56 'Delete an unapplied patch' \
57 '
f9d9a062 58 [ $(stg series --unapplied -c) -eq 1 ] &&
87bcf96e 59 stg delete foo &&
f9d9a062 60 [ $(stg series --unapplied -c) -eq 0 ]
87bcf96e
KH
61 '
62
63test_expect_success \
64 'Create two patches' \
65 '
66 stg new foo -m foo &&
67 echo foo > foo.txt &&
c7506039 68 stg add foo.txt &&
87bcf96e
KH
69 stg refresh &&
70 stg new bar -m bar &&
71 echo bar > bar.txt &&
c7506039 72 stg add bar.txt &&
87bcf96e
KH
73 stg refresh
74 '
75
76test_expect_success \
77 'Try to delete a non-topmost applied patch' \
78 '
f9d9a062 79 [ $(stg series --applied -c) -eq 2 ] &&
5901dd6b 80 stg delete foo &&
f9d9a062 81 [ $(stg series --applied -c) -eq 1 ]
87bcf96e
KH
82 '
83
84test_expect_success \
85 'Create another branch, and put one patch in each branch' \
86 '
87 stg branch --create br &&
88 stg new baz -m baz &&
89 echo baz > baz.txt &&
c7506039 90 stg add baz.txt &&
87bcf96e
KH
91 stg refresh &&
92 stg branch master &&
93 stg new baz -m baz &&
94 echo baz > baz.txt &&
c7506039 95 stg add baz.txt &&
87bcf96e
KH
96 stg refresh
97 '
98
99test_expect_success \
100 'Delete a patch in another branch' \
101 '
f9d9a062
CM
102 [ $(stg series --applied -c) -eq 2 ] &&
103 [ $(stg series --applied -b br -c) -eq 1 ] &&
87bcf96e 104 stg delete -b br baz &&
f9d9a062
CM
105 [ $(stg series --applied -c) -eq 2 ] &&
106 [ $(stg series --applied -b br -c) -eq 0 ]
87bcf96e
KH
107 '
108
109test_done