git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] remote-curl: fix clone on sha256 repos

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
May 11, 2021, 23:01 UTC
Message-ID
<YJsM3sUXRYjJiwZG@camp.crustytoothpaste.net>
In-Reply-To
<20210511103730.GA15003@dcvr>
On 2021-05-11 at 10:37:30, Eric Wong wrote:
Show 42 quoted lines
> I'm not very familiar with the way some of this stuff works, but
> the patch below seems to fix clone for me.
> 
> I originally tried changing the cmd_main->set_option code path,
> but value is always set to "true" for object-format because
> it only sees "option object-format" with no arg
> 
> 		} else if (skip_prefix(buf.buf, "option ", &arg)) {
> 			char *value = strchr(arg, ' ');
> 			int result;
> 
> 			if (value)
> 				*value++ = '\0';
> 			else
> 				value = "true";
> 
> 			result = set_option(arg, value);
> 
> So when set_option gets called, hash_algo_by_name isn't:
> 
> 	} else if (!strcmp(name, "object-format")) {
> 		int algo;
> 		options.object_format = 1;
> 		if (strcmp(value, "true")) {
> 			/* XXX this branch is never taken: */
> 			algo = hash_algo_by_name(value);
> 			if (algo == GIT_HASH_UNKNOWN)
> 				die("unknown object format '%s'", value);
> 			options.hash_algo = &hash_algos[algo];
> 		}
> 		return 0;
> 
> So I'm not sure if the above is incomplete or dead code.
> Anyways, I arrived at the following and it works for me:
> 
> -----------8<---------
> Subject: [PATCH] remote-curl: fix clone on sha256 repos
> 
> The remote-https process needs to update it's own instance of
> `the_repository' when it sees an HTTP(S) remote is using sha256.
> Without this, parse_oid_hex() fails to handle sha256 OIDs when
> it's eventually called by parse_fetch().

This seems fine as a solution for now. I tried to keep the transport code mostly independent of the local repository settings, but in this case because the HTTP walker mucks around with the internals of the local pack files, I don't think we can avoid this without some major restructuring, which I'm not interested in sitting down and writing this evening.

I'll clean this up in a nicer way once I get interop working. Thanks for sending a patch for this.

-- 
brian m. carlson (he/him or they/them)
Houston, Texas, US
Previous: brian m. carlsonNext: Junio C Hamano
Message 8 of 10 in “remote-curl: fix clone on sha256 repos”
  1. remote-curl: fix clone on sha256 reposEric Wong, May 11, 2021
  2. Junio C HamanoMay 11, 2021
  3. Ævar Arnfjörð BjarmasonMay 11, 2021
  4. Jeff KingMay 11, 2021
  5. Junio C HamanoMay 11, 2021
  6. Jeff KingMay 11, 2021
  7. brian m. carlsonMay 11, 2021
  8. brian m. carlsonMay 11, 2021
  9. Junio C HamanoMay 11, 2021
  10. brian m. carlsonMay 11, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.