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

Re: [PATCH] xdiff-interface: stop using the_repository

From
René Scharfe <l.s.r@web.de>
Date
Feb 9, 2026, 15:21 UTC
Message-ID
<b05f81aa-6e8a-4e90-ac9e-85fb72784afb@web.de>
In-Reply-To
<xmqqms1i6uc8.fsf@gitster.g>
On 2/9/26 12:15 PM, Junio C Hamano wrote:
Show 35 quoted lines
> René Scharfe <l.s.r@web.de> writes:
> 
>> Use the algorithm-agnostic is_null_oid() and push the dependency of
>> read_mmblob() on the_repository->objects to its callers.  This allows it
>> to be used with arbitrary object databases.
> 
>> diff --git a/xdiff-interface.c b/xdiff-interface.c
>> index 1a35556380..cd7493730b 100644
>> --- a/xdiff-interface.c
>> +++ b/xdiff-interface.c
>> ...
>> -void read_mmblob(mmfile_t *ptr, const struct object_id *oid)
>> +void read_mmblob(mmfile_t *ptr, struct object_database *odb,
>> +		 const struct object_id *oid)
> 
> A possible alternative may be to pass "struct repository *" here,
> but this passes the (current) smallest piece of data necessary to
> drive the helper function odb_read_object(), so it would be fine.
> 
>>  {
>>  	unsigned long size;
>>  	enum object_type type;
>>  
>> -	if (oideq(oid, null_oid(the_hash_algo))) {
>> +	if (is_null_oid(oid)) {
>>  		ptr->ptr = xstrdup("");
>>  		ptr->size = 0;
>>  		return;
>>  	}
>>  
>> -	ptr->ptr = odb_read_object(the_repository->objects, oid, &type, &size);
>> +	ptr->ptr = odb_read_object(odb, oid, &type, &size);
>>  	if (!ptr->ptr || type != OBJ_BLOB)
>>  		die("unable to read blob object %s", oid_to_hex(oid));
>>  	ptr->size = size;

My initial version did that. Then I realized that read_mmblob() is just a thin odb_read_object() wrapper that converts null_oid to empty_blob_oid and dies on non-blobs, though, so requiring a full repo pointer seemed excessive. And all callers also use other odb_* functions already.

René
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 14 in “xdiff-interface: stop using the_repository”
  1. xdiff-interface: stop using the_repositoryRené Scharfe, Feb 8, 2026
  2. Patrick SteinhardtFeb 9, 2026
  3. René ScharfeFeb 9, 2026
  4. Junio C HamanoFeb 9, 2026
  5. René ScharfeFeb 9, 2026
  6. Junio C HamanoFeb 9, 2026
  7. René ScharfeFeb 9, 2026
  8. Elijah NewrenFeb 9, 2026
  9. Junio C HamanoFeb 9, 2026
  10. René ScharfeFeb 15, 2026
  11. René ScharfeFeb 15, 2026
  12. xdiff-interface: stop using the_repositoryRené Scharfe, Feb 9, 2026
  13. Patrick SteinhardtFeb 10, 2026
  14. Junio C HamanoFeb 10, 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.