remote-curl: detect algorithm for dumb HTTP by size
commitac093d0790cf9073e6cb03744b1d0fbc1e07d3f7
authorbrian m. carlson <sandals@crustytoothpaste.net>
Fri, 19 Jun 2020 17:55:51 +0000 (19 17:55 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Jun 2020 21:04:08 +0000 (19 14:04 -0700)
tree53c245d5e7935b1d1add0f039782a2d7d8f2cc74
parentd96dab868e63cd5a55b50e1d8a23b640e17413bb
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>
remote-curl.c
t/t5550-http-fetch-dumb.sh