]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5541-http-push-smart.sh
Merge branch 'rs/bisect-start-leakfix' into maint-2.38
[thirdparty/git.git] / t / t5541-http-push-smart.sh
CommitLineData
7da4e228
SP
1#!/bin/sh
2#
3# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
4#
5
6test_description='test smart pushing over http via http-backend'
028cb644 7GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
8export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9
7da4e228
SP
10. ./test-lib.sh
11
7da4e228 12ROOT_PATH="$PWD"
0ea47f9d 13. "$TEST_DIRECTORY"/lib-gpg.sh
7da4e228 14. "$TEST_DIRECTORY"/lib-httpd.sh
d336572f 15. "$TEST_DIRECTORY"/lib-terminal.sh
7da4e228
SP
16start_httpd
17
18test_expect_success 'setup remote repository' '
19 cd "$ROOT_PATH" &&
20 mkdir test_repo &&
21 cd test_repo &&
22 git init &&
23 : >path1 &&
24 git add path1 &&
25 test_tick &&
26 git commit -m initial &&
27 cd - &&
28 git clone --bare test_repo test_repo.git &&
29 cd test_repo.git &&
30 git config http.receivepack true &&
e32a4581 31 git config core.logallrefupdates true &&
7da4e228
SP
32 ORIG_HEAD=$(git rev-parse --verify HEAD) &&
33 cd - &&
34 mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
35'
36
6ac2b3ae
JK
37setup_askpass_helper
38
9ee6bcd3
TRC
39cat >exp <<EOF
40GET /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
41POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200
42EOF
d8fab072 43test_expect_success 'no empty path components' '
a704c643
SG
44 # Clear the log, so that it does not affect the "used receive-pack
45 # service" test which reads the log too.
46 test_when_finished ">\"\$HTTPD_ROOT_PATH\"/access.log" &&
47
9ee6bcd3
TRC
48 # In the URL, add a trailing slash, and see if git appends yet another
49 # slash.
7da4e228 50 cd "$ROOT_PATH" &&
9ee6bcd3
TRC
51 git clone $HTTPD_URL/smart/test_repo.git/ test_repo_clone &&
52
d790ee17
JT
53 # NEEDSWORK: If the overspecification of the expected result is reduced, we
54 # might be able to run this test in all protocol versions.
8a1b0978 55 if test "$GIT_TEST_PROTOCOL_VERSION" = 0
d790ee17
JT
56 then
57 check_access_log exp
58 fi
9ee6bcd3
TRC
59'
60
61test_expect_success 'clone remote repository' '
62 rm -rf test_repo_clone &&
f2c2c901
MM
63 git clone $HTTPD_URL/smart/test_repo.git test_repo_clone &&
64 (
65 cd test_repo_clone && git config push.default matching
66 )
7da4e228
SP
67'
68
0cc6330d 69test_expect_success 'push to remote repository (standard)' '
7da4e228
SP
70 cd "$ROOT_PATH"/test_repo_clone &&
71 : >path2 &&
72 git add path2 &&
73 test_tick &&
74 git commit -m path2 &&
75 HEAD=$(git rev-parse --verify HEAD) &&
4eee6c6d 76 GIT_TRACE_CURL=true git push -v -v 2>err &&
0cc6330d
TRC
77 ! grep "Expect: 100-continue" err &&
78 grep "POST git-receive-pack ([0-9]* bytes)" err &&
7da4e228
SP
79 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
80 test $HEAD = $(git rev-parse --verify HEAD))
81'
82
b0c4adcd
LL
83test_expect_success 'push to remote repository (standard) with sending Accept-Language' '
84 cat >exp <<-\EOF &&
85 => Send header: Accept-Language: ko-KR, *;q=0.9
86 => Send header: Accept-Language: ko-KR, *;q=0.9
87 EOF
88
89 cd "$ROOT_PATH"/test_repo_clone &&
90 : >path_lang &&
91 git add path_lang &&
92 test_tick &&
93 git commit -m path_lang &&
94 HEAD=$(git rev-parse --verify HEAD) &&
95 GIT_TRACE_CURL=true LANGUAGE="ko_KR.UTF-8" git push -v -v 2>err &&
96 ! grep "Expect: 100-continue" err &&
97
98 grep "=> Send header: Accept-Language:" err >err.language &&
99 test_cmp exp err.language
100'
101
7da4e228
SP
102test_expect_success 'push already up-to-date' '
103 git push
104'
105
106test_expect_success 'create and delete remote branch' '
107 cd "$ROOT_PATH"/test_repo_clone &&
108 git checkout -b dev &&
109 : >path3 &&
110 git add path3 &&
111 test_tick &&
112 git commit -m dev &&
113 git push origin dev &&
114 git push origin :dev &&
115 test_must_fail git show-ref --verify refs/remotes/origin/dev
116'
117
c36c6285
ÆAB
118test_expect_success 'setup rejected update hook' '
119 test_hook --setup -C "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" update <<-\EOF &&
120 exit 1
121 EOF
5238cbf6 122
c36c6285
ÆAB
123 cat >exp <<-EOF
124 remote: error: hook declined to update refs/heads/dev2
125 To http://127.0.0.1:$LIB_HTTPD_PORT/smart/test_repo.git
126 ! [remote rejected] dev2 -> dev2 (hook declined)
127 error: failed to push some refs to '\''http://127.0.0.1:$LIB_HTTPD_PORT/smart/test_repo.git'\''
128 EOF
129'
5238cbf6
SP
130
131test_expect_success 'rejected update prints status' '
132 cd "$ROOT_PATH"/test_repo_clone &&
133 git checkout -b dev2 &&
134 : >path4 &&
135 git add path4 &&
136 test_tick &&
137 git commit -m dev2 &&
138 test_must_fail git push origin dev2 2>act &&
139 sed -e "/^remote: /s/ *$//" <act >cmp &&
1108cea7 140 test_cmp exp cmp
5238cbf6
SP
141'
142rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update"
143
7da4e228
SP
144cat >exp <<EOF
145GET /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
146POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200
147GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
148POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
149GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
150GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
151POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
152GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
153POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
5238cbf6
SP
154GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
155POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
7da4e228
SP
156EOF
157test_expect_success 'used receive-pack service' '
d790ee17
JT
158 # NEEDSWORK: If the overspecification of the expected result is reduced, we
159 # might be able to run this test in all protocol versions.
8a1b0978 160 if test "$GIT_TEST_PROTOCOL_VERSION" = 0
d790ee17
JT
161 then
162 check_access_log exp
163 fi
7da4e228
SP
164'
165
6cbd6e92 166test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
028cb644 167 "$ROOT_PATH"/test_repo_clone main success
19452374 168
08d63a42 169test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper' '
7b69079b
TRC
170 # create a dissimilarly-named remote ref so that git is unable to match the
171 # two refs (viz. local, remote) unless an explicit refspec is provided.
028cb644 172 git push origin main:niam &&
7b69079b
TRC
173
174 echo "change changed" > path2 &&
175 git commit -a -m path2 --amend &&
176
028cb644 177 # push main too; this ensures there is at least one '"'push'"' command to
7b69079b 178 # the remote helper and triggers interaction with the helper.
028cb644 179 test_must_fail git push -v origin +main main:niam >output 2>&1'
7b69079b 180
b32227e7 181test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper: remote output' '
028cb644
JS
182 grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *main -> main (forced update)$" output &&
183 grep "^ ! \[rejected\] *main -> niam (non-fast-forward)$" output
b32227e7 184'
7b69079b 185
b3e1900a 186test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper: our output' '
0aff719f 187 test_i18ngrep "Updates were rejected because" \
9567f082 188 output
7b69079b
TRC
189'
190
0cc6330d 191test_expect_success 'push (chunked)' '
028cb644 192 git checkout main &&
0cc6330d
TRC
193 test_commit commit path3 &&
194 HEAD=$(git rev-parse --verify HEAD) &&
8677b777 195 test_config http.postbuffer 4 &&
0cc6330d
TRC
196 git push -v -v origin $BRANCH 2>err &&
197 grep "POST git-receive-pack (chunked)" err &&
198 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
199 test $HEAD = $(git rev-parse --verify HEAD))
200'
201
028cb644
JS
202## References of remote: atomic1(1) main(2) collateral(2) other(2)
203## References of local : atomic2(2) main(1) collateral(3) other(2) collateral1(3) atomic(1)
204## Atomic push : main(1) collateral(3) atomic(1)
f38b1684 205test_expect_success 'push --atomic also prevents branch creation, reports collateral' '
3bca1e7f
ES
206 # Setup upstream repo - empty for now
207 d=$HTTPD_DOCUMENT_ROOT_PATH/atomic-branches.git &&
208 git init --bare "$d" &&
209 test_config -C "$d" http.receivepack true &&
210 up="$HTTPD_URL"/smart/atomic-branches.git &&
211
6f119424 212 # Tell "$up" about three branches for now
3bca1e7f
ES
213 test_commit atomic1 &&
214 test_commit atomic2 &&
215 git branch collateral &&
6f119424 216 git branch other &&
028cb644 217 git push "$up" atomic1 main collateral other &&
f38b1684 218 git tag -d atomic1 &&
3bca1e7f
ES
219
220 # collateral is a valid push, but should be failed by atomic push
221 git checkout collateral &&
222 test_commit collateral1 &&
223
028cb644
JS
224 # Make main incompatible with upstream to provoke atomic
225 git checkout main &&
3bca1e7f
ES
226 git reset --hard HEAD^ &&
227
228 # Add a new branch which should be failed by atomic push. This is a
229 # regression case.
230 git branch atomic &&
231
232 # --atomic should cause entire push to be rejected
028cb644 233 test_must_fail git push --atomic "$up" main atomic collateral 2>output &&
3bca1e7f
ES
234
235 # the new branch should not have been created upstream
236 test_must_fail git -C "$d" show-ref --verify refs/heads/atomic &&
237
238 # upstream should still reflect atomic2, the last thing we pushed
239 # successfully
240 git rev-parse atomic2 >expected &&
028cb644
JS
241 # on main...
242 git -C "$d" rev-parse refs/heads/main >actual &&
3bca1e7f
ES
243 test_cmp expected actual &&
244 # ...and collateral.
245 git -C "$d" rev-parse refs/heads/collateral >actual &&
246 test_cmp expected actual &&
247
248 # the failed refs should be indicated to the user
028cb644 249 grep "^ ! .*rejected.* main -> main" output &&
3bca1e7f
ES
250
251 # the collateral failure refs should be indicated to the user
252 grep "^ ! .*rejected.* atomic -> atomic .*atomic push failed" output &&
f38b1684
JX
253 grep "^ ! .*rejected.* collateral -> collateral .*atomic push failed" output &&
254
255 # never report what we do not push
256 ! grep "^ ! .*rejected.* atomic1 " output &&
257 ! grep "^ ! .*rejected.* other " output
3bca1e7f
ES
258'
259
6f119424 260test_expect_success 'push --atomic fails on server-side errors' '
261 # Use previously set up repository
262 d=$HTTPD_DOCUMENT_ROOT_PATH/atomic-branches.git &&
263 test_config -C "$d" http.receivepack true &&
264 up="$HTTPD_URL"/smart/atomic-branches.git &&
265
266 # break ref updates for other on the remote site
267 mkdir "$d/refs/heads/other.lock" &&
268
269 # add the new commit to other
270 git branch -f other collateral &&
271
272 # --atomic should cause entire push to be rejected
273 test_must_fail git push --atomic "$up" atomic other 2>output &&
274
275 # the new branch should not have been created upstream
276 test_must_fail git -C "$d" show-ref --verify refs/heads/atomic &&
277
278 # upstream should still reflect atomic2, the last thing we pushed
279 # successfully
280 git rev-parse atomic2 >expected &&
281 # ...to other.
282 git -C "$d" rev-parse refs/heads/other >actual &&
283 test_cmp expected actual &&
284
285 # the new branch should not have been created upstream
286 test_must_fail git -C "$d" show-ref --verify refs/heads/atomic &&
287
288 # the failed refs should be indicated to the user
289 grep "^ ! .*rejected.* other -> other .*atomic transaction failed" output &&
290
291 # the collateral failure refs should be indicated to the user
292 grep "^ ! .*rejected.* atomic -> atomic .*atomic transaction failed" output
293'
294
02f79147
JK
295test_expect_success 'push --all can push to empty repo' '
296 d=$HTTPD_DOCUMENT_ROOT_PATH/empty-all.git &&
297 git init --bare "$d" &&
298 git --git-dir="$d" config http.receivepack true &&
299 git push --all "$HTTPD_URL"/smart/empty-all.git
300'
301
302test_expect_success 'push --mirror can push to empty repo' '
303 d=$HTTPD_DOCUMENT_ROOT_PATH/empty-mirror.git &&
304 git init --bare "$d" &&
305 git --git-dir="$d" config http.receivepack true &&
306 git push --mirror "$HTTPD_URL"/smart/empty-mirror.git
307'
308
309test_expect_success 'push --all to repo with alternates' '
310 s=$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git &&
311 d=$HTTPD_DOCUMENT_ROOT_PATH/alternates-all.git &&
312 git clone --bare --shared "$s" "$d" &&
313 git --git-dir="$d" config http.receivepack true &&
314 git --git-dir="$d" repack -adl &&
315 git push --all "$HTTPD_URL"/smart/alternates-all.git
316'
317
318test_expect_success 'push --mirror to repo with alternates' '
319 s=$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git &&
320 d=$HTTPD_DOCUMENT_ROOT_PATH/alternates-mirror.git &&
321 git clone --bare --shared "$s" "$d" &&
322 git --git-dir="$d" config http.receivepack true &&
323 git --git-dir="$d" repack -adl &&
324 git push --mirror "$HTTPD_URL"/smart/alternates-mirror.git
325'
326
e304aeba
JK
327test_expect_success TTY 'push shows progress when stderr is a tty' '
328 cd "$ROOT_PATH"/test_repo_clone &&
329 test_commit noisy &&
330 test_terminal git push >output 2>&1 &&
bbf47568 331 test_i18ngrep "^Writing objects" output
e304aeba
JK
332'
333
334test_expect_success TTY 'push --quiet silences status and progress' '
c207e34f
CB
335 cd "$ROOT_PATH"/test_repo_clone &&
336 test_commit quiet &&
e304aeba 337 test_terminal git push --quiet >output 2>&1 &&
ec21ac8c 338 test_must_be_empty output
c207e34f
CB
339'
340
e304aeba
JK
341test_expect_success TTY 'push --no-progress silences progress but not status' '
342 cd "$ROOT_PATH"/test_repo_clone &&
343 test_commit no-progress &&
344 test_terminal git push --no-progress >output 2>&1 &&
415c7dd0 345 test_i18ngrep "^To http" output &&
bbf47568 346 test_i18ngrep ! "^Writing objects" output
e304aeba
JK
347'
348
349test_expect_success 'push --progress shows progress to non-tty' '
350 cd "$ROOT_PATH"/test_repo_clone &&
351 test_commit progress &&
352 git push --progress >output 2>&1 &&
415c7dd0 353 test_i18ngrep "^To http" output &&
bbf47568 354 test_i18ngrep "^Writing objects" output
e304aeba
JK
355'
356
e32a4581
JK
357test_expect_success 'http push gives sane defaults to reflog' '
358 cd "$ROOT_PATH"/test_repo_clone &&
359 test_commit reflog-test &&
360 git push "$HTTPD_URL"/smart/test_repo.git &&
361 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
362 log -g -1 --format="%gn <%ge>" >actual &&
363 echo "anonymous <anonymous@http.127.0.0.1>" >expect &&
364 test_cmp expect actual
365'
366
367test_expect_success 'http push respects GIT_COMMITTER_* in reflog' '
368 cd "$ROOT_PATH"/test_repo_clone &&
369 test_commit custom-reflog-test &&
370 git push "$HTTPD_URL"/smart_custom_env/test_repo.git &&
371 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
372 log -g -1 --format="%gn <%ge>" >actual &&
373 echo "Custom User <custom@example.com>" >expect &&
374 test_cmp expect actual
375'
376
6ac2b3ae
JK
377test_expect_success 'push over smart http with auth' '
378 cd "$ROOT_PATH/test_repo_clone" &&
379 echo push-auth-test >expect &&
380 test_commit push-auth-test &&
afbf5ca5 381 set_askpass user@host pass@host &&
6ac2b3ae
JK
382 git push "$HTTPD_URL"/auth/smart/test_repo.git &&
383 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
384 log -1 --format=%s >actual &&
385 expect_askpass both user@host &&
386 test_cmp expect actual
387'
388
b81401c1 389test_expect_success 'push to auth-only-for-push repo' '
4c71009d
JK
390 cd "$ROOT_PATH/test_repo_clone" &&
391 echo push-half-auth >expect &&
392 test_commit push-half-auth &&
afbf5ca5 393 set_askpass user@host pass@host &&
4c71009d
JK
394 git push "$HTTPD_URL"/auth-push/smart/test_repo.git &&
395 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
396 log -1 --format=%s >actual &&
397 expect_askpass both user@host &&
398 test_cmp expect actual
399'
400
b0808819
JK
401test_expect_success 'create repo without http.receivepack set' '
402 cd "$ROOT_PATH" &&
403 git init half-auth &&
404 (
405 cd half-auth &&
406 test_commit one
407 ) &&
408 git clone --bare half-auth "$HTTPD_DOCUMENT_ROOT_PATH/half-auth.git"
409'
410
411test_expect_success 'clone via half-auth-complete does not need password' '
412 cd "$ROOT_PATH" &&
413 set_askpass wrong &&
414 git clone "$HTTPD_URL"/half-auth-complete/smart/half-auth.git \
415 half-auth-clone &&
416 expect_askpass none
417'
418
419test_expect_success 'push into half-auth-complete requires password' '
420 cd "$ROOT_PATH/half-auth-clone" &&
421 echo two >expect &&
422 test_commit two &&
afbf5ca5 423 set_askpass user@host pass@host &&
b0808819
JK
424 git push "$HTTPD_URL/half-auth-complete/smart/half-auth.git" &&
425 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/half-auth.git" \
426 log -1 --format=%s >actual &&
427 expect_askpass both user@host &&
428 test_cmp expect actual
429'
430
26be19ba
JK
431test_expect_success CMDLINE_LIMIT 'push 2000 tags over http' '
432 sha1=$(git rev-parse HEAD) &&
433 test_seq 2000 |
434 sort |
435 sed "s|.*|$sha1 refs/tags/really-long-tag-name-&|" \
436 >.git/packed-refs &&
437 run_with_limited_cmdline git push --mirror
438'
439
0ea47f9d 440test_expect_success GPG 'push with post-receive to inspect certificate' '
f6db603c 441 test_hook -C "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git post-receive <<-\EOF &&
0ea47f9d
JH
442 # discard the update list
443 cat >/dev/null
444 # record the push certificate
445 if test -n "${GIT_PUSH_CERT-}"
446 then
447 git cat-file blob $GIT_PUSH_CERT >../push-cert
448 fi &&
449 cat >../push-cert-status <<E_O_F
450 SIGNER=${GIT_PUSH_CERT_SIGNER-nobody}
451 KEY=${GIT_PUSH_CERT_KEY-nokey}
452 STATUS=${GIT_PUSH_CERT_STATUS-nostatus}
5732373d
JH
453 NONCE_STATUS=${GIT_PUSH_CERT_NONCE_STATUS-nononcestatus}
454 NONCE=${GIT_PUSH_CERT_NONCE-nononce}
0ea47f9d 455 E_O_F
f6db603c
ÆAB
456 EOF
457 (
458 cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
5732373d
JH
459 git config receive.certnonceseed sekrit &&
460 git config receive.certnonceslop 30
0ea47f9d
JH
461 ) &&
462 cd "$ROOT_PATH/test_repo_clone" &&
463 test_commit cert-test &&
464 git push --signed "$HTTPD_URL/smart/test_repo.git" &&
465 (
466 cd "$HTTPD_DOCUMENT_ROOT_PATH" &&
5732373d 467 cat <<-\EOF &&
0ea47f9d
JH
468 SIGNER=C O Mitter <committer@example.com>
469 KEY=13B6F51ECDDE430D
470 STATUS=G
5732373d 471 NONCE_STATUS=OK
0ea47f9d 472 EOF
5732373d 473 sed -n -e "s/^nonce /NONCE=/p" -e "/^$/q" push-cert
0ea47f9d
JH
474 ) >expect &&
475 test_cmp expect "$HTTPD_DOCUMENT_ROOT_PATH/push-cert-status"
476'
477
882d49ca 478test_expect_success 'push status output scrubs password' '
68f3c079
JK
479 cd "$ROOT_PATH/test_repo_clone" &&
480 git push --porcelain \
481 "$HTTPD_URL_USER_PASS/smart/test_repo.git" \
482 +HEAD:scrub >status &&
882d49ca
JK
483 # should have been scrubbed down to vanilla URL
484 grep "^To $HTTPD_URL/smart/test_repo.git" status
485'
486
46da295a
JS
487test_expect_success 'clone/fetch scrubs password from reflogs' '
488 cd "$ROOT_PATH" &&
489 git clone "$HTTPD_URL_USER_PASS/smart/test_repo.git" \
490 reflog-test &&
491 cd reflog-test &&
492 test_commit prepare-for-force-fetch &&
493 git switch -c away &&
494 git fetch "$HTTPD_URL_USER_PASS/smart/test_repo.git" \
028cb644 495 +main:main &&
46da295a 496 # should have been scrubbed down to vanilla URL
028cb644 497 git log -g main >reflog &&
46da295a
JS
498 grep "$HTTPD_URL" reflog &&
499 ! grep "$HTTPD_URL_USER_PASS" reflog
500'
501
cd85b447 502test_expect_success 'Non-ASCII branch name can be used with --force-with-lease' '
503 cd "$ROOT_PATH" &&
504 git clone "$HTTPD_URL_USER_PASS/smart/test_repo.git" non-ascii &&
505 cd non-ascii &&
506 git checkout -b rama-de-árbol &&
507 test_commit F &&
508 git push --force-with-lease origin rama-de-árbol &&
509 git ls-remote origin refs/heads/rama-de-árbol >actual &&
510 git ls-remote . refs/heads/rama-de-árbol >expect &&
511 test_cmp expect actual &&
512 git push --delete --force-with-lease origin rama-de-árbol &&
513 git ls-remote origin refs/heads/rama-de-árbol >actual &&
514 test_must_be_empty actual
515'
516
8301266a
JS
517test_expect_success 'colorize errors/hints' '
518 cd "$ROOT_PATH"/test_repo_clone &&
519 test_must_fail git -c color.transport=always -c color.advice=always \
520 -c color.push=always \
028cb644 521 push origin origin/main^:main 2>act &&
8301266a
JS
522 test_decode_color <act >decoded &&
523 test_i18ngrep "<RED>.*rejected.*<RESET>" decoded &&
524 test_i18ngrep "<RED>error: failed to push some refs" decoded &&
525 test_i18ngrep "<YELLOW>hint: " decoded &&
526 test_i18ngrep ! "^hint: " decoded
527'
528
e4c9538a
JK
529test_expect_success 'report error server does not provide ref status' '
530 git init "$HTTPD_DOCUMENT_ROOT_PATH/no_report" &&
531 git -C "$HTTPD_DOCUMENT_ROOT_PATH/no_report" config http.receivepack true &&
532 test_must_fail git push --porcelain \
533 $HTTPD_URL_USER_PASS/smart/no_report \
534 HEAD:refs/tags/will-fail >actual &&
535 test_must_fail git -C "$HTTPD_DOCUMENT_ROOT_PATH/no_report" \
536 rev-parse --verify refs/tags/will-fail &&
537 cat >expect <<-EOF &&
538 To $HTTPD_URL/smart/no_report
c5c3486f 539 ! HEAD:refs/tags/will-fail [remote failure] (remote failed to report status)
e4c9538a
JK
540 Done
541 EOF
542 test_cmp expect actual
543'
544
7da4e228 545test_done