chiark / gitweb /
ce3b68886cf1ce8dc5c75b689161ae21f8a4c90c
[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 EOF
64 test_expect_success 'Status after refresh' '
65     stg new -m "first patch" &&
66     stg refresh &&
67     stg status > output.txt &&
68     diff -u expected.txt output.txt
69 '
70
71 cat > expected.txt <<EOF
72 M foo/bar
73 EOF
74 test_expect_success 'Status after modification' '
75     echo "wee" >> foo/bar &&
76     stg status > output.txt &&
77     diff -u expected.txt output.txt
78 '
79
80 cat > expected.txt <<EOF
81 EOF
82 test_expect_success 'Status after refresh' '
83     stg new -m "second patch" && stg refresh &&
84     stg status > output.txt &&
85     diff -u expected.txt output.txt
86 '
87
88 test_expect_success 'Make a conflicting patch' '
89     stg pop &&
90     stg new -m "third patch" &&
91     echo "woo" >> foo/bar &&
92     stg refresh
93 '
94
95 cat > expected.txt <<EOF
96 ? foo/bar.ancestor
97 ? foo/bar.current
98 ? foo/bar.patched
99 C foo/bar
100 EOF
101 test_expect_success 'Status after conflicting push' '
102     ! stg push &&
103     stg status > output.txt &&
104     diff -u expected.txt output.txt
105 '
106
107 cat > expected.txt <<EOF
108 M foo/bar
109 EOF
110 test_expect_success 'Status after resolving the push' '
111     stg resolved -a &&
112     stg status > output.txt &&
113     diff -u expected.txt output.txt
114 '
115
116 cat > expected.txt <<EOF
117 D foo/bar
118 EOF
119 test_expect_success 'Status after deleting a file' '
120     rm foo/bar &&
121     stg status > output.txt &&
122     diff -u expected.txt output.txt
123 '
124
125 test_done