git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Eric Wong <e@80x24.org>,
	"brian m. carlson" <sandals@crustytoothpaste.net>,
	git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] remote-curl: fix clone on sha256 repos
Date: Tue, 11 May 2021 17:23:23 -0400	[thread overview]
Message-ID: <YJr1y9jqguEQQXk3@coredump.intra.peff.net> (raw)
In-Reply-To: <YJrMNmH92mKrIX0N@coredump.intra.peff.net>

On Tue, May 11, 2021 at 02:25:58PM -0400, Jeff King wrote:

> It would be nice if there was a way to use an environment variable like
> GIT_TEST_DEFAULT_HASH to mean "be hash X on the server, but Y on the
> client". But I don't think we can easily do that. The "git init" command
> which is used to create a repo that is later used for server access
> doesn't _know_ that's what it's being used for. Possibly we could have
> an extra variable that instructs git-clone to use a separate default
> hash. And then:
> 
>   GIT_TEST_DEFAULT_HASH=sha256 \
>   GIT_TEST_CLONE_DEFAULT_HASH=sha1 \
>   make test
> 
> might possibly trigger some interesting cases.

So this triggers several test failures:

diff --git a/builtin/clone.c b/builtin/clone.c
index eeb74c0217..622447daf7 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -992,6 +992,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 	packet_trace_identity("clone");
 
+	/* hack to test cross-hash interop */
+	{
+		const char *x = getenv("GIT_TEST_DEFAULT_CLONE_HASH");
+		if (x)
+			setenv("GIT_DEFAULT_HASH", x, 1);
+	}
+
 	git_config(git_clone_config, NULL);
 
 	argc = parse_options(argc, argv, prefix, builtin_clone_options,

For example, running:

  GIT_TEST_DEFAULT_CLONE_HASH=sha1 \
  GIT_TEST_DEFAULT_HASH=sha256 \
  ./t5550-http-fetch-dumb.sh -v -i

fails in test 3, which shows the problem Eric found. And indeed,
applying his patch fixes it. We then go on to fail in test 7 ("empty
dumb HTTP repository has default hash algorithm"), which is not all that
surprising, since there is no longer one "the default".

So I'm not sure if the technique is a good one. It did find a bug, but
it's not clear to me if the other dozen failures it finds are also bugs,
or places where the tests should be modified to handle this case, or
just weird problems caused by the hacky implementation above. A lot of
them seem to involve submodules, which is not surprising; we'd probably
end up here with a sha256 superproject and cloned sha1 modules.

-Peff

  parent reply	other threads:[~2021-05-11 21:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11 10:37 [PATCH] remote-curl: fix clone on sha256 repos Eric Wong
2021-05-11 13:36 ` Junio C Hamano
2021-05-11 14:47 ` Ævar Arnfjörð Bjarmason
2021-05-11 18:25   ` Jeff King
2021-05-11 21:02     ` Junio C Hamano
2021-05-11 21:23     ` Jeff King [this message]
2021-05-11 23:04     ` brian m. carlson
2021-05-11 23:01 ` brian m. carlson
2021-05-11 23:48   ` Junio C Hamano
2021-05-11 23:51     ` brian m. carlson

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YJr1y9jqguEQQXk3@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=avarab@gmail.com \
    --cc=e@80x24.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sandals@crustytoothpaste.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).