Re: [RFC PATCH 1/1] Define an extended tree format
From: brian m. carlson <hidden>
Date: 2025-10-01 21:45:31
On 2025-10-01 at 21:11:40, Jeff King wrote:
quoted hunk ↗ jump to hunk
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 think sending in this patch is a good first step right now. The intention of the transition document is that the code is in one and only one hash algorithm at a time and it would be better to reject this case until we're ready to wire it up correctly than end up with data that's corrupt down the line.
I also won't be at all surprised if you've run across this already in your interop work.
I have not, since it's primarily involved working with the testsuite and some test repositories. I know that submodules are broken in interop mode; I didn't need to test that until I was writing code to make them not-broken. -- brian m. carlson (they/them) Toronto, Ontario, CA
Attachments
- signature.asc [application/pgp-signature] 262 bytes