http tests: use "test_hook" for "smart" and "dumb" http tests

Change the http tests to use "test_hook" insteadd of "write_script". In both cases we can get rid of sub-shelling. For "t/t5550-http-fetch-dumb.sh" add a trivial helper which sets up the hook and calls "update-server-info". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Mar 17, 2022 at 11:13 UTC f6db603c7a051d9d0d1ce135673ce77a5b8b7a4c
2 files changed +14 -21
t/t5541-http-push-smart.sh
+4 -6
@@ -419,10 +419,7 @@ test_expect_success CMDLINE_LIMIT 'push 2000 tags over http' '
419 '
420
421 test_expect_success GPG 'push with post-receive to inspect certificate' '
422 - (
423 - cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
424 - mkdir -p hooks &&
425 - write_script hooks/post-receive <<-\EOF &&
422 + test_hook -C "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git post-receive <<-\EOF &&
423 # discard the update list
424 cat >/dev/null
425 # record the push certificate
@@ -437,8 +434,9 @@ test_expect_success GPG 'push with post-receive to inspect certificate' '
434 NONCE_STATUS=${GIT_PUSH_CERT_NONCE_STATUS-nononcestatus}
435 NONCE=${GIT_PUSH_CERT_NONCE-nononce}
436 E_O_F
440 - EOF
441 -
437 + EOF
438 + (
439 + cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
440 git config receive.certnonceseed sekrit &&
441 git config receive.certnonceslop 30
442 ) &&
t/t5550-http-fetch-dumb.sh
+10 -15
@@ -25,16 +25,17 @@ test_expect_success 'setup repository' '
25 git commit -m two
26 '
27
28 +setup_post_update_server_info_hook () {
29 + test_hook --setup -C "$1" post-update <<-\EOF &&
30 + exec git update-server-info
31 + EOF
32 + git -C "$1" update-server-info
33 +}
34 +
35 test_expect_success 'create http-accessible bare repository with loose objects' '
36 cp -R .git "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
30 - (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
31 - git config core.bare true &&
32 - mkdir -p hooks &&
33 - write_script "hooks/post-update" <<-\EOF &&
34 - exec git update-server-info
35 - EOF
36 - hooks/post-update
37 - ) &&
37 + git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" config core.bare true &&
38 + setup_post_update_server_info_hook "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
39 git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
40 git push public main:main
41 '
@@ -62,13 +63,7 @@ test_expect_success 'create password-protected repository' '
63
64 test_expect_success 'create empty remote repository' '
65 git init --bare "$HTTPD_DOCUMENT_ROOT_PATH/empty.git" &&
65 - (cd "$HTTPD_DOCUMENT_ROOT_PATH/empty.git" &&
66 - mkdir -p hooks &&
67 - write_script "hooks/post-update" <<-\EOF &&
68 - exec git update-server-info
69 - EOF
70 - hooks/post-update
71 - )
66 + setup_post_update_server_info_hook "$HTTPD_DOCUMENT_ROOT_PATH/empty.git"
67 '
68
69 test_expect_success 'empty dumb HTTP repository has default hash algorithm' '