Allow StGIT commands to run correctly in subdirectories
[stgit] / t / t0002-status.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2007 David Kågedal
4 #
5
6 test_description='Basic stg status
7
8 Test that "stg status" works.'
9
10 . ./test-lib.sh
11 stg init
12
13 # Ignore our own output files.
14 cat > .git/info/exclude <<EOF
15 /expected.txt
16 /output.txt
17 EOF
18
19 cat > expected.txt <<EOF
20 EOF
21 test_expect_success 'Run status on empty' '
22 stg status > output.txt &&
23 diff -u expected.txt output.txt
24 '
25
26 cat > expected.txt <<EOF
27 ? foo
28 EOF
29 test_expect_success 'Status with an untracked file' '
30 touch foo &&
31 stg status > output.txt &&
32 diff -u expected.txt output.txt
33 '
34 rm -f foo
35
36 cat > expected.txt <<EOF
37 EOF
38 test_expect_success 'Status with an empty directory' '
39 mkdir foo &&
40 stg status > output.txt &&
41 diff -u expected.txt output.txt
42 '
43
44 cat > expected.txt <<EOF
45 ? foo/
46 EOF
47 test_expect_success 'Status with an untracked file in a subdir' '
48 touch foo/bar &&
49 stg status > output.txt &&
50 diff -u expected.txt output.txt
51 '
52
53 cat > expected.txt <<EOF
54 A foo/bar
55 EOF
56 test_expect_success 'Status with an added file' '
57 stg add foo &&
58 stg status > output.txt &&
59 diff -u expected.txt output.txt
60 '
61
62 cat > expected.txt <<EOF
63 foo/bar
64 EOF
65 test_expect_success 'Status with an added file and -n option' '
66 stg status -n > output.txt &&
67 diff -u expected.txt output.txt
68 '
69
70 cat > expected.txt <<EOF
71 EOF
72 test_expect_success 'Status after refresh' '
73 stg new -m "first patch" &&
74 stg refresh &&
75 stg status > output.txt &&
76 diff -u expected.txt output.txt
77 '
78
79 cat > expected.txt <<EOF
80 M foo/bar
81 EOF
82 test_expect_success 'Status after modification' '
83 echo "wee" >> foo/bar &&
84 stg status > output.txt &&
85 diff -u expected.txt output.txt
86 '
87
88 cat > expected.txt <<EOF
89 EOF
90 test_expect_success 'Status after refresh' '
91 stg new -m "second patch" && stg refresh &&
92 stg status > output.txt &&
93 diff -u expected.txt output.txt
94 '
95
96 test_expect_success 'Add another file' '
97 echo lajbans > fie &&
98 stg add fie &&
99 stg refresh
100 '
101
102 test_expect_success 'Make a conflicting patch' '
103 stg pop &&
104 stg new -m "third patch" &&
105 echo "woo" >> foo/bar &&
106 stg refresh
107 '
108
109 cat > expected.txt <<EOF
110 ? foo/bar.ancestor
111 ? foo/bar.current
112 ? foo/bar.patched
113 C foo/bar
114 EOF
115 test_expect_success 'Status after conflicting push' '
116 ! stg push &&
117 stg status > output.txt &&
118 diff -u expected.txt output.txt
119 '
120
121 cat > expected.txt <<EOF
122 C foo/bar
123 EOF
124 test_expect_success 'Status of file' '
125 stg status foo/bar > output.txt &&
126 diff -u expected.txt output.txt
127 '
128
129 cat > expected.txt <<EOF
130 C foo/bar
131 EOF
132 test_expect_success 'Status of dir' '
133 stg status foo > output.txt &&
134 diff -u expected.txt output.txt
135 '
136
137 cat > expected.txt <<EOF
138 EOF
139 test_expect_success 'Status of other file' '
140 stg status fie > output.txt &&
141 diff -u expected.txt output.txt
142 '
143
144 cat > expected.txt <<EOF
145 M foo/bar
146 EOF
147 test_expect_success 'Status after resolving the push' '
148 stg resolved -a &&
149 stg status > output.txt &&
150 diff -u expected.txt output.txt
151 '
152
153 cat > expected.txt <<EOF
154 D foo/bar
155 EOF
156 test_expect_success 'Status after deleting a file' '
157 rm foo/bar &&
158 stg status > output.txt &&
159 diff -u expected.txt output.txt
160 '
161
162 test_done