From: Junio C Hamano <gitster@pobox.com>
To: Adrian Ratiu <adrian.ratiu@collabora.com>
Cc: git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>,
"brian m . carlson" <sandals@crustytoothpaste.net>,
Axel Rasmussen <axelrasmussen@google.com>,
Emily Shaffer <emilyshaffer@google.com>,
Josh Steadmon <steadmon@google.com>
Subject: Re: [PATCH v2] ls-remote: add --show-object-format
Date: Thu, 12 Nov 2026 10:07:17 -0800 [thread overview]
Message-ID: <xmqqfqx5kjoq.fsf@gitster.g> (raw)
In-Reply-To: <20261112085205.452463-1-adrian.ratiu@collabora.com> (Adrian Ratiu's message of "Thu, 12 Nov 2026 10:52:05 +0200")
Adrian Ratiu <adrian.ratiu@collabora.com> 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.
prev parent reply other threads:[~2026-11-12 18:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 10:45 [PATCH] ls-remote: add --show-object-format Adrian Ratiu
2026-11-05 14:13 ` Patrick Steinhardt
2026-11-05 16:35 ` Adrian Ratiu
2026-11-12 8:52 ` [PATCH v2] " Adrian Ratiu
2026-11-12 18:07 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqfqx5kjoq.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=adrian.ratiu@collabora.com \
--cc=axelrasmussen@google.com \
--cc=emilyshaffer@google.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
--cc=sandals@crustytoothpaste.net \
--cc=steadmon@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.