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

Re: [PATCH v2 2/5] odb/source: introduce error status when reading objects

From
Karthik Nayak <karthik.188@gmail.com>
Date
Aug 20, 2026, 20:59 UTC
Message-ID
<CAOLa=ZTKqPa-9j8UzqQQCVwVk=Yt7aQVxg9qSi41Q+=A-6dAow@mail.gmail.com>
In-Reply-To
<aocNq1N9MWS4BeaJ@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 45 quoted lines
> On Thu, Aug 20, 2026 at 08:41:10AM -0400, Karthik Nayak wrote:
>> Patrick Steinhardt <ps@pks.im> writes:
>>
>> > The `read_object_info()` callback of `struct odb_source` is documented
>> > to return a negative error code in case reading the object has failed,
>> > and zero otherwise. This is overly broad though, as there are two very
>> > different kinds of failures:
>> >
>> >   - The object may not exist in the source at all.
>> >
>> >   - The object exists, but reading it has failed, for example because
>> >     its on-disk state is corrupt.
>> >
>> > This distinction matters to callers: when an object is corrupt in one
>> > source we may still find a good copy of it in another source, so we may
>> > still be able to proceed with a given operation.
>> >
>>
>> But isn't that the same for an object not existing in a source? If it
>> doesn't exist in one source, we may find a good copy of it in another?
>
> Yeah, that paragraph is a bit odd indeed. What I really wanted to say is
> that the failure mode is different depending on whether the object is
> found at all: if it's not then we'd fail gracefully, if it is but it's
> corrupt then we die.
>
>> > diff --git a/odb.c b/odb.c
>> > index caf1d0f542..1b37b26376 100644
>> > --- a/odb.c
>> > +++ b/odb.c
>> > @@ -696,12 +696,12 @@ static int oid_object_info_convert(struct repository *r,
>> >  	return ret;
>> >  }
>> >
>>
>> Here and elsewhere. Shouldn't we explicitly return ODB_READ_OK or
>> ODB_READ_ERROR instead of relying on implicit conversion?
>
> I didn't want to go through the complete callchain to make sure that we
> explicitly return those values. I think it'd be mostly pointless: the
> return code convention is established enough, and all callers already
> return the expected values anyway, even though they're not using the
> enum now.
>
> Patrick

I think logically it is correct already, but returning an enum type but seeing -1,0,1 in the return statements means that we have to either remember the different enum values or we need to cross reference each time. Eventually someone would start using 'return ODB_READ_OK' and so on and then we'd have a mix of both (this argument does go both way). Anyway, it is fine as is.

Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 6 of 15 in “odb: handle `OBJECT_INFO_DIE_IF_CORRUPT` generically”
  1. 0/5 odb: handle `OBJECT_INFO_DIE_IF_CORRUPT` genericallyPatrick Steinhardt, Aug 19, 2026
  2. 1/5 odb/source-packed: flag known-bad objects as corrupt and not missingPatrick Steinhardt, Aug 19, 2026
  3. 2/5 odb/source: introduce error status when reading objectsPatrick Steinhardt, Aug 19, 2026
  4. Karthik NayakAug 20, 2026
  5. Patrick SteinhardtAug 20, 2026
  6. Karthik NayakAug 20, 2026
  7. 3/5 odb/source: let callers discern missing and corrupt objectsPatrick Steinhardt, Aug 19, 2026
  8. Karthik NayakAug 20, 2026
  9. Patrick SteinhardtAug 20, 2026
  10. Karthik NayakAug 20, 2026
  11. Patrick SteinhardtAug 21, 2026
  12. Karthik NayakAug 21, 2026
  13. 4/5 odb/source: allow `read_object_info()` to bubble up error messagesPatrick Steinhardt, Aug 19, 2026
  14. 5/5 odb: handle `OBJECT_INFO_DIE_IF_CORRUPT` genericallyPatrick Steinhardt, Aug 19, 2026
  15. Karthik NayakAug 20, 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.