From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 4/7] odb/source-loose: distinguish missing and corrupt objects
Date: Tue, 18 Aug 2026 11:23:27 -0700 [thread overview]
Message-ID: <xmqqzeyjxp7k.fsf@gitster.g> (raw)
In-Reply-To: <20260818-pks-odb-generic-corrupt-objects-v1-4-ec234567510f@pks.im> (Patrick Steinhardt's message of "Tue, 18 Aug 2026 16:19:31 +0200")
Patrick Steinhardt <ps@pks.im> writes:
> @@ -91,11 +91,16 @@ static int read_object_info_from_path(struct odb_source_loose *loose,
> struct stat st;
>
> if ((!oi || (!oi->disk_sizep && !oi->mtimep)) && (flags & OBJECT_INFO_QUICK)) {
> - ret = quick_has_loose(loose, oid) ? 0 : -1;
> + ret = quick_has_loose(loose, oid) ? 0 : 1;
> goto out;
> }
>
> if (lstat(path, &st) < 0) {
> + if (errno == ENOENT) {
> + ret = 1;
> + goto out;
> + }
> +
> ret = -1;
> goto out;
Exactly the same comment about "turn it into an enum with meaningful
names once you add to an yes/no set a third choice" applies here.
> @@ -155,7 +163,7 @@ static int read_object_info_from_path(struct odb_source_loose *loose,
>
> if (parse_loose_header(hdr, oi) < 0) {
> ret = error(_("unable to parse %s header"), oid_to_hex(oid));
> - goto corrupt;
> + goto out;
> }
>
> if (*oi->typep < 0)
> @@ -165,7 +173,7 @@ static int read_object_info_from_path(struct odb_source_loose *loose,
> *oi->contentp = unpack_loose_rest(&stream, hdr, *oi->sizep, oid);
> if (!*oi->contentp) {
> ret = -1;
> - goto corrupt;
> + goto out;
> }
> }
>
> @@ -173,21 +181,20 @@ static int read_object_info_from_path(struct odb_source_loose *loose,
> case ULHR_BAD:
> ret = error(_("unable to unpack %s header"),
> oid_to_hex(oid));
> - goto corrupt;
> + goto out;
> case ULHR_TOO_LONG:
> ret = error(_("header for %s too long, exceeds %d bytes"),
> oid_to_hex(oid), MAX_HEADER_LEN);
> - goto corrupt;
> + goto out;
> }
>
> ret = 0;
>
> -corrupt:
> - if (ret && (flags & OBJECT_INFO_DIE_IF_CORRUPT))
> +out:
> + if (ret < 0 && (flags & OBJECT_INFO_DIE_IF_CORRUPT))
> die(_("loose object %s (stored in %s) is corrupt"),
> oid_to_hex(oid), path);
A missing object is not necessarily repository corruption, and the
code path to deal with it needs to jump here, so naming the label
"out:" is more appropriate. OK.
next prev parent reply other threads:[~2026-08-18 18:23 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
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 [this message]
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=xmqqzeyjxp7k.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;
as well as URLs for NNTP newsgroup(s).