]>
Commit | Line | Data |
---|---|---|
6de08ae6 SP |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Shawn Pearce | |
4 | # | |
5 | ||
5be60078 | 6 | test_description='Test git update-ref and basic ref logging' |
6de08ae6 SP |
7 | . ./test-lib.sh |
8 | ||
3749fde5 | 9 | Z=$_z40 |
c3b0dec5 LT |
10 | |
11 | test_expect_success setup ' | |
12 | ||
13 | for name in A B C D E F | |
14 | do | |
15 | test_tick && | |
16 | T=$(git write-tree) && | |
17 | sha1=$(echo $name | git commit-tree $T) && | |
18 | eval $name=$sha1 | |
19 | done | |
20 | ||
21 | ' | |
22 | ||
6de08ae6 | 23 | m=refs/heads/master |
818f477c SP |
24 | n_dir=refs/heads/gu |
25 | n=$n_dir/fixes | |
6de08ae6 SP |
26 | |
27 | test_expect_success \ | |
28 | "create $m" \ | |
5be60078 | 29 | "git update-ref $m $A && |
8aac4b45 | 30 | test $A"' = $(cat .git/'"$m"')' |
6de08ae6 SP |
31 | test_expect_success \ |
32 | "create $m" \ | |
5be60078 | 33 | "git update-ref $m $B $A && |
8aac4b45 | 34 | test $B"' = $(cat .git/'"$m"')' |
40672a19 KW |
35 | test_expect_success "fail to delete $m with stale ref" ' |
36 | test_must_fail git update-ref -d $m $A && | |
37 | test $B = "$(cat .git/$m)" | |
38 | ' | |
39 | test_expect_success "delete $m" ' | |
40 | git update-ref -d $m $B && | |
41 | ! test -f .git/$m | |
42 | ' | |
6de08ae6 SP |
43 | rm -f .git/$m |
44 | ||
3fe8dce6 KW |
45 | test_expect_success "delete $m without oldvalue verification" " |
46 | git update-ref $m $A && | |
47 | test $A = \$(cat .git/$m) && | |
48 | git update-ref -d $m && | |
49 | ! test -f .git/$m | |
50 | " | |
51 | rm -f .git/$m | |
52 | ||
818f477c SP |
53 | test_expect_success \ |
54 | "fail to create $n" \ | |
598f0877 JN |
55 | "touch .git/$n_dir && |
56 | test_must_fail git update-ref $n $A >out 2>err" | |
818f477c SP |
57 | rm -f .git/$n_dir out err |
58 | ||
6de08ae6 SP |
59 | test_expect_success \ |
60 | "create $m (by HEAD)" \ | |
5be60078 | 61 | "git update-ref HEAD $A && |
8aac4b45 | 62 | test $A"' = $(cat .git/'"$m"')' |
6de08ae6 SP |
63 | test_expect_success \ |
64 | "create $m (by HEAD)" \ | |
5be60078 | 65 | "git update-ref HEAD $B $A && |
8aac4b45 | 66 | test $B"' = $(cat .git/'"$m"')' |
40672a19 KW |
67 | test_expect_success "fail to delete $m (by HEAD) with stale ref" ' |
68 | test_must_fail git update-ref -d HEAD $A && | |
69 | test $B = $(cat .git/$m) | |
70 | ' | |
71 | test_expect_success "delete $m (by HEAD)" ' | |
72 | git update-ref -d HEAD $B && | |
73 | ! test -f .git/$m | |
74 | ' | |
6de08ae6 SP |
75 | rm -f .git/$m |
76 | ||
75c96e05 JH |
77 | test_expect_success \ |
78 | "create $m (by HEAD)" \ | |
79 | "git update-ref HEAD $A && | |
80 | test $A"' = $(cat .git/'"$m"')' | |
81 | test_expect_success \ | |
82 | "pack refs" \ | |
83 | "git pack-refs --all" | |
84 | test_expect_success \ | |
85 | "move $m (by HEAD)" \ | |
86 | "git update-ref HEAD $B $A && | |
87 | test $B"' = $(cat .git/'"$m"')' | |
b274a714 | 88 | test_expect_success "delete $m (by HEAD) should remove both packed and loose $m" ' |
75c96e05 JH |
89 | git update-ref -d HEAD $B && |
90 | ! grep "$m" .git/packed-refs && | |
91 | ! test -f .git/$m | |
92 | ' | |
93 | rm -f .git/$m | |
94 | ||
569740bd MV |
95 | cp -f .git/HEAD .git/HEAD.orig |
96 | test_expect_success "delete symref without dereference" ' | |
97 | git update-ref --no-deref -d HEAD && | |
98 | ! test -f .git/HEAD | |
99 | ' | |
100 | cp -f .git/HEAD.orig .git/HEAD | |
101 | ||
045a476f MV |
102 | test_expect_success "delete symref without dereference when the referred ref is packed" ' |
103 | echo foo >foo.c && | |
104 | git add foo.c && | |
105 | git commit -m foo && | |
106 | git pack-refs --all && | |
107 | git update-ref --no-deref -d HEAD && | |
108 | ! test -f .git/HEAD | |
109 | ' | |
110 | cp -f .git/HEAD.orig .git/HEAD | |
111 | git update-ref -d $m | |
112 | ||
41ac414e | 113 | test_expect_success '(not) create HEAD with old sha1' " |
d492b31c | 114 | test_must_fail git update-ref HEAD $A $B |
41ac414e JH |
115 | " |
116 | test_expect_success "(not) prior created .git/$m" " | |
117 | ! test -f .git/$m | |
118 | " | |
6de08ae6 SP |
119 | rm -f .git/$m |
120 | ||
121 | test_expect_success \ | |
122 | "create HEAD" \ | |
5be60078 | 123 | "git update-ref HEAD $A" |
41ac414e | 124 | test_expect_success '(not) change HEAD with wrong SHA1' " |
d492b31c | 125 | test_must_fail git update-ref HEAD $B $Z |
41ac414e JH |
126 | " |
127 | test_expect_success "(not) changed .git/$m" " | |
128 | ! test $B"' = $(cat .git/'"$m"') | |
129 | ' | |
6de08ae6 SP |
130 | rm -f .git/$m |
131 | ||
0bee5918 SP |
132 | : a repository with working tree always has reflog these days... |
133 | : >.git/logs/refs/heads/master | |
6de08ae6 SP |
134 | test_expect_success \ |
135 | "create $m (logged by touch)" \ | |
136 | 'GIT_COMMITTER_DATE="2005-05-26 23:30" \ | |
5be60078 | 137 | git update-ref HEAD '"$A"' -m "Initial Creation" && |
8aac4b45 | 138 | test '"$A"' = $(cat .git/'"$m"')' |
6de08ae6 SP |
139 | test_expect_success \ |
140 | "update $m (logged by touch)" \ | |
141 | 'GIT_COMMITTER_DATE="2005-05-26 23:31" \ | |
5be60078 | 142 | git update-ref HEAD'" $B $A "'-m "Switch" && |
8aac4b45 | 143 | test '"$B"' = $(cat .git/'"$m"')' |
6de08ae6 SP |
144 | test_expect_success \ |
145 | "set $m (logged by touch)" \ | |
146 | 'GIT_COMMITTER_DATE="2005-05-26 23:41" \ | |
5be60078 | 147 | git update-ref HEAD'" $A && |
8aac4b45 | 148 | test $A"' = $(cat .git/'"$m"')' |
6de08ae6 SP |
149 | |
150 | cat >expect <<EOF | |
151 | $Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 Initial Creation | |
152 | $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000 Switch | |
153 | $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000 | |
154 | EOF | |
155 | test_expect_success \ | |
156 | "verifying $m's log" \ | |
188c3827 | 157 | "test_cmp expect .git/logs/$m" |
6de08ae6 SP |
158 | rm -rf .git/$m .git/logs expect |
159 | ||
160 | test_expect_success \ | |
161 | 'enable core.logAllRefUpdates' \ | |
5be60078 JH |
162 | 'git config core.logAllRefUpdates true && |
163 | test true = $(git config --bool --get core.logAllRefUpdates)' | |
6de08ae6 SP |
164 | |
165 | test_expect_success \ | |
166 | "create $m (logged by config)" \ | |
167 | 'GIT_COMMITTER_DATE="2005-05-26 23:32" \ | |
5be60078 | 168 | git update-ref HEAD'" $A "'-m "Initial Creation" && |
8aac4b45 | 169 | test '"$A"' = $(cat .git/'"$m"')' |
6de08ae6 SP |
170 | test_expect_success \ |
171 | "update $m (logged by config)" \ | |
172 | 'GIT_COMMITTER_DATE="2005-05-26 23:33" \ | |
5be60078 | 173 | git update-ref HEAD'" $B $A "'-m "Switch" && |
8aac4b45 | 174 | test '"$B"' = $(cat .git/'"$m"')' |
6de08ae6 SP |
175 | test_expect_success \ |
176 | "set $m (logged by config)" \ | |
177 | 'GIT_COMMITTER_DATE="2005-05-26 23:43" \ | |
5be60078 | 178 | git update-ref HEAD '"$A && |
8aac4b45 | 179 | test $A"' = $(cat .git/'"$m"')' |
6de08ae6 SP |
180 | |
181 | cat >expect <<EOF | |
182 | $Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 +0000 Initial Creation | |
183 | $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 +0000 Switch | |
184 | $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 +0000 | |
185 | EOF | |
186 | test_expect_success \ | |
187 | "verifying $m's log" \ | |
188c3827 | 188 | 'test_cmp expect .git/logs/$m' |
6de08ae6 SP |
189 | rm -f .git/$m .git/logs/$m expect |
190 | ||
5be60078 | 191 | git update-ref $m $D |
e5229042 | 192 | cat >.git/logs/$m <<EOF |
d1a4489a JK |
193 | 0000000000000000000000000000000000000000 $C $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500 |
194 | $C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150350 -0500 | |
e5229042 SP |
195 | $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500 |
196 | $F $Z $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500 | |
197 | $Z $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500 | |
198 | EOF | |
199 | ||
200 | ed="Thu, 26 May 2005 18:32:00 -0500" | |
201 | gd="Thu, 26 May 2005 18:33:00 -0500" | |
202 | ld="Thu, 26 May 2005 18:43:00 -0500" | |
203 | test_expect_success \ | |
cce91a2c | 204 | 'Query "master@{May 25 2005}" (before history)' \ |
2dec68cf | 205 | 'rm -f o e && |
5be60078 | 206 | git rev-parse --verify "master@{May 25 2005}" >o 2>e && |
8aac4b45 | 207 | test '"$C"' = $(cat o) && |
16d7cc90 | 208 | test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"' |
e5229042 | 209 | test_expect_success \ |
cce91a2c | 210 | "Query master@{2005-05-25} (before history)" \ |
2dec68cf | 211 | 'rm -f o e && |
5be60078 | 212 | git rev-parse --verify master@{2005-05-25} >o 2>e && |
8aac4b45 | 213 | test '"$C"' = $(cat o) && |
16d7cc90 | 214 | echo test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"' |
e5229042 | 215 | test_expect_success \ |
cce91a2c | 216 | 'Query "master@{May 26 2005 23:31:59}" (1 second before history)' \ |
2dec68cf | 217 | 'rm -f o e && |
5be60078 | 218 | git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e && |
8aac4b45 | 219 | test '"$C"' = $(cat o) && |
16d7cc90 | 220 | test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"' |
e5229042 | 221 | test_expect_success \ |
cce91a2c | 222 | 'Query "master@{May 26 2005 23:32:00}" (exactly history start)' \ |
2dec68cf | 223 | 'rm -f o e && |
5be60078 | 224 | git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e && |
d1a4489a JK |
225 | test '"$C"' = $(cat o) && |
226 | test "" = "$(cat e)"' | |
227 | test_expect_success \ | |
228 | 'Query "master@{May 26 2005 23:32:30}" (first non-creation change)' \ | |
2dec68cf | 229 | 'rm -f o e && |
d1a4489a | 230 | git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e && |
8aac4b45 | 231 | test '"$A"' = $(cat o) && |
e5229042 SP |
232 | test "" = "$(cat e)"' |
233 | test_expect_success \ | |
cce91a2c | 234 | 'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' \ |
2dec68cf | 235 | 'rm -f o e && |
5be60078 | 236 | git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e && |
8aac4b45 JH |
237 | test '"$B"' = $(cat o) && |
238 | test "warning: Log .git/logs/'"$m has gap after $gd"'." = "$(cat e)"' | |
e5229042 | 239 | test_expect_success \ |
cce91a2c | 240 | 'Query "master@{2005-05-26 23:38:00}" (middle of history)' \ |
2dec68cf | 241 | 'rm -f o e && |
5be60078 | 242 | git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e && |
8aac4b45 | 243 | test '"$Z"' = $(cat o) && |
e5229042 SP |
244 | test "" = "$(cat e)"' |
245 | test_expect_success \ | |
cce91a2c | 246 | 'Query "master@{2005-05-26 23:43:00}" (exact end of history)' \ |
2dec68cf | 247 | 'rm -f o e && |
5be60078 | 248 | git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e && |
8aac4b45 | 249 | test '"$E"' = $(cat o) && |
e5229042 SP |
250 | test "" = "$(cat e)"' |
251 | test_expect_success \ | |
cce91a2c | 252 | 'Query "master@{2005-05-28}" (past end of history)' \ |
2dec68cf | 253 | 'rm -f o e && |
5be60078 | 254 | git rev-parse --verify "master@{2005-05-28}" >o 2>e && |
8aac4b45 JH |
255 | test '"$D"' = $(cat o) && |
256 | test "warning: Log .git/logs/'"$m unexpectedly ended on $ld"'." = "$(cat e)"' | |
e5229042 | 257 | |
cce91a2c SP |
258 | |
259 | rm -f .git/$m .git/logs/$m expect | |
260 | ||
261 | test_expect_success \ | |
262 | 'creating initial files' \ | |
9c7466fa | 263 | 'echo TEST >F && |
5be60078 | 264 | git add F && |
9c7466fa | 265 | GIT_AUTHOR_DATE="2005-05-26 23:30" \ |
0cb0e143 | 266 | GIT_COMMITTER_DATE="2005-05-26 23:30" git commit -m add -a && |
2dec68cf | 267 | h_TEST=$(git rev-parse --verify HEAD) && |
9c7466fa SP |
268 | echo The other day this did not work. >M && |
269 | echo And then Bob told me how to fix it. >>M && | |
270 | echo OTHER >F && | |
271 | GIT_AUTHOR_DATE="2005-05-26 23:41" \ | |
0cb0e143 | 272 | GIT_COMMITTER_DATE="2005-05-26 23:41" git commit -F M -a && |
5be60078 | 273 | h_OTHER=$(git rev-parse --verify HEAD) && |
a3a733e6 | 274 | GIT_AUTHOR_DATE="2005-05-26 23:44" \ |
0cb0e143 | 275 | GIT_COMMITTER_DATE="2005-05-26 23:44" git commit --amend && |
5be60078 | 276 | h_FIXED=$(git rev-parse --verify HEAD) && |
a3a733e6 SP |
277 | echo Merged initial commit and a later commit. >M && |
278 | echo $h_TEST >.git/MERGE_HEAD && | |
279 | GIT_AUTHOR_DATE="2005-05-26 23:45" \ | |
0cb0e143 | 280 | GIT_COMMITTER_DATE="2005-05-26 23:45" git commit -F M && |
d9c8344b | 281 | h_MERGED=$(git rev-parse --verify HEAD) && |
9c7466fa SP |
282 | rm -f M' |
283 | ||
284 | cat >expect <<EOF | |
a3a733e6 | 285 | $Z $h_TEST $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 commit (initial): add |
9c7466fa | 286 | $h_TEST $h_OTHER $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000 commit: The other day this did not work. |
a3a733e6 SP |
287 | $h_OTHER $h_FIXED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151040 +0000 commit (amend): The other day this did not work. |
288 | $h_FIXED $h_MERGED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151100 +0000 commit (merge): Merged initial commit and a later commit. | |
9c7466fa SP |
289 | EOF |
290 | test_expect_success \ | |
0cb0e143 | 291 | 'git commit logged updates' \ |
188c3827 | 292 | "test_cmp expect .git/logs/$m" |
a3a733e6 | 293 | unset h_TEST h_OTHER h_FIXED h_MERGED |
cce91a2c SP |
294 | |
295 | test_expect_success \ | |
5be60078 JH |
296 | 'git cat-file blob master:F (expect OTHER)' \ |
297 | 'test OTHER = $(git cat-file blob master:F)' | |
cce91a2c | 298 | test_expect_success \ |
5be60078 JH |
299 | 'git cat-file blob master@{2005-05-26 23:30}:F (expect TEST)' \ |
300 | 'test TEST = $(git cat-file blob "master@{2005-05-26 23:30}:F")' | |
cce91a2c | 301 | test_expect_success \ |
5be60078 JH |
302 | 'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \ |
303 | 'test OTHER = $(git cat-file blob "master@{2005-05-26 23:42}:F")' | |
cce91a2c | 304 | |
c6268bc0 BK |
305 | a=refs/heads/a |
306 | b=refs/heads/b | |
307 | c=refs/heads/c | |
308 | E='""' | |
309 | F='%s\0' | |
310 | pws='path with space' | |
311 | ||
312 | test_expect_success 'stdin test setup' ' | |
313 | echo "$pws" >"$pws" && | |
314 | git add -- "$pws" && | |
315 | git commit -m "$pws" | |
316 | ' | |
317 | ||
318 | test_expect_success '-z fails without --stdin' ' | |
319 | test_must_fail git update-ref -z $m $m $m 2>err && | |
320 | grep "usage: git update-ref" err | |
321 | ' | |
322 | ||
323 | test_expect_success 'stdin works with no input' ' | |
324 | >stdin && | |
325 | git update-ref --stdin <stdin && | |
326 | git rev-parse --verify -q $m | |
327 | ' | |
328 | ||
329 | test_expect_success 'stdin fails on empty line' ' | |
330 | echo "" >stdin && | |
331 | test_must_fail git update-ref --stdin <stdin 2>err && | |
332 | grep "fatal: empty command in input" err | |
333 | ' | |
334 | ||
335 | test_expect_success 'stdin fails on only whitespace' ' | |
336 | echo " " >stdin && | |
337 | test_must_fail git update-ref --stdin <stdin 2>err && | |
338 | grep "fatal: whitespace before command: " err | |
339 | ' | |
340 | ||
341 | test_expect_success 'stdin fails on leading whitespace' ' | |
342 | echo " create $a $m" >stdin && | |
343 | test_must_fail git update-ref --stdin <stdin 2>err && | |
344 | grep "fatal: whitespace before command: create $a $m" err | |
345 | ' | |
346 | ||
347 | test_expect_success 'stdin fails on unknown command' ' | |
348 | echo "unknown $a" >stdin && | |
349 | test_must_fail git update-ref --stdin <stdin 2>err && | |
350 | grep "fatal: unknown command: unknown $a" err | |
351 | ' | |
352 | ||
20fcffcc | 353 | test_expect_success 'stdin fails on unbalanced quotes' ' |
c6268bc0 BK |
354 | echo "create $a \"master" >stdin && |
355 | test_must_fail git update-ref --stdin <stdin 2>err && | |
356 | grep "fatal: badly quoted argument: \\\"master" err | |
357 | ' | |
358 | ||
20fcffcc MH |
359 | test_expect_success 'stdin fails on invalid escape' ' |
360 | echo "create $a \"ma\zter\"" >stdin && | |
361 | test_must_fail git update-ref --stdin <stdin 2>err && | |
362 | grep "fatal: badly quoted argument: \\\"ma\\\\zter\\\"" err | |
363 | ' | |
364 | ||
697a4151 | 365 | test_expect_success 'stdin fails on junk after quoted argument' ' |
c6268bc0 BK |
366 | echo "create \"$a\"master" >stdin && |
367 | test_must_fail git update-ref --stdin <stdin 2>err && | |
697a4151 | 368 | grep "fatal: unexpected character after quoted argument: \\\"$a\\\"master" err |
c6268bc0 BK |
369 | ' |
370 | ||
371 | test_expect_success 'stdin fails create with no ref' ' | |
372 | echo "create " >stdin && | |
373 | test_must_fail git update-ref --stdin <stdin 2>err && | |
374 | grep "fatal: create line missing <ref>" err | |
375 | ' | |
376 | ||
377 | test_expect_success 'stdin fails create with bad ref name' ' | |
378 | echo "create ~a $m" >stdin && | |
379 | test_must_fail git update-ref --stdin <stdin 2>err && | |
380 | grep "fatal: invalid ref format: ~a" err | |
381 | ' | |
382 | ||
383 | test_expect_success 'stdin fails create with no new value' ' | |
384 | echo "create $a" >stdin && | |
385 | test_must_fail git update-ref --stdin <stdin 2>err && | |
386 | grep "fatal: create $a missing <newvalue>" err | |
387 | ' | |
388 | ||
389 | test_expect_success 'stdin fails create with too many arguments' ' | |
390 | echo "create $a $m $m" >stdin && | |
391 | test_must_fail git update-ref --stdin <stdin 2>err && | |
392 | grep "fatal: create $a has extra input: $m" err | |
393 | ' | |
394 | ||
395 | test_expect_success 'stdin fails update with no ref' ' | |
396 | echo "update " >stdin && | |
397 | test_must_fail git update-ref --stdin <stdin 2>err && | |
398 | grep "fatal: update line missing <ref>" err | |
399 | ' | |
400 | ||
401 | test_expect_success 'stdin fails update with bad ref name' ' | |
402 | echo "update ~a $m" >stdin && | |
403 | test_must_fail git update-ref --stdin <stdin 2>err && | |
404 | grep "fatal: invalid ref format: ~a" err | |
405 | ' | |
406 | ||
407 | test_expect_success 'stdin fails update with no new value' ' | |
408 | echo "update $a" >stdin && | |
409 | test_must_fail git update-ref --stdin <stdin 2>err && | |
410 | grep "fatal: update $a missing <newvalue>" err | |
411 | ' | |
412 | ||
413 | test_expect_success 'stdin fails update with too many arguments' ' | |
414 | echo "update $a $m $m $m" >stdin && | |
415 | test_must_fail git update-ref --stdin <stdin 2>err && | |
416 | grep "fatal: update $a has extra input: $m" err | |
417 | ' | |
418 | ||
419 | test_expect_success 'stdin fails delete with no ref' ' | |
420 | echo "delete " >stdin && | |
421 | test_must_fail git update-ref --stdin <stdin 2>err && | |
422 | grep "fatal: delete line missing <ref>" err | |
423 | ' | |
424 | ||
425 | test_expect_success 'stdin fails delete with bad ref name' ' | |
426 | echo "delete ~a $m" >stdin && | |
427 | test_must_fail git update-ref --stdin <stdin 2>err && | |
428 | grep "fatal: invalid ref format: ~a" err | |
429 | ' | |
430 | ||
431 | test_expect_success 'stdin fails delete with too many arguments' ' | |
432 | echo "delete $a $m $m" >stdin && | |
433 | test_must_fail git update-ref --stdin <stdin 2>err && | |
434 | grep "fatal: delete $a has extra input: $m" err | |
435 | ' | |
436 | ||
437 | test_expect_success 'stdin fails verify with too many arguments' ' | |
438 | echo "verify $a $m $m" >stdin && | |
439 | test_must_fail git update-ref --stdin <stdin 2>err && | |
440 | grep "fatal: verify $a has extra input: $m" err | |
441 | ' | |
442 | ||
443 | test_expect_success 'stdin fails option with unknown name' ' | |
444 | echo "option unknown" >stdin && | |
445 | test_must_fail git update-ref --stdin <stdin 2>err && | |
446 | grep "fatal: option unknown: unknown" err | |
447 | ' | |
448 | ||
449 | test_expect_success 'stdin fails with duplicate refs' ' | |
450 | cat >stdin <<-EOF && | |
451 | create $a $m | |
452 | create $b $m | |
453 | create $a $m | |
454 | EOF | |
455 | test_must_fail git update-ref --stdin <stdin 2>err && | |
456 | grep "fatal: Multiple updates for ref '"'"'$a'"'"' not allowed." err | |
457 | ' | |
458 | ||
459 | test_expect_success 'stdin create ref works' ' | |
460 | echo "create $a $m" >stdin && | |
461 | git update-ref --stdin <stdin && | |
462 | git rev-parse $m >expect && | |
463 | git rev-parse $a >actual && | |
464 | test_cmp expect actual | |
465 | ' | |
466 | ||
20fcffcc MH |
467 | test_expect_success 'stdin succeeds with quoted argument' ' |
468 | git update-ref -d $a && | |
469 | echo "create $a \"$m\"" >stdin && | |
470 | git update-ref --stdin <stdin && | |
471 | git rev-parse $m >expect && | |
472 | git rev-parse $a >actual && | |
473 | test_cmp expect actual | |
474 | ' | |
475 | ||
476 | test_expect_success 'stdin succeeds with escaped character' ' | |
477 | git update-ref -d $a && | |
478 | echo "create $a \"ma\\163ter\"" >stdin && | |
479 | git update-ref --stdin <stdin && | |
480 | git rev-parse $m >expect && | |
481 | git rev-parse $a >actual && | |
482 | test_cmp expect actual | |
483 | ' | |
484 | ||
c6268bc0 BK |
485 | test_expect_success 'stdin update ref creates with zero old value' ' |
486 | echo "update $b $m $Z" >stdin && | |
487 | git update-ref --stdin <stdin && | |
488 | git rev-parse $m >expect && | |
489 | git rev-parse $b >actual && | |
490 | test_cmp expect actual && | |
491 | git update-ref -d $b | |
492 | ' | |
493 | ||
494 | test_expect_success 'stdin update ref creates with empty old value' ' | |
495 | echo "update $b $m $E" >stdin && | |
496 | git update-ref --stdin <stdin && | |
497 | git rev-parse $m >expect && | |
498 | git rev-parse $b >actual && | |
499 | test_cmp expect actual | |
500 | ' | |
501 | ||
502 | test_expect_success 'stdin create ref works with path with space to blob' ' | |
503 | echo "create refs/blobs/pws \"$m:$pws\"" >stdin && | |
504 | git update-ref --stdin <stdin && | |
505 | git rev-parse "$m:$pws" >expect && | |
506 | git rev-parse refs/blobs/pws >actual && | |
507 | test_cmp expect actual && | |
508 | git update-ref -d refs/blobs/pws | |
509 | ' | |
510 | ||
511 | test_expect_success 'stdin update ref fails with wrong old value' ' | |
512 | echo "update $c $m $m~1" >stdin && | |
513 | test_must_fail git update-ref --stdin <stdin 2>err && | |
514 | grep "fatal: Cannot lock the ref '"'"'$c'"'"'" err && | |
515 | test_must_fail git rev-parse --verify -q $c | |
516 | ' | |
517 | ||
518 | test_expect_success 'stdin update ref fails with bad old value' ' | |
519 | echo "update $c $m does-not-exist" >stdin && | |
520 | test_must_fail git update-ref --stdin <stdin 2>err && | |
9255f059 | 521 | grep "fatal: update $c: invalid <oldvalue>: does-not-exist" err && |
c6268bc0 BK |
522 | test_must_fail git rev-parse --verify -q $c |
523 | ' | |
524 | ||
525 | test_expect_success 'stdin create ref fails with bad new value' ' | |
526 | echo "create $c does-not-exist" >stdin && | |
527 | test_must_fail git update-ref --stdin <stdin 2>err && | |
9255f059 | 528 | grep "fatal: create $c: invalid <newvalue>: does-not-exist" err && |
c6268bc0 BK |
529 | test_must_fail git rev-parse --verify -q $c |
530 | ' | |
531 | ||
532 | test_expect_success 'stdin create ref fails with zero new value' ' | |
533 | echo "create $c " >stdin && | |
534 | test_must_fail git update-ref --stdin <stdin 2>err && | |
9255f059 | 535 | grep "fatal: create $c given zero <newvalue>" err && |
c6268bc0 BK |
536 | test_must_fail git rev-parse --verify -q $c |
537 | ' | |
538 | ||
539 | test_expect_success 'stdin update ref works with right old value' ' | |
540 | echo "update $b $m~1 $m" >stdin && | |
541 | git update-ref --stdin <stdin && | |
542 | git rev-parse $m~1 >expect && | |
543 | git rev-parse $b >actual && | |
544 | test_cmp expect actual | |
545 | ' | |
546 | ||
547 | test_expect_success 'stdin delete ref fails with wrong old value' ' | |
548 | echo "delete $a $m~1" >stdin && | |
549 | test_must_fail git update-ref --stdin <stdin 2>err && | |
550 | grep "fatal: Cannot lock the ref '"'"'$a'"'"'" err && | |
551 | git rev-parse $m >expect && | |
552 | git rev-parse $a >actual && | |
553 | test_cmp expect actual | |
554 | ' | |
555 | ||
556 | test_expect_success 'stdin delete ref fails with zero old value' ' | |
557 | echo "delete $a " >stdin && | |
558 | test_must_fail git update-ref --stdin <stdin 2>err && | |
9255f059 | 559 | grep "fatal: delete $a given zero <oldvalue>" err && |
c6268bc0 BK |
560 | git rev-parse $m >expect && |
561 | git rev-parse $a >actual && | |
562 | test_cmp expect actual | |
563 | ' | |
564 | ||
565 | test_expect_success 'stdin update symref works option no-deref' ' | |
566 | git symbolic-ref TESTSYMREF $b && | |
567 | cat >stdin <<-EOF && | |
568 | option no-deref | |
569 | update TESTSYMREF $a $b | |
570 | EOF | |
571 | git update-ref --stdin <stdin && | |
572 | git rev-parse TESTSYMREF >expect && | |
573 | git rev-parse $a >actual && | |
574 | test_cmp expect actual && | |
575 | git rev-parse $m~1 >expect && | |
576 | git rev-parse $b >actual && | |
577 | test_cmp expect actual | |
578 | ' | |
579 | ||
580 | test_expect_success 'stdin delete symref works option no-deref' ' | |
581 | git symbolic-ref TESTSYMREF $b && | |
582 | cat >stdin <<-EOF && | |
583 | option no-deref | |
584 | delete TESTSYMREF $b | |
585 | EOF | |
586 | git update-ref --stdin <stdin && | |
587 | test_must_fail git rev-parse --verify -q TESTSYMREF && | |
588 | git rev-parse $m~1 >expect && | |
589 | git rev-parse $b >actual && | |
590 | test_cmp expect actual | |
591 | ' | |
592 | ||
593 | test_expect_success 'stdin delete ref works with right old value' ' | |
594 | echo "delete $b $m~1" >stdin && | |
595 | git update-ref --stdin <stdin && | |
596 | test_must_fail git rev-parse --verify -q $b | |
597 | ' | |
598 | ||
599 | test_expect_success 'stdin update/create/verify combination works' ' | |
600 | cat >stdin <<-EOF && | |
601 | update $a $m | |
602 | create $b $m | |
603 | verify $c | |
604 | EOF | |
605 | git update-ref --stdin <stdin && | |
606 | git rev-parse $m >expect && | |
607 | git rev-parse $a >actual && | |
608 | test_cmp expect actual && | |
609 | git rev-parse $b >actual && | |
610 | test_cmp expect actual && | |
611 | test_must_fail git rev-parse --verify -q $c | |
612 | ' | |
613 | ||
614 | test_expect_success 'stdin update refs works with identity updates' ' | |
615 | cat >stdin <<-EOF && | |
616 | update $a $m $m | |
617 | update $b $m $m | |
618 | update $c $Z $E | |
619 | EOF | |
620 | git update-ref --stdin <stdin && | |
621 | git rev-parse $m >expect && | |
622 | git rev-parse $a >actual && | |
623 | test_cmp expect actual && | |
624 | git rev-parse $b >actual && | |
625 | test_cmp expect actual && | |
626 | test_must_fail git rev-parse --verify -q $c | |
627 | ' | |
628 | ||
629 | test_expect_success 'stdin update refs fails with wrong old value' ' | |
630 | git update-ref $c $m && | |
631 | cat >stdin <<-EOF && | |
632 | update $a $m $m | |
633 | update $b $m $m | |
634 | update $c '' | |
635 | EOF | |
636 | test_must_fail git update-ref --stdin <stdin 2>err && | |
637 | grep "fatal: Cannot lock the ref '"'"'$c'"'"'" err && | |
638 | git rev-parse $m >expect && | |
639 | git rev-parse $a >actual && | |
640 | test_cmp expect actual && | |
641 | git rev-parse $b >actual && | |
642 | test_cmp expect actual && | |
643 | git rev-parse $c >actual && | |
644 | test_cmp expect actual | |
645 | ' | |
646 | ||
647 | test_expect_success 'stdin delete refs works with packed and loose refs' ' | |
648 | git pack-refs --all && | |
649 | git update-ref $c $m~1 && | |
650 | cat >stdin <<-EOF && | |
651 | delete $a $m | |
652 | update $b $Z $m | |
653 | update $c $E $m~1 | |
654 | EOF | |
655 | git update-ref --stdin <stdin && | |
656 | test_must_fail git rev-parse --verify -q $a && | |
657 | test_must_fail git rev-parse --verify -q $b && | |
658 | test_must_fail git rev-parse --verify -q $c | |
659 | ' | |
660 | ||
661 | test_expect_success 'stdin -z works on empty input' ' | |
662 | >stdin && | |
663 | git update-ref -z --stdin <stdin && | |
664 | git rev-parse --verify -q $m | |
665 | ' | |
666 | ||
667 | test_expect_success 'stdin -z fails on empty line' ' | |
668 | echo "" >stdin && | |
669 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
670 | grep "fatal: whitespace before command: " err | |
671 | ' | |
672 | ||
673 | test_expect_success 'stdin -z fails on empty command' ' | |
674 | printf $F "" >stdin && | |
675 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
676 | grep "fatal: empty command in input" err | |
677 | ' | |
678 | ||
679 | test_expect_success 'stdin -z fails on only whitespace' ' | |
680 | printf $F " " >stdin && | |
681 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
682 | grep "fatal: whitespace before command: " err | |
683 | ' | |
684 | ||
685 | test_expect_success 'stdin -z fails on leading whitespace' ' | |
686 | printf $F " create $a" "$m" >stdin && | |
687 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
688 | grep "fatal: whitespace before command: create $a" err | |
689 | ' | |
690 | ||
691 | test_expect_success 'stdin -z fails on unknown command' ' | |
692 | printf $F "unknown $a" >stdin && | |
693 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
694 | grep "fatal: unknown command: unknown $a" err | |
695 | ' | |
696 | ||
697 | test_expect_success 'stdin -z fails create with no ref' ' | |
698 | printf $F "create " >stdin && | |
699 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
700 | grep "fatal: create line missing <ref>" err | |
701 | ' | |
702 | ||
703 | test_expect_success 'stdin -z fails create with bad ref name' ' | |
704 | printf $F "create ~a " "$m" >stdin && | |
705 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
706 | grep "fatal: invalid ref format: ~a " err | |
707 | ' | |
708 | ||
709 | test_expect_success 'stdin -z fails create with no new value' ' | |
710 | printf $F "create $a" >stdin && | |
711 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
712 | grep "fatal: create $a missing <newvalue>" err | |
713 | ' | |
714 | ||
715 | test_expect_success 'stdin -z fails create with too many arguments' ' | |
716 | printf $F "create $a" "$m" "$m" >stdin && | |
717 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
718 | grep "fatal: unknown command: $m" err | |
719 | ' | |
720 | ||
721 | test_expect_success 'stdin -z fails update with no ref' ' | |
722 | printf $F "update " >stdin && | |
723 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
724 | grep "fatal: update line missing <ref>" err | |
725 | ' | |
726 | ||
727 | test_expect_success 'stdin -z fails update with bad ref name' ' | |
728 | printf $F "update ~a" "$m" >stdin && | |
729 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
730 | grep "fatal: invalid ref format: ~a" err | |
731 | ' | |
732 | ||
191f241b MH |
733 | test_expect_success 'stdin -z treats empty new value as zeros' ' |
734 | git update-ref $a $m && | |
735 | printf $F "update $a" "" "" >stdin && | |
736 | git update-ref -z --stdin <stdin && | |
737 | test_must_fail git rev-parse --verify -q $a | |
738 | ' | |
739 | ||
c6268bc0 BK |
740 | test_expect_success 'stdin -z fails update with no new value' ' |
741 | printf $F "update $a" >stdin && | |
742 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
743 | grep "fatal: update $a missing <newvalue>" err | |
744 | ' | |
745 | ||
746 | test_expect_success 'stdin -z fails update with no old value' ' | |
747 | printf $F "update $a" "$m" >stdin && | |
748 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
ac117755 | 749 | grep "fatal: update $a missing <oldvalue>" err |
c6268bc0 BK |
750 | ' |
751 | ||
752 | test_expect_success 'stdin -z fails update with too many arguments' ' | |
753 | printf $F "update $a" "$m" "$m" "$m" >stdin && | |
754 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
755 | grep "fatal: unknown command: $m" err | |
756 | ' | |
757 | ||
758 | test_expect_success 'stdin -z fails delete with no ref' ' | |
759 | printf $F "delete " >stdin && | |
760 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
761 | grep "fatal: delete line missing <ref>" err | |
762 | ' | |
763 | ||
764 | test_expect_success 'stdin -z fails delete with bad ref name' ' | |
765 | printf $F "delete ~a" "$m" >stdin && | |
766 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
767 | grep "fatal: invalid ref format: ~a" err | |
768 | ' | |
769 | ||
770 | test_expect_success 'stdin -z fails delete with no old value' ' | |
771 | printf $F "delete $a" >stdin && | |
772 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
ac117755 | 773 | grep "fatal: delete $a missing <oldvalue>" err |
c6268bc0 BK |
774 | ' |
775 | ||
776 | test_expect_success 'stdin -z fails delete with too many arguments' ' | |
777 | printf $F "delete $a" "$m" "$m" >stdin && | |
778 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
779 | grep "fatal: unknown command: $m" err | |
780 | ' | |
781 | ||
782 | test_expect_success 'stdin -z fails verify with too many arguments' ' | |
783 | printf $F "verify $a" "$m" "$m" >stdin && | |
784 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
785 | grep "fatal: unknown command: $m" err | |
786 | ' | |
787 | ||
788 | test_expect_success 'stdin -z fails verify with no old value' ' | |
789 | printf $F "verify $a" >stdin && | |
790 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
ac117755 | 791 | grep "fatal: verify $a missing <oldvalue>" err |
c6268bc0 BK |
792 | ' |
793 | ||
794 | test_expect_success 'stdin -z fails option with unknown name' ' | |
795 | printf $F "option unknown" >stdin && | |
796 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
797 | grep "fatal: option unknown: unknown" err | |
798 | ' | |
799 | ||
800 | test_expect_success 'stdin -z fails with duplicate refs' ' | |
801 | printf $F "create $a" "$m" "create $b" "$m" "create $a" "$m" >stdin && | |
802 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
803 | grep "fatal: Multiple updates for ref '"'"'$a'"'"' not allowed." err | |
804 | ' | |
805 | ||
806 | test_expect_success 'stdin -z create ref works' ' | |
807 | printf $F "create $a" "$m" >stdin && | |
808 | git update-ref -z --stdin <stdin && | |
809 | git rev-parse $m >expect && | |
810 | git rev-parse $a >actual && | |
811 | test_cmp expect actual | |
812 | ' | |
813 | ||
814 | test_expect_success 'stdin -z update ref creates with zero old value' ' | |
815 | printf $F "update $b" "$m" "$Z" >stdin && | |
816 | git update-ref -z --stdin <stdin && | |
817 | git rev-parse $m >expect && | |
818 | git rev-parse $b >actual && | |
819 | test_cmp expect actual && | |
820 | git update-ref -d $b | |
821 | ' | |
822 | ||
823 | test_expect_success 'stdin -z update ref creates with empty old value' ' | |
824 | printf $F "update $b" "$m" "" >stdin && | |
825 | git update-ref -z --stdin <stdin && | |
826 | git rev-parse $m >expect && | |
827 | git rev-parse $b >actual && | |
828 | test_cmp expect actual | |
829 | ' | |
830 | ||
831 | test_expect_success 'stdin -z create ref works with path with space to blob' ' | |
832 | printf $F "create refs/blobs/pws" "$m:$pws" >stdin && | |
833 | git update-ref -z --stdin <stdin && | |
834 | git rev-parse "$m:$pws" >expect && | |
835 | git rev-parse refs/blobs/pws >actual && | |
836 | test_cmp expect actual && | |
837 | git update-ref -d refs/blobs/pws | |
838 | ' | |
839 | ||
840 | test_expect_success 'stdin -z update ref fails with wrong old value' ' | |
841 | printf $F "update $c" "$m" "$m~1" >stdin && | |
842 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
843 | grep "fatal: Cannot lock the ref '"'"'$c'"'"'" err && | |
844 | test_must_fail git rev-parse --verify -q $c | |
845 | ' | |
846 | ||
847 | test_expect_success 'stdin -z update ref fails with bad old value' ' | |
848 | printf $F "update $c" "$m" "does-not-exist" >stdin && | |
849 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
9255f059 | 850 | grep "fatal: update $c: invalid <oldvalue>: does-not-exist" err && |
c6268bc0 BK |
851 | test_must_fail git rev-parse --verify -q $c |
852 | ' | |
853 | ||
854 | test_expect_success 'stdin -z create ref fails with bad new value' ' | |
855 | printf $F "create $c" "does-not-exist" >stdin && | |
856 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
9255f059 | 857 | grep "fatal: create $c: invalid <newvalue>: does-not-exist" err && |
c6268bc0 BK |
858 | test_must_fail git rev-parse --verify -q $c |
859 | ' | |
860 | ||
3afcc463 | 861 | test_expect_success 'stdin -z create ref fails with empty new value' ' |
c6268bc0 BK |
862 | printf $F "create $c" "" >stdin && |
863 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
b984d333 | 864 | grep "fatal: create $c missing <newvalue>" err && |
c6268bc0 BK |
865 | test_must_fail git rev-parse --verify -q $c |
866 | ' | |
867 | ||
868 | test_expect_success 'stdin -z update ref works with right old value' ' | |
869 | printf $F "update $b" "$m~1" "$m" >stdin && | |
870 | git update-ref -z --stdin <stdin && | |
871 | git rev-parse $m~1 >expect && | |
872 | git rev-parse $b >actual && | |
873 | test_cmp expect actual | |
874 | ' | |
875 | ||
876 | test_expect_success 'stdin -z delete ref fails with wrong old value' ' | |
877 | printf $F "delete $a" "$m~1" >stdin && | |
878 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
879 | grep "fatal: Cannot lock the ref '"'"'$a'"'"'" err && | |
880 | git rev-parse $m >expect && | |
881 | git rev-parse $a >actual && | |
882 | test_cmp expect actual | |
883 | ' | |
884 | ||
885 | test_expect_success 'stdin -z delete ref fails with zero old value' ' | |
886 | printf $F "delete $a" "$Z" >stdin && | |
887 | test_must_fail git update-ref -z --stdin <stdin 2>err && | |
9255f059 | 888 | grep "fatal: delete $a given zero <oldvalue>" err && |
c6268bc0 BK |
889 | git rev-parse $m >expect && |
890 | git rev-parse $a >actual && | |
891 | test_cmp expect actual | |
892 | ' | |
893 | ||
894 | test_expect_success 'stdin -z update symref works option no-deref' ' | |
895 | git symbolic-ref TESTSYMREF $b && | |
896 | printf $F "option no-deref" "update TESTSYMREF" "$a" "$b" >stdin && | |
897 | git update-ref -z --stdin <stdin && | |
898 | git rev-parse TESTSYMREF >expect && | |
899 | git rev-parse $a >actual && | |
900 | test_cmp expect actual && | |
901 | git rev-parse $m~1 >expect && | |
902 | git rev-parse $b >actual && | |
903 | test_cmp expect actual | |
904 | ' | |
905 | ||
906 | test_expect_success 'stdin -z delete symref works option no-deref' ' | |
907 | git symbolic-ref TESTSYMREF $b && | |
908 | printf $F "option no-deref" "delete TESTSYMREF" "$b" >stdin && | |
909 | git update-ref -z --stdin <stdin && | |
910 | test_must_fail git rev-parse --verify -q TESTSYMREF && | |
911 | git rev-parse $m~1 >expect && | |
912 | git rev-parse $b >actual && | |
913 | test_cmp expect actual | |
914 | ' | |
915 | ||
916 | test_expect_success 'stdin -z delete ref works with right old value' ' | |
917 | printf $F "delete $b" "$m~1" >stdin && | |
918 | git update-ref -z --stdin <stdin && | |
919 | test_must_fail git rev-parse --verify -q $b | |
920 | ' | |
921 | ||
922 | test_expect_success 'stdin -z update/create/verify combination works' ' | |
923 | printf $F "update $a" "$m" "" "create $b" "$m" "verify $c" "" >stdin && | |
924 | git update-ref -z --stdin <stdin && | |
925 | git rev-parse $m >expect && | |
926 | git rev-parse $a >actual && | |
927 | test_cmp expect actual && | |
928 | git rev-parse $b >actual && | |
929 | test_cmp expect actual && | |
930 | test_must_fail git rev-parse --verify -q $c | |
931 | ' | |
932 | ||
933 | test_expect_success 'stdin -z update refs works with identity updates' ' | |
934 | printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$Z" "" >stdin && | |
935 | git update-ref -z --stdin <stdin && | |
936 | git rev-parse $m >expect && | |
937 | git rev-parse $a >actual && | |
938 | test_cmp expect actual && | |
939 | git rev-parse $b >actual && | |
940 | test_cmp expect actual && | |
941 | test_must_fail git rev-parse --verify -q $c | |
942 | ' | |
943 | ||
944 | test_expect_success 'stdin -z update refs fails with wrong old value' ' | |
945 | git update-ref $c $m && | |
c1329110 | 946 | printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$m" "$Z" >stdin && |
c6268bc0 BK |
947 | test_must_fail git update-ref -z --stdin <stdin 2>err && |
948 | grep "fatal: Cannot lock the ref '"'"'$c'"'"'" err && | |
949 | git rev-parse $m >expect && | |
950 | git rev-parse $a >actual && | |
951 | test_cmp expect actual && | |
952 | git rev-parse $b >actual && | |
953 | test_cmp expect actual && | |
954 | git rev-parse $c >actual && | |
955 | test_cmp expect actual | |
956 | ' | |
957 | ||
958 | test_expect_success 'stdin -z delete refs works with packed and loose refs' ' | |
959 | git pack-refs --all && | |
960 | git update-ref $c $m~1 && | |
961 | printf $F "delete $a" "$m" "update $b" "$Z" "$m" "update $c" "" "$m~1" >stdin && | |
962 | git update-ref -z --stdin <stdin && | |
963 | test_must_fail git rev-parse --verify -q $a && | |
964 | test_must_fail git rev-parse --verify -q $b && | |
965 | test_must_fail git rev-parse --verify -q $c | |
966 | ' | |
967 | ||
6de08ae6 | 968 | test_done |