Git development
 help / color / mirror / Atom feed
From: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 3/6] object-file: move iteration over loose files into backend
Date: Tue, 10 Nov 2026 19:27:58 +0530	[thread overview]
Message-ID: <79a2222b-2087-460f-b4c8-c24c3b7c087c@gmail.com> (raw)
In-Reply-To: <20261102-pks-odb-loose-cleanups-v1-3-fbbc86c29693@pks.im>

On 11/2/26 16:50, Patrick Steinhardt wrote:
> The logic to iterate over files part of the "loose" backend is contained
> in "object-file.c" even though it's an implementation detail of the
> backend itself. Move the logic into the backend accordingly.
> 
> Note that the function is a bit on the weird side: it accepts a generic
> `struct odb_source` as input and doesn't cast it down to its backend at
> all. This is because all it requires access to is the `path` member of
> the source, and from thereon it knows how to iterate the subdirectories
> of the "loose" backend.
> 
> We should adapt this function to accept `struct odb_source_loose` to
> properly reflect that it expects a path to a loose object database. But
> that would require changes to a bunch of callers without much benefit.
> So for now, the function signature is left as-is. But eventually we may
> want to change it once we have reworked a couple of its callers.
> 
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>   builtin/count-objects.c |  1 +
>   builtin/gc.c            |  1 +
>   builtin/prune.c         |  1 +
>   object-file.c           | 92 -------------------------------------------------
>   object-file.h           | 44 -----------------------
>   odb/source-loose.c      | 92 +++++++++++++++++++++++++++++++++++++++++++++++++
>   odb/source-loose.h      | 33 ++++++++++++++++++
>   prune-packed.c          |  1 +
>   8 files changed, 129 insertions(+), 136 deletions(-)
> 
> diff --git a/builtin/count-objects.c b/builtin/count-objects.c
> index 3f7b20fde53..aae040567e3 100644
> --- a/builtin/count-objects.c
> +++ b/builtin/count-objects.c
> @@ -14,6 +14,7 @@
>   #include "quote.h"
>   #include "packfile.h"
>   #include "object-file.h"
> +#include "odb/source-loose.h"
>   

It seems like we can remove the include of object-file.h while at it.
>   static unsigned long garbage;
>   static off_t size_garbage;
> diff --git a/builtin/gc.c b/builtin/gc.c
> index 81cecf6b6c3..d3ba6f0c9e9 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -31,6 +31,7 @@
>   #include "packfile.h"
>   #include "object-file.h"
>   #include "odb.h"
> +#include "odb/source-loose.h"
>   #include "path.h"
>   #include "reflog.h"
>   #include "rerere.h"
> diff --git a/builtin/prune.c b/builtin/prune.c
> index 97f4c1418bc..af2a547d931 100644
> --- a/builtin/prune.c
> +++ b/builtin/prune.c
> @@ -17,6 +17,7 @@
>   #include "object-file.h"
>   #include "object-name.h"
>   #include "odb.h"
> +#include "odb/source-loose.h"
>   #include "shallow.h"
>   

Ditto for the above two.

>   
> +static int for_each_file_in_obj_subdir(unsigned int subdir_nr,
> +				       struct strbuf *path,
> +				       const struct git_hash_algo *algop,
> +				       each_loose_object_fn obj_cb,
> +				       each_loose_cruft_fn cruft_cb,
> +				       each_loose_subdir_fn subdir_cb,
> +				       void *data)

This was made 'static' during the move but that seems to make sense to me.

> diff --git a/prune-packed.c b/prune-packed.c
> index b6749b8d132..d0a8a062b97 100644
> --- a/prune-packed.c
> +++ b/prune-packed.c
> @@ -3,6 +3,7 @@
>   #include "git-compat-util.h"
>   #include "gettext.h"
>   #include "object-file.h"
> +#include "odb/source-loose.h"

This could also benefit from losing the include of object-file.h

Rest of the patch looks good to me.

-- 
Sivaraam


  reply	other threads:[~2026-11-10 13:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02 11:20 [PATCH 0/6] object-file: move logic related to the loose backend Patrick Steinhardt
2026-11-02 11:20 ` [PATCH 1/6] object-file: move logic to read loose objects into backend Patrick Steinhardt
2026-11-10 13:10   ` Kaartic Sivaraam
2026-11-11 13:38     ` Patrick Steinhardt
2026-11-02 11:20 ` [PATCH 2/6] object-file: move logic to derive loose object paths " Patrick Steinhardt
2026-11-10 13:28   ` Kaartic Sivaraam
2026-11-11 13:40     ` Patrick Steinhardt
2026-11-02 11:20 ` [PATCH 3/6] object-file: move iteration over loose files " Patrick Steinhardt
2026-11-10 13:57   ` Kaartic Sivaraam [this message]
2026-11-02 11:20 ` [PATCH 4/6] odb/source-loose: deduplicate logic to mmap objects Patrick Steinhardt
2026-11-10 14:15   ` Kaartic Sivaraam
2026-11-11 13:40     ` Patrick Steinhardt
2026-11-02 11:20 ` [PATCH 5/6] object-file: stop including "odb/source-loose.h" Patrick Steinhardt
2026-11-10 16:13   ` Kaartic Sivaraam
2026-11-11 13:40     ` Patrick Steinhardt
2026-11-02 11:20 ` [PATCH 6/6] object-file: stop including "git-zlib.h" Patrick Steinhardt
2026-11-10 16:13   ` Kaartic Sivaraam

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=79a2222b-2087-460f-b4c8-c24c3b7c087c@gmail.com \
    --to=kaartic.sivaraam@gmail.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