refs/files: skip creation of "refs/{heads,tags}" for worktrees
[git.git] / t / t7422-submodule-output.sh
blobab946ec9405deb536ffd7c6fa350bcc8abf3544c
1 #!/bin/sh
3 test_description='submodule --cached, --quiet etc. output'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7 . "$TEST_DIRECTORY"/lib-t3100.sh
9 setup_sub () {
10 local d="$1" &&
11 shift &&
12 git $@ clone . "$d" &&
13 git $@ submodule add ./"$d"
16 normalize_status () {
17 sed -e 's/-g[0-9a-f]*/-gHASH/'
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 &&
31 # recursive in X/
32 git -C X pull &&
33 GIT_ALLOW_PROTOCOL=file git -C X submodule update --init &&
35 # dirty
36 for d in S.D X/S.D
38 echo dirty >"$d"/A.t || return 1
39 done &&
41 # commit (for --cached)
42 for d in S.C* X/S.C*
44 git -C "$d" reset --hard A || return 1
45 done &&
47 # dirty
48 for d in S*.D X/S*.D
50 echo dirty >"$d/C2.t" || return 1
51 done &&
53 for ref in A B C
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
66 for opts in "" "status"
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
80 done
82 for opts in \
83 "status --recursive"
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
102 done
104 for opts in \
105 "--quiet" \
106 "--quiet status" \
107 "status --quiet"
109 test_expect_success "git submodule $opts" '
110 git submodule $opts >out &&
111 test_must_be_empty out
113 done
115 for opts in \
116 "--cached" \
117 "--cached status" \
118 "status --cached"
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)
128 git submodule $opts >actual.raw &&
129 normalize_status <actual.raw >actual &&
130 test_cmp expect actual
132 done
134 for opts in \
135 "--cached --quiet" \
136 "--cached --quiet status" \
137 "--cached status --quiet" \
138 "--quiet status --cached" \
139 "status --cached --quiet"
141 test_expect_success "git submodule $opts" '
142 git submodule $opts >out &&
143 test_must_be_empty out
145 done
147 for opts in \
148 "status --cached --recursive" \
149 "--cached status --recursive"
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)
164 git submodule $opts >actual.raw &&
165 normalize_status <actual.raw >actual &&
166 test_cmp expect actual
168 done
170 test_done