Re: [PATCH 1/5] loose: load loose object map for the correct source
Justin Tobler <jltobler@gmail.com> writes:
Show 13 quoted lines
> On 26/07/24 05:48AM, Patrick Steinhardt wrote:
>> When loading the loose object map via `load_one_loose_object_map()` we
>> pass in both a repository and the corresponding source. We ultimately
>> don't really respect the passed-in source though as we instead always
>> load the map via the common directory. This doesn't make any sense
>> though, as the function is called in a loop through all sources, and as
>> such the expectation is that we'll load the map that belongs to the
>> given source.
>>
>> Fix this bug by instead loading the map via the loose source's path.
>
> IIUC the primary source is always being used, does this mean that
> repositories using a compat hash and alternates are currently broken?
Yeah, the commit message seems to undersell this fix.
I think it wouldn't hurt to add a small test for this:
test_expect_success 'rev-parse maps oid of object borrowed from alternate' '
test_when_finished rm -rf alt borrow &&
git init --object-format=sha256 alt &&
git -C alt config extensions.compatObjectFormat sha1 &&
test_commit -C alt A &&
git init --object-format=sha256 borrow &&
git -C borrow config extensions.compatObjectFormat sha1 &&
echo "$PWD/alt/.git/objects" >borrow/.git/objects/info/alternates &&
oid=$(git -C alt rev-parse HEAD) &&
git -C alt rev-parse --output-object-format=sha1 "$oid" >expect &&
git -C borrow rev-parse --output-object-format=sha1 "$oid" >actual &&
test_cmp expect actual
'--
Cheers,
Toon