From: Derrick Stolee <stolee@gmail.com>
To: Patrick Steinhardt <ps@pks.im>,
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com,
johannes.schindelin@gmx.de, peff@peff.net, me@ttaylorr.com,
johncai86@gmail.com, newren@gmail.com,
christian.couder@gmail.com, kristofferhaugsbakk@fastmail.com,
jonathantanmy@google.com, karthik.188@gmail.com,
Derrick Stolee <derrickstolee@github.com>
Subject: Re: [PATCH v2 2/5] backfill: basic functionality and tests
Date: Mon, 3 Feb 2025 09:44:49 -0500 [thread overview]
Message-ID: <718583a4-31e6-45d4-9807-c5a07050b28f@gmail.com> (raw)
In-Reply-To: <Z4jY3EQbC42scEIF@pks.im>
On 1/16/25 5:01 AM, Patrick Steinhardt wrote:
> On Fri, Dec 20, 2024 at 04:29:50PM +0000, Derrick Stolee via GitGitGadget wrote:
>> diff --git a/builtin/backfill.c b/builtin/backfill.c
>> index 38e6aaeaa03..177fd4286c7 100644
>> --- a/builtin/backfill.c
>> +++ b/builtin/backfill.c
> [snip]
>> +static int fill_missing_blobs(const char *path UNUSED,
>> + struct oid_array *list,
>> + enum object_type type,
>> + void *data)
>> +{
>> + struct backfill_context *ctx = data;
>> +
>> + if (type != OBJ_BLOB)
>> + return 0;
>> +
>> + for (size_t i = 0; i < list->nr; i++) {
>> + off_t size = 0;
>> + struct object_info info = OBJECT_INFO_INIT;
>> + info.disk_sizep = &size;
>> + if (oid_object_info_extended(ctx->repo,
>> + &list->oid[i],
>> + &info,
>> + OBJECT_INFO_FOR_PREFETCH) ||
>> + !size)
>
> So this is the object existence test? Is there a reason why we don't use
> `repo_has_object_file()`, or its `_with_flags()` variant if we need to
> pass `OBJECT_INFO_FOR_PREFETCH`?
You make a good point, but I also notice that repo_has_object_file() has
the following comment:
* These functions can be removed once all callers have migrated to
* has_object() and/or oid_object_info_extended().
so I'll use has_object().
>> + oid_array_append(&ctx->current_batch, &list->oid[i]);
>> + }
>> +
>> + if (ctx->current_batch.nr >= ctx->batch_size)
>> + download_batch(ctx);
>> +
>> + return 0;
>> +}
>> +
>> +static int do_backfill(struct backfill_context *ctx)
>> +{
>> + struct rev_info revs;
>> + struct path_walk_info info = PATH_WALK_INFO_INIT;
>> + int ret;
>> +
>> + repo_init_revisions(ctx->repo, &revs, "");
>> + handle_revision_arg("HEAD", &revs, 0, 0);
>> +
>> + info.blobs = 1;
>> + info.tags = info.commits = info.trees = 0;
>
> Nit: this should be unnecessary as PATH_WALK_INFO_INIT already
> initialized those fields for us, right?
The info.blobs is redundant, but is helpful for context. The
other line is necessary as PATH_WALK_INFO_INIT is defined as:
#define PATH_WALK_INFO_INIT { \
.blobs = 1, \
.trees = 1, \
.commits = 1, \
.tags = 1, \
}
>> + info.revs = &revs;
>> + info.path_fn = fill_missing_blobs;
>> + info.path_fn_data = ctx;
>> +
>> + ret = walk_objects_by_path(&info);
>> +
>> + /* Download the objects that did not fill a batch. */
>> + if (!ret)
>> + download_batch(ctx);
>> +
>> + backfill_context_clear(ctx);
>
> Nit: I think it's a bit funny that we're cleaning up the context over
> here rather than in the caller.
Cleaning up in the caller makes the "return do_backfill(&ctx);" line
slightly more complicated, but you are right that we shouldn't be
cleaning up something that the method "doesn't own".
Thanks,
-Stolee
next prev parent reply other threads:[~2025-02-03 14:44 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-06 20:07 [PATCH 0/5] PATH WALK III: Add 'git backfill' command Derrick Stolee via GitGitGadget
2024-12-06 20:07 ` [PATCH 1/5] backfill: add builtin boilerplate Derrick Stolee via GitGitGadget
2025-01-16 10:11 ` Patrick Steinhardt
2025-01-16 17:52 ` Junio C Hamano
2025-02-03 14:38 ` Derrick Stolee
2024-12-06 20:07 ` [PATCH 2/5] backfill: basic functionality and tests Derrick Stolee via GitGitGadget
2024-12-16 8:01 ` Patrick Steinhardt
2024-12-18 15:03 ` Derrick Stolee
2024-12-06 20:07 ` [PATCH 3/5] backfill: add --batch-size=<n> option Derrick Stolee via GitGitGadget
2024-12-16 8:01 ` Patrick Steinhardt
2024-12-18 15:09 ` Derrick Stolee
2025-01-19 17:57 ` Jean-Noël AVILA
2024-12-06 20:07 ` [PATCH 4/5] backfill: add --sparse option Derrick Stolee via GitGitGadget
2024-12-16 8:01 ` Patrick Steinhardt
2024-12-06 20:07 ` [PATCH 5/5] backfill: assume --sparse when sparse-checkout is enabled Derrick Stolee via GitGitGadget
2024-12-08 10:53 ` [PATCH 0/5] PATH WALK III: Add 'git backfill' command Junio C Hamano
2024-12-09 0:34 ` Junio C Hamano
2024-12-20 16:29 ` [PATCH v2 " Derrick Stolee via GitGitGadget
2024-12-20 16:29 ` [PATCH v2 1/5] backfill: add builtin boilerplate Derrick Stolee via GitGitGadget
2024-12-20 16:29 ` [PATCH v2 2/5] backfill: basic functionality and tests Derrick Stolee via GitGitGadget
2025-01-16 10:01 ` Patrick Steinhardt
2025-02-03 14:44 ` Derrick Stolee [this message]
2024-12-20 16:29 ` [PATCH v2 3/5] backfill: add --min-batch-size=<n> option Derrick Stolee via GitGitGadget
2025-01-16 10:01 ` Patrick Steinhardt
2024-12-20 16:29 ` [PATCH v2 4/5] backfill: add --sparse option Derrick Stolee via GitGitGadget
2025-01-16 10:01 ` Patrick Steinhardt
2025-02-03 15:11 ` Derrick Stolee
2024-12-20 16:29 ` [PATCH v2 5/5] backfill: assume --sparse when sparse-checkout is enabled Derrick Stolee via GitGitGadget
2025-01-16 10:00 ` [PATCH v2 0/5] PATH WALK III: Add 'git backfill' command Patrick Steinhardt
2025-01-17 22:37 ` Junio C Hamano
2025-02-03 17:11 ` [PATCH v3 " Derrick Stolee via GitGitGadget
2025-02-03 17:11 ` [PATCH v3 1/5] backfill: add builtin boilerplate Derrick Stolee via GitGitGadget
2025-02-03 17:11 ` [PATCH v3 2/5] backfill: basic functionality and tests Derrick Stolee via GitGitGadget
2025-02-03 17:11 ` [PATCH v3 3/5] backfill: add --min-batch-size=<n> option Derrick Stolee via GitGitGadget
2025-02-03 17:11 ` [PATCH v3 4/5] backfill: add --sparse option Derrick Stolee via GitGitGadget
2025-02-03 17:11 ` [PATCH v3 5/5] backfill: assume --sparse when sparse-checkout is enabled Derrick Stolee via GitGitGadget
2025-02-04 0:18 ` [PATCH v3 0/5] PATH WALK III: Add 'git backfill' command Junio C Hamano
2025-02-05 7:15 ` Patrick Steinhardt
2025-02-05 17:07 ` Junio C Hamano
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=718583a4-31e6-45d4-9807-c5a07050b28f@gmail.com \
--to=stolee@gmail.com \
--cc=christian.couder@gmail.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--cc=johncai86@gmail.com \
--cc=jonathantanmy@google.com \
--cc=karthik.188@gmail.com \
--cc=kristofferhaugsbakk@fastmail.com \
--cc=me@ttaylorr.com \
--cc=newren@gmail.com \
--cc=peff@peff.net \
--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).