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

Re: [PATCH 2/3] rev-parse: die when --output-object-format cannot map an object

From
Adrian Ratiu <adrian.ratiu@collabora.com>
Date
Nov 17, 2026, 11:55 UTC
Message-ID
<87fqwzk6yv.fsf@collabora.com>
In-Reply-To
<avqynlDKnJpJn6RZ@pks.im>
On Mon, 16 Nov 2026, Patrick Steinhardt <ps@pks.im> wrote:
Show 20 quoted lines
> On Thu, Nov 12, 2026 at 09:57:39PM +0200, Adrian Ratiu wrote:
>> This happens because rev-parse ignores the repo_oid_to_algop() return
>> value. When no mapping is found, that function fails and leaves the
>> id unchanged, so the storage id is what gets printed.
>> 
>> Fix it to die with the same message as pack-objects. The other callers
>> of repo_oid_to_algop() already check its result.
>> 
>> This only covers a single revision argument, the one case where
>> rev-parse converts its output. Other forms, such as "A..B" or "A^@",
>> print storage ids whatever --output-object-format says. That is left
>> for a separate change.
>
> This paragraph is a bit hard to parse.
>
>   Note that this only covers the case where the user asks for a single
>   revision, as it is the only case where we pass the desired output hash
>   explicitly. All the other cases, like for example when the user passes
>   a range, do not use the desired output hash at all. Fixing that would
>   be a bigger change though, so this is left for a future patch series.
Ack, I'll reword it.
Show 7 quoted lines
>> The test copies a loose object into the repository by hand, so it
>> doesn't depend on whether fetch writes compat mappings.
>
> Do we have to do that? I'm mostly asking in the context of the new
> object storage format extension, which may change where and how exactly
> objects are stored. So all tests that manually modify the object
> database will break, and we'll want and need to fix those.
We can do it any other way, no problem.

How I reproduced this in the real world (non-test) is by creating a commit with JJ, but I tried to avoid adding JJ as a test dependency. :)

Besides, I'll fix this in newer JJ as well, to simply reject repos with extensions.compatObjectFormat, which is not supported either in Gitoxide or JJ.

Show 19 quoted lines
>> diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
>> index 30bf8a4d0a..c15d9953a8 100755
>> --- a/t/t1500-rev-parse.sh
>> +++ b/t/t1500-rev-parse.sh
>> @@ -241,6 +241,24 @@ test_expect_success RUST 'rev-parse --show-object-format in repo with compat mod
>>  	)
>>  '
>>  
>> +test_expect_success RUST 'rev-parse --output-object-format with unmapped object' '
>> +	test_when_finished "rm -rf plain compat" &&
>> +	git init --object-format=sha256 plain &&
>> +	git init --object-format=sha256 compat &&
>> +	git -C compat config extensions.compatobjectformat sha1 &&
>> +	oid=$(echo unmapped | git -C plain hash-object -w --stdin) &&
>> +	# copy the object by hand, so that no compat mapping is written for it
>
> Instead of copying by hand, wouldn't it be possible to write the object
> with the compat object format unset and then set it afterwards? That
> should also ensure that we don't have the compat hash.
Yes, I just verified that it works. Will it this way in v2, thanks!
Previous: Patrick SteinhardtNext: Adrian Ratiu
Message 7 of 10 in “compatObjectFormat: fix a BUG(), wrong id and unknown headers”
  1. 0/3 compatObjectFormat: fix a BUG(), wrong id and unknown headersAdrian Ratiu, Nov 12, 2026
  2. 1/3 setup: reject compatObjectFormat == objectFormatAdrian Ratiu, Nov 12, 2026
  3. Patrick SteinhardtNov 16, 2026
  4. Adrian RatiuNov 17, 2026
  5. 2/3 rev-parse: die when --output-object-format cannot map an objectAdrian Ratiu, Nov 12, 2026
  6. Patrick SteinhardtNov 16, 2026
  7. Adrian RatiuNov 17, 2026
  8. 3/3 object-file-convert: copy unknown commit headers unchangedAdrian Ratiu, Nov 12, 2026
  9. Patrick SteinhardtNov 16, 2026
  10. Adrian RatiuNov 17, 2026

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.