summaryrefslogtreecommitdiff
path: root/t/t5550-http-fetch-dumb.sh
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2020-06-19 17:55:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-06-19 21:04:08 (GMT)
commitac093d0790cf9073e6cb03744b1d0fbc1e07d3f7 (patch)
tree53c245d5e7935b1d1add0f039782a2d7d8f2cc74 /t/t5550-http-fetch-dumb.sh
parentd96dab868e63cd5a55b50e1d8a23b640e17413bb (diff)
downloadgit-ac093d0790cf9073e6cb03744b1d0fbc1e07d3f7.zip
git-ac093d0790cf9073e6cb03744b1d0fbc1e07d3f7.tar.gz
git-ac093d0790cf9073e6cb03744b1d0fbc1e07d3f7.tar.bz2
remote-curl: detect algorithm for dumb HTTP by size
When reading the info/refs file for a repository, we have no explicit way to detect which hash algorithm is in use because the file doesn't provide one. Detect the hash algorithm in use by the size of the first object ID. If we have an empty repository, we don't know what the hash algorithm is on the remote side, so default to whatever the local side has configured. Without doing this, we cannot clone an empty repository since we don't know its hash algorithm. Test this case appropriately, since we currently have no tests for cloning an empty repository with the dumb HTTP protocol. We anonymize the URL like elsewhere in the function in case the user has decided to include a secret in the URL. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5550-http-fetch-dumb.sh')
-rwxr-xr-xt/t5550-http-fetch-dumb.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh
index 5048530..e57716b 100755
--- a/t/t5550-http-fetch-dumb.sh
+++ b/t/t5550-http-fetch-dumb.sh
@@ -50,6 +50,24 @@ test_expect_success 'create password-protected repository' '
"$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/repo.git"
'
+test_expect_success 'create empty remote repository' '
+ git init --bare "$HTTPD_DOCUMENT_ROOT_PATH/empty.git" &&
+ (cd "$HTTPD_DOCUMENT_ROOT_PATH/empty.git" &&
+ mkdir -p hooks &&
+ write_script "hooks/post-update" <<-\EOF &&
+ exec git update-server-info
+ EOF
+ hooks/post-update
+ )
+'
+
+test_expect_success 'empty dumb HTTP repository has default hash algorithm' '
+ test_when_finished "rm -fr clone-empty" &&
+ git clone $HTTPD_URL/dumb/empty.git clone-empty &&
+ git -C clone-empty rev-parse --show-object-format >empty-format &&
+ test "$(cat empty-format)" = "$(test_oid algo)"
+'
+
setup_askpass_helper
test_expect_success 'cloning password-protected repository can fail' '