From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/7] odb/source-inmemory: signal missing objects via positive return
Date: Tue, 18 Aug 2026 11:05:33 -0700 [thread overview]
Message-ID: <xmqqcxvfz4lu.fsf@gitster.g> (raw)
In-Reply-To: <20260818-pks-odb-generic-corrupt-objects-v1-2-ec234567510f@pks.im> (Patrick Steinhardt's message of "Tue, 18 Aug 2026 16:19:29 +0200")
Patrick Steinhardt <ps@pks.im> writes:
> The in-memory source returns a negative value from its
> `read_object_info()` callback when the object in question does not
> exist. Adapt the callback to return a positive value for missing objects
> according to the new calling convention.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> odb/source-inmemory.c | 2 +-
> t/unit-tests/u-odb-inmemory.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/odb/source-inmemory.c b/odb/source-inmemory.c
> index 3e71611b8e..57183daf4d 100644
> --- a/odb/source-inmemory.c
> +++ b/odb/source-inmemory.c
> @@ -66,7 +66,7 @@ static int odb_source_inmemory_read_object_info(struct odb_source *source,
>
> object = find_cached_object(inmemory, oid);
> if (!object)
> - return -1;
> + return 1;
Let's not define "any positive value means this single thing: it
does not exist" and then return a mysterious and unspecified hard
coded constant like this. Instead perhaps something along this
line?
enum odb_roi_status {
ODB_ROI_SUCCESS = 0,
ODB_ROI_MISSING = 1,
ODB_ROI_IO_ERROR = -1,
...
};
As I already said, I personally prefer to define MISSING also as
a negative value.
next prev parent reply other threads:[~2026-08-18 18:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 14:19 [PATCH 0/7] odb: handle `OBJECT_INFO_DIE_IF_CORRUPT` generically Patrick Steinhardt
2026-08-18 14:19 ` [PATCH 1/7] odb/source: discern missing and corrupt objects Patrick Steinhardt
2026-08-18 18:00 ` Junio C Hamano
2026-08-18 14:19 ` [PATCH 2/7] odb/source-inmemory: signal missing objects via positive return Patrick Steinhardt
2026-08-18 18:05 ` Junio C Hamano [this message]
2026-08-18 14:19 ` [PATCH 3/7] odb/source-packed: flag known-bad objects as corrupt and not missing Patrick Steinhardt
2026-08-18 18:17 ` Junio C Hamano
2026-08-18 14:19 ` [PATCH 4/7] odb/source-loose: distinguish missing and corrupt objects Patrick Steinhardt
2026-08-18 18:23 ` Junio C Hamano
2026-08-18 14:19 ` [PATCH 5/7] odb/source-files: signal mark objects via positive return Patrick Steinhardt
2026-08-18 18:58 ` Junio C Hamano
2026-08-18 14:19 ` [PATCH 6/7] odb/source: allow `read_object_info()` to bubble up error messages Patrick Steinhardt
2026-08-18 14:19 ` [PATCH 7/7] odb: handle `OBJECT_INFO_DIE_IF_CORRUPT` generically Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqcxvfz4lu.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox