From: Junio C Hamano Date: Thu, 12 Nov 2026 18:07:17 GMT Subject: Re: [PATCH v2] ls-remote: add --show-object-format Message-ID: In-Reply-To: <20261112085205.452463-1-adrian.ratiu@collabora.com> Adrian Ratiu writes: > @@ -150,6 +154,9 @@ int cmd_ls_remote(int argc, > > if (!dest && !quiet) > fprintf(stderr, "From %s\n", remote->url.v[0]); > + if (show_object_format) > + printf("object-format: %s\n", > + transport_get_hash_algo(transport)->name); OK. transport_get_hash_algo() just grabs transport->hash_algo which was relayed from connect.c:get_remote_refs(), so even when talking over an old protocol that does not explicitly declare, we get GIT_HASH_SHA1_LEGACY. IOW, no need to worry about hitting an "eh, we do not know that" here. Looking good. > +# Run "ls-remote --show-object-format" with the given arguments over > +# protocol v0 and v2, and check that it prints the object format given > +# as the first argument, followed by the same refs as plain "ls-remote". > +test_show_object_format () { > + format=$1 && > + shift && > + echo "object-format: $format" >expect && > + git ls-remote "$@" >>expect && > + for version in 0 2 > + do > + git -c protocol.version=$version \ > + ls-remote --show-object-format "$@" >actual && > + test_cmp expect actual || return 1 > + done > +} > + > +for hash in sha1 sha256 > +do > + test_expect_success "ls-remote --show-object-format with empty $hash remote" ' > + git init --bare --object-format=$hash empty-$hash.git && > + test_show_object_format $hash empty-$hash.git > + ' > + > + test_expect_success "ls-remote --show-object-format with $hash remote" ' > + git init --object-format=$hash repo-$hash && > + test_commit -C repo-$hash one && > + test_show_object_format $hash repo-$hash HEAD > + ' > +done > + > +test_expect_success 'ls-remote --show-object-format outside repository' ' > + nongit git init --bare --object-format=sha256 empty-nongit.git && > + echo "object-format: sha256" >expect && > + nongit git ls-remote --show-object-format empty-nongit.git >actual && > + test_cmp expect actual > +' And we seem to have adequate test coverage. Thanks.