public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Aaron Plattner <aplattner@nvidia.com>,
	Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>,
	Toon Claes <toon@iotcl.com>
Subject: Re: [PATCH v3 1/7] object-file: always set OI_LOOSE when reading object info
Date: Wed, 7 Jan 2026 12:27:24 +0100	[thread overview]
Message-ID: <aV5DHI04KBs4GJn-@pks.im> (raw)
In-Reply-To: <CAOLa=ZSNmi_Lzb=3EdWks=mMOPvfijT2659y4YtxWnUKVUOXaA@mail.gmail.com>

On Wed, Jan 07, 2026 at 12:50:45AM -0800, Karthik Nayak wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> > diff --git a/object-file.c b/object-file.c
> > index 6280e42f34..d566df427a 100644
> > --- a/object-file.c
> > +++ b/object-file.c
> > @@ -439,12 +439,23 @@ int odb_source_loose_read_object_info(struct odb_source *source,
> >  	 */
> >  	if (!oi || (!oi->typep && !oi->sizep && !oi->contentp)) {
> >  		struct stat st;
> > -		if ((!oi || !oi->disk_sizep) && (flags & OBJECT_INFO_QUICK))
> > -			return quick_has_loose(source->loose, oid) ? 0 : -1;
> > +
> > +		if ((!oi || !oi->disk_sizep) && (flags & OBJECT_INFO_QUICK)) {
> > +			status = quick_has_loose(source->loose, oid) ? 0 : -1;
> > +			if (!status && oi)
> > +				oi->whence = OI_LOOSE;
> > +			return status;
> > +		}
> > +
> >  		if (stat_loose_object(source->loose, oid, &st, &path) < 0)
> >  			return -1;
> > -		if (oi && oi->disk_sizep)
> > -			*oi->disk_sizep = st.st_size;
> > +
> > +		if (oi) {
> > +			if (oi->disk_sizep)
> > +				*oi->disk_sizep = st.st_size;
> > +			oi->whence = OI_LOOSE;
> > +		}
> > +
> >  		return 0;
> >  	}
> >
> 
> The change looks good. I'm wary of early returns independently doing the
> cleanup, wonder if it'd be better to do `status = ...; goto cleanup`
> instead.

I share that sentiment, and I was in fact having a look at what it would
take to have a single exit path in this function. I eventually discarded
the work though because it required a bunch of changes to really make
this whole function more readable than it currently is.

But now that you're the second one thinking this I'll probably bite the
bullet and just do it.

Thanks!

Patrick

  reply	other threads:[~2026-01-07 11:27 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-18  6:28 [PATCH 0/8] Improvements for reading object info Patrick Steinhardt
2025-12-18  6:28 ` [PATCH 1/8] object-file: always set OI_LOOSE when " Patrick Steinhardt
2025-12-18  6:28 ` [PATCH 2/8] packfile: always declare object info to be OI_PACKED Patrick Steinhardt
2025-12-18  7:23   ` Junio C Hamano
2025-12-18  9:10     ` Patrick Steinhardt
2025-12-18  6:28 ` [PATCH 3/8] packfile: extend `is_delta` field to allow for "unknown" state Patrick Steinhardt
2025-12-18  6:28 ` [PATCH 4/8] packfile: always populate pack-specific info when reading object info Patrick Steinhardt
2025-12-18  7:32   ` Junio C Hamano
2025-12-18  6:28 ` [PATCH 5/8] packfile: disentangle return value of `packed_object_info()` Patrick Steinhardt
2025-12-18  6:28 ` [PATCH 6/8] packfile: skip unpacking object header for disk size requests Patrick Steinhardt
2025-12-18  6:28 ` [PATCH 7/8] packfile: fix short-circuiting of empty requests Patrick Steinhardt
2025-12-18  6:28 ` [PATCH 8/8] packfile: drop repository parameter from `packed_object_info()` Patrick Steinhardt
2025-12-18  8:09 ` [PATCH 0/8] Improvements for reading object info Junio C Hamano
2025-12-18  8:30   ` Patrick Steinhardt
2025-12-18 10:54 ` [PATCH v2 0/7] " Patrick Steinhardt
2025-12-18 10:54   ` [PATCH v2 1/7] object-file: always set OI_LOOSE when " Patrick Steinhardt
2025-12-18 10:54   ` [PATCH v2 2/7] packfile: always declare object info to be OI_PACKED Patrick Steinhardt
2026-01-05 14:29     ` Toon Claes
2025-12-18 10:54   ` [PATCH v2 3/7] packfile: extend `is_delta` field to allow for "unknown" state Patrick Steinhardt
2026-01-05 15:35     ` Toon Claes
2026-01-06  6:34       ` Patrick Steinhardt
2025-12-18 10:54   ` [PATCH v2 4/7] packfile: always populate pack-specific info when reading object info Patrick Steinhardt
2025-12-30 17:03     ` Kristoffer Haugsbakk
2026-01-05 11:38       ` Patrick Steinhardt
2025-12-18 10:54   ` [PATCH v2 5/7] packfile: disentangle return value of `packed_object_info()` Patrick Steinhardt
2025-12-18 10:54   ` [PATCH v2 6/7] packfile: skip unpacking object header for disk size requests Patrick Steinhardt
2025-12-18 10:54   ` [PATCH v2 7/7] packfile: drop repository parameter from `packed_object_info()` Patrick Steinhardt
2026-01-06  6:54 ` [PATCH v3 0/7] Improvements for reading object info Patrick Steinhardt
2026-01-06  6:54   ` [PATCH v3 1/7] object-file: always set OI_LOOSE when " Patrick Steinhardt
2026-01-07  8:50     ` Karthik Nayak
2026-01-07 11:27       ` Patrick Steinhardt [this message]
2026-01-06  6:54   ` [PATCH v3 2/7] packfile: always declare object info to be OI_PACKED Patrick Steinhardt
2026-01-06  6:54   ` [PATCH v3 3/7] packfile: extend `is_delta` field to allow for "unknown" state Patrick Steinhardt
2026-01-07 10:12     ` Karthik Nayak
2026-01-06  6:55   ` [PATCH v3 4/7] packfile: always populate pack-specific info when reading object info Patrick Steinhardt
2026-01-06  6:55   ` [PATCH v3 5/7] packfile: disentangle return value of `packed_object_info()` Patrick Steinhardt
2026-01-06  6:55   ` [PATCH v3 6/7] packfile: skip unpacking object header for disk size requests Patrick Steinhardt
2026-01-06  6:55   ` [PATCH v3 7/7] packfile: drop repository parameter from `packed_object_info()` Patrick Steinhardt
2026-01-07 10:17   ` [PATCH v3 0/7] Improvements for reading object info Karthik Nayak
2026-01-07 13:07 ` [PATCH v4 " Patrick Steinhardt
2026-01-07 13:08   ` [PATCH v4 1/7] object-file: always set OI_LOOSE when " Patrick Steinhardt
2026-01-08  9:30     ` Karthik Nayak
2026-01-07 13:08   ` [PATCH v4 2/7] packfile: always declare object info to be OI_PACKED Patrick Steinhardt
2026-01-07 13:08   ` [PATCH v4 3/7] packfile: extend `is_delta` field to allow for "unknown" state Patrick Steinhardt
2026-01-07 13:08   ` [PATCH v4 4/7] packfile: always populate pack-specific info when reading object info Patrick Steinhardt
2026-01-07 13:08   ` [PATCH v4 5/7] packfile: disentangle return value of `packed_object_info()` Patrick Steinhardt
2026-01-07 13:08   ` [PATCH v4 6/7] packfile: skip unpacking object header for disk size requests Patrick Steinhardt
2026-01-07 13:08   ` [PATCH v4 7/7] packfile: drop repository parameter from `packed_object_info()` Patrick Steinhardt
2026-01-08  9:30   ` [PATCH v4 0/7] Improvements for reading object info Karthik Nayak
2026-01-12  9:00 ` [PATCH v5 " Patrick Steinhardt
2026-01-12  9:00   ` [PATCH v5 1/7] object-file: always set OI_LOOSE when " Patrick Steinhardt
2026-01-12  9:00   ` [PATCH v5 2/7] packfile: always declare object info to be OI_PACKED Patrick Steinhardt
2026-01-12 14:54     ` Junio C Hamano
2026-01-12  9:00   ` [PATCH v5 3/7] packfile: extend `is_delta` field to allow for "unknown" state Patrick Steinhardt
2026-01-12  9:00   ` [PATCH v5 4/7] packfile: always populate pack-specific info when reading object info Patrick Steinhardt
2026-01-12  9:00   ` [PATCH v5 5/7] packfile: disentangle return value of `packed_object_info()` Patrick Steinhardt
2026-01-12  9:00   ` [PATCH v5 6/7] packfile: skip unpacking object header for disk size requests Patrick Steinhardt
2026-01-12  9:00   ` [PATCH v5 7/7] packfile: drop repository parameter from `packed_object_info()` 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=aV5DHI04KBs4GJn-@pks.im \
    --to=ps@pks.im \
    --cc=aplattner@nvidia.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=karthik.188@gmail.com \
    --cc=kristofferhaugsbakk@fastmail.com \
    --cc=toon@iotcl.com \
    /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