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

Re: [RFC PATCH 1/1] Define an extended tree format

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 1, 2025, 21:19 UTC
Message-ID
<xmqqy0puz5f6.fsf@gitster.g>
In-Reply-To
<20251001211140.GA140550@peff.net>
Jeff King <peff@peff.net> writes:
Show 5 quoted lines
> The other unexpected thing is that the sequence above works today! I
> think it is mostly accidental, though. When we read the head of the
> submodule, we get a "struct object_id" with a different algo field. But
> we never pay attention to that field, and just treat it as if it is
> using our native algorithm.

Yeah, I recall that there was a discussion about this exact "yes, we get by fine with SHA-1 commit object name 0-padded to the right, when embedding SHA-1 submodule inside SHA-256 superproject", countered by brian's "no, it may happen to work but you shouldn't rely on it" recently.

Show 25 quoted lines
> So it all works as expected, but I feel like it's mostly by accident. My
> gut feeling is that we probably wanted something like this to protect us
> from confusion:
>
> index 06ad74db22..295b0c6318 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -719,6 +719,8 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
>  	if (S_ISDIR(st_mode)) {
>  		if (repo_resolve_gitlink_ref(the_repository, path, "HEAD", &oid) < 0)
>  			return error(_("'%s' does not have a commit checked out"), path);
> +		if (oid.algo != hash_algo_by_ptr(the_repository->hash_algo))
> +			return error(_("object format %s of '%s' is incompatible with this repository (%s)"), hash_algos[oid.algo].name, path, the_repository->hash_algo->name);
>  		while (namelen && path[namelen-1] == '/')
>  			namelen--;
>  	}
>
> Of course that is strictly worse for somebody who is relying on the
> current accidental behavior. ;) And in the long run, I think this is the
> spot we'd want to hook to do whatever massaging we need (whether
> converting to the equivalent in-repo algorithm, or hacking up the name
> to store the foreign hash).
>
> I also won't be at all surprised if you've run across this already in
> your interop work.
Previous: Jeff KingNext: brian m. carlson
Message 6 of 10 in “Extended tree format for mixed submodules and conflicts”
  1. 0/1 Extended tree format for mixed submodules and conflictsbrian m. carlson, Oct 1, 2025
  2. 1/1 Define an extended tree formatbrian m. carlson, Oct 1, 2025
  3. Junio C HamanoOct 1, 2025
  4. Jeff KingOct 1, 2025
  5. Jeff KingOct 1, 2025
  6. Junio C HamanoOct 1, 2025
  7. brian m. carlsonOct 1, 2025
  8. Jeff KingOct 1, 2025
  9. Jeff KingOct 1, 2025
  10. Elijah NewrenOct 1, 2025

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.