summaryrefslogtreecommitdiffstats
path: root/t/t0025-crlf-renormalize.sh
diff options
context:
space:
mode:
authorbrian m. carlson <bk2204@github.com>2023-05-17 21:24:43 +0200
committerJunio C Hamano <gitster@pobox.com>2023-05-17 22:22:46 +0200
commit933e3a4ee205353d8f093d5dfcd226fa432c4e58 (patch)
tree247e2666a7fd325910d8bee3b830a54195c9ff64 /t/t0025-crlf-renormalize.sh
parentThe thirteenth batch (diff)
downloadgit-933e3a4ee205353d8f093d5dfcd226fa432c4e58.tar.xz
git-933e3a4ee205353d8f093d5dfcd226fa432c4e58.zip
upload-pack: advertise capabilities when cloning empty repos
When cloning an empty repository, protocol versions 0 and 1 currently offer nothing but the header and flush packets for the /info/refs endpoint. This means that no capabilities are provided, so the client side doesn't know what capabilities are present. However, this does pose a problem when working with SHA-256 repositories, since we use the capabilities to know the remote side's object format (hash algorithm). As of 8b214c2e9d ("clone: propagate object-format when cloning from void", 2023-04-05), this has been fixed for protocol v2, since there we always read the hash algorithm from the remote. Fortunately, the push version of the protocol already indicates a clue for how to solve this. When the /info/refs endpoint is accessed for a push and the remote is empty, we include a dummy "capabilities^{}" ref pointing to the all-zeros object ID. The protocol documentation already indicates this should _always_ be sent, even for fetches and clones, so let's just do that, which means we'll properly announce the hash algorithm as part of the capabilities. This just works with the existing code because we share the same ref code for fetches and clones, and libgit2, JGit, and dulwich do as well. There is one minor issue to fix, though. If we called send_ref with namespaces, we would return NULL with the capabilities entry, which would cause a crash. Instead, let's refactor out a function to print just the ref itself without stripping the namespace and use it for our special capabilities entry. Add several sets of tests for HTTP as well as for local clones. The behavior can be slightly different for HTTP versus a local or SSH clone because of the stateless-rpc functionality, so it's worth testing both. Signed-off-by: brian m. carlson <bk2204@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0025-crlf-renormalize.sh')
0 files changed, 0 insertions, 0 deletions