]>
Commit | Line | Data |
---|---|---|
27bfd950 PY |
1 | #!/bin/sh |
2 | ||
47a528ad | 3 | test_description='git status for submodule' |
27bfd950 PY |
4 | |
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success 'setup' ' | |
ee6fc514 JL |
8 | test_create_repo sub && |
9 | ( | |
10 | cd sub && | |
11 | : >bar && | |
12 | git add bar && | |
13 | git commit -m " Add bar" && | |
14 | : >foo && | |
15 | git add foo && | |
16 | git commit -m " Add foo" | |
17 | ) && | |
18 | echo output > .gitignore && | |
19 | git add sub .gitignore && | |
27bfd950 PY |
20 | git commit -m "Add submodule sub" |
21 | ' | |
22 | ||
23 | test_expect_success 'status clean' ' | |
ee6fc514 JL |
24 | git status >output && |
25 | grep "nothing to commit" output | |
27bfd950 | 26 | ' |
ee6fc514 | 27 | |
9e4b7ab6 | 28 | test_expect_success 'commit --dry-run -a clean' ' |
ee6fc514 JL |
29 | test_must_fail git commit --dry-run -a >output && |
30 | grep "nothing to commit" output | |
31 | ' | |
32 | ||
33 | test_expect_success 'status with modified file in submodule' ' | |
34 | (cd sub && git reset --hard) && | |
35 | echo "changed" >sub/foo && | |
36 | git status >output && | |
85adbf2f | 37 | grep "modified: sub (modified content)" output |
ee6fc514 JL |
38 | ' |
39 | ||
40 | test_expect_success 'status with modified file in submodule (porcelain)' ' | |
41 | (cd sub && git reset --hard) && | |
42 | echo "changed" >sub/foo && | |
43 | git status --porcelain >output && | |
44 | diff output - <<-\EOF | |
45 | M sub | |
46 | EOF | |
47 | ' | |
48 | ||
49 | test_expect_success 'status with added file in submodule' ' | |
50 | (cd sub && git reset --hard && echo >foo && git add foo) && | |
51 | git status >output && | |
85adbf2f | 52 | grep "modified: sub (modified content)" output |
ee6fc514 JL |
53 | ' |
54 | ||
55 | test_expect_success 'status with added file in submodule (porcelain)' ' | |
56 | (cd sub && git reset --hard && echo >foo && git add foo) && | |
57 | git status --porcelain >output && | |
58 | diff output - <<-\EOF | |
59 | M sub | |
60 | EOF | |
61 | ' | |
62 | ||
63 | test_expect_success 'status with untracked file in submodule' ' | |
64 | (cd sub && git reset --hard) && | |
65 | echo "content" >sub/new-file && | |
66 | git status >output && | |
85adbf2f | 67 | grep "modified: sub (untracked content)" output |
ee6fc514 JL |
68 | ' |
69 | ||
3bfc4504 JL |
70 | test_expect_success 'status -uno with untracked file in submodule' ' |
71 | git status -uno >output && | |
72 | grep "^nothing to commit" output | |
73 | ' | |
74 | ||
ee6fc514 JL |
75 | test_expect_success 'status with untracked file in submodule (porcelain)' ' |
76 | git status --porcelain >output && | |
77 | diff output - <<-\EOF | |
78 | M sub | |
79 | EOF | |
27bfd950 | 80 | ' |
ee6fc514 | 81 | |
85adbf2f JL |
82 | test_expect_success 'status with added and untracked file in submodule' ' |
83 | (cd sub && git reset --hard && echo >foo && git add foo) && | |
84 | echo "content" >sub/new-file && | |
85 | git status >output && | |
86 | grep "modified: sub (modified content, untracked content)" output | |
87 | ' | |
88 | ||
89 | test_expect_success 'status with added and untracked file in submodule (porcelain)' ' | |
90 | (cd sub && git reset --hard && echo >foo && git add foo) && | |
91 | echo "content" >sub/new-file && | |
92 | git status --porcelain >output && | |
93 | diff output - <<-\EOF | |
94 | M sub | |
95 | EOF | |
96 | ' | |
97 | ||
98 | test_expect_success 'status with modified file in modified submodule' ' | |
99 | (cd sub && git reset --hard) && | |
100 | rm sub/new-file && | |
101 | (cd sub && echo "next change" >foo && git commit -m "next change" foo) && | |
102 | echo "changed" >sub/foo && | |
103 | git status >output && | |
104 | grep "modified: sub (new commits, modified content)" output | |
105 | ' | |
106 | ||
107 | test_expect_success 'status with modified file in modified submodule (porcelain)' ' | |
108 | (cd sub && git reset --hard) && | |
109 | echo "changed" >sub/foo && | |
110 | git status --porcelain >output && | |
111 | diff output - <<-\EOF | |
112 | M sub | |
113 | EOF | |
114 | ' | |
115 | ||
116 | test_expect_success 'status with added file in modified submodule' ' | |
117 | (cd sub && git reset --hard && echo >foo && git add foo) && | |
118 | git status >output && | |
119 | grep "modified: sub (new commits, modified content)" output | |
120 | ' | |
121 | ||
122 | test_expect_success 'status with added file in modified submodule (porcelain)' ' | |
123 | (cd sub && git reset --hard && echo >foo && git add foo) && | |
124 | git status --porcelain >output && | |
125 | diff output - <<-\EOF | |
126 | M sub | |
127 | EOF | |
128 | ' | |
129 | ||
130 | test_expect_success 'status with untracked file in modified submodule' ' | |
131 | (cd sub && git reset --hard) && | |
132 | echo "content" >sub/new-file && | |
133 | git status >output && | |
134 | grep "modified: sub (new commits, untracked content)" output | |
135 | ' | |
136 | ||
137 | test_expect_success 'status with untracked file in modified submodule (porcelain)' ' | |
138 | git status --porcelain >output && | |
139 | diff output - <<-\EOF | |
140 | M sub | |
141 | EOF | |
142 | ' | |
143 | ||
144 | test_expect_success 'status with added and untracked file in modified submodule' ' | |
145 | (cd sub && git reset --hard && echo >foo && git add foo) && | |
146 | echo "content" >sub/new-file && | |
147 | git status >output && | |
148 | grep "modified: sub (new commits, modified content, untracked content)" output | |
149 | ' | |
150 | ||
151 | test_expect_success 'status with added and untracked file in modified submodule (porcelain)' ' | |
152 | (cd sub && git reset --hard && echo >foo && git add foo) && | |
153 | echo "content" >sub/new-file && | |
154 | git status --porcelain >output && | |
155 | diff output - <<-\EOF | |
156 | M sub | |
157 | EOF | |
158 | ' | |
159 | ||
eee49b6c JL |
160 | test_expect_success 'setup .git file for sub' ' |
161 | (cd sub && | |
162 | rm -f new-file | |
163 | REAL="$(pwd)/../.real" && | |
164 | mv .git "$REAL" | |
165 | echo "gitdir: $REAL" >.git) && | |
166 | echo .real >>.gitignore && | |
167 | git commit -m "added .real to .gitignore" .gitignore | |
168 | ' | |
169 | ||
170 | test_expect_success 'status with added file in modified submodule with .git file' ' | |
171 | (cd sub && git reset --hard && echo >foo && git add foo) && | |
172 | git status >output && | |
173 | grep "modified: sub (new commits, modified content)" output | |
174 | ' | |
175 | ||
27bfd950 PY |
176 | test_expect_success 'rm submodule contents' ' |
177 | rm -rf sub/* sub/.git | |
178 | ' | |
ee6fc514 | 179 | |
27bfd950 | 180 | test_expect_success 'status clean (empty submodule dir)' ' |
ee6fc514 JL |
181 | git status >output && |
182 | grep "nothing to commit" output | |
27bfd950 | 183 | ' |
ee6fc514 | 184 | |
050288d5 | 185 | test_expect_success 'status -a clean (empty submodule dir)' ' |
ee6fc514 JL |
186 | test_must_fail git commit --dry-run -a >output && |
187 | grep "nothing to commit" output | |
27bfd950 PY |
188 | ' |
189 | ||
190 | test_done |