Git development
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org, Toon Claes <toon@iotcl.com>,
	Junio C Hamano <gitster@pobox.com>,
	Justin Tobler <jltobler@gmail.com>
Subject: Re: [PATCH v4 7/9] odb/source: support writing alternates when creating the database
Date: Fri, 11 Sep 2026 07:15:12 +0200	[thread overview]
Message-ID: <aqOOYI9v8M9VYeNN@pks.im> (raw)
In-Reply-To: <CAOLa=ZQaPstiQmXm9=TyWPUxL6X2=Lcqeg6y2XeXzSJDpq-GBA@mail.gmail.com>

On Thu, Sep 10, 2026 at 04:10:31AM -0700, Karthik Nayak wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> > diff --git a/odb/source-files.c b/odb/source-files.c
> > index b7b3a297bb..8fe65d91f8 100644
> > --- a/odb/source-files.c
> > +++ b/odb/source-files.c
> > @@ -64,8 +70,74 @@ static int odb_source_files_create_on_disk(struct odb_source *source)
[snip]
> > +		/*
> > +		 * The alternates file may already exist, e.g. when it has been
> > +		 * seeded from a template directory. Read any preexisting
> > +		 * entries so that we don't end up writing duplicates.
> > +		 */
> > +		orig = fopen(path.buf, "r");
> > +		if (orig) {
> > +			while (strbuf_getline(&line, orig) != EOF) {
> > +				strset_add(&seen, line.buf);
> > +				fprintf(alternates, "%s\n", line.buf);
> > +			}
> > +
> > +			if (ferror(orig)) {
> > +				ret = error_errno(_("unable to read alternates file"));
> > +				fclose(orig);
> > +				goto out;
> > +			}
> 
> Shouldn't this be checked inside the for loop with every `fprintf` call?

There isn't really any need to, as the error indicator on file streams
is sticky. Sure, it would allow us to potentially abort earlier. But
it's unlikely that this really matters in practice.

> > diff --git a/odb/source.h b/odb/source.h
> > index ea8675247e..63f1c0c531 100644
> > --- a/odb/source.h
> > +++ b/odb/source.h
> > @@ -36,6 +36,15 @@ struct object_id;
> >  struct odb_stream;
> >  struct strvec;
> >
> > +struct odb_create_on_disk_options {
> > +	/*
> > +	 * Alternates that shall be written into the newly created object
> > +	 * database. Whether or not this option can be handled is specific to
> > +	 * the backend.
> > +	 */
> 
> Would it make sense to formalize errors thrown by backends, so we know
> when a backend specifically cannot handle alternates?

Maybe, but there's nothing that'd use it. So I'm a bit hesitant to
introduce that right now without us having a way to verify the logic at
all. We may want to eventually introduce such logic though.

Patrick

  reply	other threads:[~2026-09-11  5:15 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 14:11 [PATCH 0/8] odb: write alternates at creation time Patrick Steinhardt
2026-08-25 14:11 ` [PATCH 1/8] builtin/clone: defer setup of the object database Patrick Steinhardt
2026-08-25 14:11 ` [PATCH 2/8] builtin/clone: move around `setup_reference()` Patrick Steinhardt
2026-08-25 14:11 ` [PATCH 3/8] builtin/clone: refactor handling of "--reference{,-if-able}" Patrick Steinhardt
2026-08-28 14:52   ` Toon Claes
2026-08-25 14:11 ` [PATCH 4/8] builtin/clone: move setup of alternates for shared local clones Patrick Steinhardt
2026-08-28 14:52   ` Toon Claes
2026-08-25 14:11 ` [PATCH 5/8] builtin/clone: move setup of alternates for non-shared " Patrick Steinhardt
2026-08-28 14:52   ` Toon Claes
2026-08-31  8:13     ` Patrick Steinhardt
2026-08-25 14:11 ` [PATCH 6/8] odb/source: support writing alternates when creating the database Patrick Steinhardt
2026-08-28 14:53   ` Toon Claes
2026-08-31  8:14     ` Patrick Steinhardt
2026-08-28 19:13   ` Junio C Hamano
2026-08-31  8:14     ` Patrick Steinhardt
2026-08-25 14:11 ` [PATCH 7/8] builtin/clone: write alternates via `odb_create_on_disk()` Patrick Steinhardt
2026-08-25 14:11 ` [PATCH 8/8] odb/source: remove the ability to write alternates Patrick Steinhardt
2026-08-28 14:53   ` Toon Claes
2026-08-31  8:14     ` Patrick Steinhardt
2026-08-31 10:02 ` [PATCH v2 0/8] odb: write alternates at creation time Patrick Steinhardt
2026-08-31 10:02   ` [PATCH v2 1/8] builtin/clone: defer setup of the object database Patrick Steinhardt
2026-09-06 16:42     ` Justin Tobler
2026-09-07  7:23       ` Patrick Steinhardt
2026-08-31 10:02   ` [PATCH v2 2/8] builtin/clone: move around `setup_reference()` Patrick Steinhardt
2026-08-31 10:02   ` [PATCH v2 3/8] builtin/clone: refactor handling of "--reference{,-if-able}" Patrick Steinhardt
2026-08-31 10:02   ` [PATCH v2 4/8] builtin/clone: move setup of alternates for shared local clones Patrick Steinhardt
2026-08-31 10:02   ` [PATCH v2 5/8] builtin/clone: move setup of alternates for non-shared " Patrick Steinhardt
2026-08-31 10:02   ` [PATCH v2 6/8] odb/source: support writing alternates when creating the database Patrick Steinhardt
2026-09-06 17:02     ` Justin Tobler
2026-09-07  7:23       ` Patrick Steinhardt
2026-08-31 10:02   ` [PATCH v2 7/8] builtin/clone: write alternates via `odb_create_on_disk()` Patrick Steinhardt
2026-09-06 17:07     ` Justin Tobler
2026-08-31 10:02   ` [PATCH v2 8/8] odb/source: remove the ability to write alternates Patrick Steinhardt
2026-09-01  6:09   ` [PATCH v2 0/8] odb: write alternates at creation time Toon Claes
2026-09-07  8:25 ` [PATCH v3 0/9] " Patrick Steinhardt
2026-09-07  8:25   ` [PATCH v3 1/9] setup: split up concerns of `init_db()` Patrick Steinhardt
2026-09-08 22:12     ` Justin Tobler
2026-09-09  5:48       ` Patrick Steinhardt
2026-09-07  8:25   ` [PATCH v3 2/9] builtin/clone: defer setup of the object database Patrick Steinhardt
2026-09-08 22:20     ` Justin Tobler
2026-09-09  5:48       ` Patrick Steinhardt
2026-09-07  8:25   ` [PATCH v3 3/9] builtin/clone: move around `setup_reference()` Patrick Steinhardt
2026-09-07  8:25   ` [PATCH v3 4/9] builtin/clone: refactor handling of "--reference{,-if-able}" Patrick Steinhardt
2026-09-07  8:25   ` [PATCH v3 5/9] builtin/clone: move setup of alternates for shared local clones Patrick Steinhardt
2026-09-08 22:43     ` Justin Tobler
2026-09-08 22:48       ` Justin Tobler
2026-09-07  8:25   ` [PATCH v3 6/9] builtin/clone: move setup of alternates for non-shared " Patrick Steinhardt
2026-09-07  8:25   ` [PATCH v3 7/9] odb/source: support writing alternates when creating the database Patrick Steinhardt
2026-09-07  8:25   ` [PATCH v3 8/9] builtin/clone: write alternates via `odb_create_on_disk()` Patrick Steinhardt
2026-09-07  8:25   ` [PATCH v3 9/9] odb/source: remove the ability to write alternates Patrick Steinhardt
2026-09-09  5:48 ` [PATCH v4 0/9] odb: write alternates at creation time Patrick Steinhardt
2026-09-09  5:48   ` [PATCH v4 1/9] setup: split up concerns of `init_db()` Patrick Steinhardt
2026-09-10  9:24     ` Karthik Nayak
2026-09-09  5:48   ` [PATCH v4 2/9] builtin/clone: defer setup of the object database Patrick Steinhardt
2026-09-10  9:28     ` Karthik Nayak
2026-09-09  5:48   ` [PATCH v4 3/9] builtin/clone: move around `setup_reference()` Patrick Steinhardt
2026-09-10  9:29     ` Karthik Nayak
2026-09-09  5:48   ` [PATCH v4 4/9] builtin/clone: refactor handling of "--reference{,-if-able}" Patrick Steinhardt
2026-09-10  9:37     ` Karthik Nayak
2026-09-10 14:26       ` Patrick Steinhardt
2026-09-09  5:48   ` [PATCH v4 5/9] builtin/clone: move setup of alternates for shared local clones Patrick Steinhardt
2026-09-10 10:52     ` Karthik Nayak
2026-09-10 10:54       ` Karthik Nayak
2026-09-10 14:26         ` Patrick Steinhardt
2026-09-09  5:48   ` [PATCH v4 6/9] builtin/clone: move setup of alternates for non-shared " Patrick Steinhardt
2026-09-10 11:00     ` Karthik Nayak
2026-09-09  5:48   ` [PATCH v4 7/9] odb/source: support writing alternates when creating the database Patrick Steinhardt
2026-09-10 11:10     ` Karthik Nayak
2026-09-11  5:15       ` Patrick Steinhardt [this message]
2026-09-09  5:48   ` [PATCH v4 8/9] builtin/clone: write alternates via `odb_create_on_disk()` Patrick Steinhardt
2026-09-09  5:48   ` [PATCH v4 9/9] odb/source: remove the ability to write alternates Patrick Steinhardt
2026-09-09 18:30   ` [PATCH v4 0/9] odb: write alternates at creation time Justin Tobler
2026-09-10 15:09 ` [PATCH v5 " Patrick Steinhardt
2026-09-10 15:09   ` [PATCH v5 1/9] setup: split up concerns of `init_db()` Patrick Steinhardt
2026-09-10 15:09   ` [PATCH v5 2/9] builtin/clone: defer setup of the object database Patrick Steinhardt
2026-09-10 15:09   ` [PATCH v5 3/9] builtin/clone: move around `setup_reference()` Patrick Steinhardt
2026-09-10 15:09   ` [PATCH v5 4/9] builtin/clone: refactor handling of "--reference{,-if-able}" Patrick Steinhardt
2026-09-10 15:09   ` [PATCH v5 5/9] builtin/clone: move setup of alternates for shared local clones Patrick Steinhardt
2026-09-10 15:09   ` [PATCH v5 6/9] builtin/clone: move setup of alternates for non-shared " Patrick Steinhardt
2026-09-10 15:09   ` [PATCH v5 7/9] odb/source: support writing alternates when creating the database Patrick Steinhardt
2026-09-10 15:09   ` [PATCH v5 8/9] builtin/clone: write alternates via `odb_create_on_disk()` Patrick Steinhardt
2026-09-10 15:09   ` [PATCH v5 9/9] odb/source: remove the ability to write alternates Patrick Steinhardt
2026-09-10 19:53   ` [PATCH v5 0/9] odb: write alternates at creation time Karthik Nayak
2026-09-11  5:15     ` 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=aqOOYI9v8M9VYeNN@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jltobler@gmail.com \
    --cc=karthik.188@gmail.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