]>
Commit | Line | Data |
---|---|---|
44874cbd ÆAB |
1 | #!/bin/sh |
2 | ||
3 | test_description='submodule --cached, --quiet etc. output' | |
4 | ||
435285bd | 5 | TEST_PASSES_SANITIZE_LEAK=true |
44874cbd ÆAB |
6 | . ./test-lib.sh |
7 | . "$TEST_DIRECTORY"/lib-t3100.sh | |
8 | ||
9 | setup_sub () { | |
10 | local d="$1" && | |
11 | shift && | |
12 | git $@ clone . "$d" && | |
13 | git $@ submodule add ./"$d" | |
14 | } | |
15 | ||
16 | normalize_status () { | |
17 | sed -e 's/-g[0-9a-f]*/-gHASH/' | |
18 | } | |
19 | ||
20 | test_expect_success 'setup' ' | |
21 | test_commit A && | |
22 | test_commit B && | |
23 | setup_sub S && | |
24 | setup_sub S.D && | |
25 | setup_sub S.C && | |
26 | setup_sub S.C.D && | |
27 | setup_sub X && | |
28 | git add S* && | |
29 | test_commit C && | |
30 | ||
31 | # recursive in X/ | |
32 | git -C X pull && | |
33 | GIT_ALLOW_PROTOCOL=file git -C X submodule update --init && | |
34 | ||
35 | # dirty | |
36 | for d in S.D X/S.D | |
37 | do | |
38 | echo dirty >"$d"/A.t || return 1 | |
39 | done && | |
40 | ||
41 | # commit (for --cached) | |
42 | for d in S.C* X/S.C* | |
43 | do | |
44 | git -C "$d" reset --hard A || return 1 | |
45 | done && | |
46 | ||
47 | # dirty | |
48 | for d in S*.D X/S*.D | |
49 | do | |
50 | echo dirty >"$d/C2.t" || return 1 | |
51 | done && | |
52 | ||
53 | for ref in A B C | |
54 | do | |
55 | # Not different with SHA-1 and SHA-256, just (ab)using | |
56 | # test_oid_cache as a variable bag to avoid using | |
57 | # $(git rev-parse ...). | |
58 | oid=$(git rev-parse $ref) && | |
59 | test_oid_cache <<-EOF || return 1 | |
60 | $ref sha1:$oid | |
61 | $ref sha256:$oid | |
62 | EOF | |
63 | done | |
64 | ' | |
65 | ||
66 | for opts in "" "status" | |
67 | do | |
68 | test_expect_success "git submodule $opts" ' | |
69 | sed -e "s/^>//" >expect <<-EOF && | |
70 | > $(test_oid B) S (B) | |
71 | >+$(test_oid A) S.C (A) | |
72 | >+$(test_oid A) S.C.D (A) | |
73 | > $(test_oid B) S.D (B) | |
74 | >+$(test_oid C) X (C) | |
75 | EOF | |
76 | git submodule $opts >actual.raw && | |
77 | normalize_status <actual.raw >actual && | |
78 | test_cmp expect actual | |
79 | ' | |
80 | done | |
81 | ||
82 | for opts in \ | |
83 | "status --recursive" | |
84 | do | |
85 | test_expect_success "git submodule $opts" ' | |
86 | sed -e "s/^>//" >expect <<-EOF && | |
87 | > $(test_oid B) S (B) | |
88 | >+$(test_oid A) S.C (A) | |
89 | >+$(test_oid A) S.C.D (A) | |
90 | > $(test_oid B) S.D (B) | |
91 | >+$(test_oid C) X (C) | |
92 | > $(test_oid B) X/S (B) | |
93 | >+$(test_oid A) X/S.C (A) | |
94 | >+$(test_oid A) X/S.C.D (A) | |
95 | > $(test_oid B) X/S.D (B) | |
96 | > $(test_oid B) X/X (B) | |
97 | EOF | |
98 | git submodule $opts >actual.raw && | |
99 | normalize_status <actual.raw >actual && | |
100 | test_cmp expect actual | |
101 | ' | |
102 | done | |
103 | ||
104 | for opts in \ | |
105 | "--quiet" \ | |
106 | "--quiet status" \ | |
107 | "status --quiet" | |
108 | do | |
109 | test_expect_success "git submodule $opts" ' | |
110 | git submodule $opts >out && | |
111 | test_must_be_empty out | |
112 | ' | |
113 | done | |
114 | ||
115 | for opts in \ | |
116 | "--cached" \ | |
117 | "--cached status" \ | |
118 | "status --cached" | |
119 | do | |
120 | test_expect_success "git submodule $opts" ' | |
121 | sed -e "s/^>//" >expect <<-EOF && | |
122 | > $(test_oid B) S (B) | |
123 | >+$(test_oid B) S.C (B) | |
124 | >+$(test_oid B) S.C.D (B) | |
125 | > $(test_oid B) S.D (B) | |
126 | >+$(test_oid B) X (B) | |
127 | EOF | |
128 | git submodule $opts >actual.raw && | |
129 | normalize_status <actual.raw >actual && | |
130 | test_cmp expect actual | |
131 | ' | |
132 | done | |
133 | ||
134 | for opts in \ | |
135 | "--cached --quiet" \ | |
136 | "--cached --quiet status" \ | |
137 | "--cached status --quiet" \ | |
138 | "--quiet status --cached" \ | |
139 | "status --cached --quiet" | |
140 | do | |
141 | test_expect_success "git submodule $opts" ' | |
142 | git submodule $opts >out && | |
143 | test_must_be_empty out | |
144 | ' | |
145 | done | |
146 | ||
147 | for opts in \ | |
148 | "status --cached --recursive" \ | |
149 | "--cached status --recursive" | |
150 | do | |
151 | test_expect_success "git submodule $opts" ' | |
152 | sed -e "s/^>//" >expect <<-EOF && | |
153 | > $(test_oid B) S (B) | |
154 | >+$(test_oid B) S.C (B) | |
155 | >+$(test_oid B) S.C.D (B) | |
156 | > $(test_oid B) S.D (B) | |
157 | >+$(test_oid B) X (B) | |
158 | > $(test_oid B) X/S (B) | |
159 | >+$(test_oid B) X/S.C (B) | |
160 | >+$(test_oid B) X/S.C.D (B) | |
161 | > $(test_oid B) X/S.D (B) | |
162 | > $(test_oid B) X/X (B) | |
163 | EOF | |
164 | git submodule $opts >actual.raw && | |
165 | normalize_status <actual.raw >actual && | |
166 | test_cmp expect actual | |
167 | ' | |
168 | done | |
169 | ||
170 | test_done |