Git development
 help / color / mirror / Atom feed
* [GSoC PATCH v2] backfill: auto-detect sparse-checkout from config
@ 2026-04-04 11:15 Trieu Huynh
  2026-04-04 17:36 ` Derrick Stolee
  0 siblings, 1 reply; 3+ messages in thread
From: Trieu Huynh @ 2026-04-04 11:15 UTC (permalink / raw)
  To: git; +Cc: gitster, stolee, Trieu Huynh

From: Trieu Huynh <vikingtc4@gmail.com>

Commit 85127bcdea ("backfill: assume --sparse when sparse-checkout is
enabled") intended for 'git backfill' to consult the repository
configuration when the user does not pass '--sparse' or
'--no-sparse' on the command line. It added the sentinel check:

    if (ctx->sparse < 0)
        ctx->sparse = cfg->apply_sparse_checkout;

However, the ctx->sparse field is initialized to 0 instead of -1,
so this guard never triggers. Consequently, the repository config
(core.sparseCheckout) is never checked, and the command always
performs a full backfill even when sparse-checkout is enabled.

Fix this by initializing ctx->sparse to -1, ensuring the existing
fallback logic correctly reads the repository configuration when
no explicit flags are provided.

Add a test to verify that 'git backfill' automatically respects
sparse-checkout settings when no flags are passed.

Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
v2:
  - Update commit message to explicitly point to addressing 85127bcdea.
  - The code change itself is unchanged.

 builtin/backfill.c  |  2 +-
 t/t5620-backfill.sh | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/builtin/backfill.c b/builtin/backfill.c
index e80fc1b694..54acdfe290 100644
--- a/builtin/backfill.c
+++ b/builtin/backfill.c
@@ -120,7 +120,7 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit
 		.repo = repo,
 		.current_batch = OID_ARRAY_INIT,
 		.min_batch_size = 50000,
-		.sparse = 0,
+		.sparse = -1,
 	};
 	struct option options[] = {
 		OPT_UNSIGNED(0, "min-batch-size", &ctx.min_batch_size,
diff --git a/t/t5620-backfill.sh b/t/t5620-backfill.sh
index 58c81556e7..bed4987124 100755
--- a/t/t5620-backfill.sh
+++ b/t/t5620-backfill.sh
@@ -119,6 +119,21 @@ test_expect_success 'backfill --sparse' '
 	test_line_count = 0 missing
 '
 
+test_expect_success 'backfill auto-detects sparse-checkout from config' '
+	git clone --sparse --filter=blob:none \
+		--single-branch --branch=main \
+		"file://$(pwd)/srv.bare" backfill-auto-sparse &&
+
+	git -C backfill-auto-sparse rev-list --quiet --objects --missing=print HEAD >missing &&
+	test_line_count = 44 missing &&
+
+	GIT_TRACE2_EVENT="$(pwd)/auto-sparse-trace" git \
+		-C backfill-auto-sparse backfill &&
+
+	test_trace2_data promisor fetch_count 4 <auto-sparse-trace &&
+	test_trace2_data path-walk paths 5 <auto-sparse-trace
+'
+
 test_expect_success 'backfill --sparse without cone mode (positive)' '
 	git clone --no-checkout --filter=blob:none		\
 		--single-branch --branch=main 		\
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [GSoC PATCH v2] backfill: auto-detect sparse-checkout from config
  2026-04-04 11:15 [GSoC PATCH v2] backfill: auto-detect sparse-checkout from config Trieu Huynh
@ 2026-04-04 17:36 ` Derrick Stolee
  2026-04-06 16:27   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Derrick Stolee @ 2026-04-04 17:36 UTC (permalink / raw)
  To: Trieu Huynh, git; +Cc: gitster

On 4/4/26 7:15 AM, Trieu Huynh wrote:
> From: Trieu Huynh <vikingtc4@gmail.com>
> 
> Commit 85127bcdea ("backfill: assume --sparse when sparse-checkout is
> enabled") intended for 'git backfill' to consult the repository
> configuration when the user does not pass '--sparse' or
> '--no-sparse' on the command line. It added the sentinel check:
> 
>      if (ctx->sparse < 0)
>          ctx->sparse = cfg->apply_sparse_checkout;
> 
> However, the ctx->sparse field is initialized to 0 instead of -1,
> so this guard never triggers. Consequently, the repository config
> (core.sparseCheckout) is never checked, and the command always
> performs a full backfill even when sparse-checkout is enabled.

Thanks for adding this context. This patch LGTM.

nit: it helps to reply to your previous version [1] so the history
of your patch series shows up in a single thread. No need to fix it
now because this version should be final. I'm a fan of using
GitGitGadget to avoid making these kinds of mistakes, but you can
use 'git send-email --in-reply-to=<id>' [2] in the future.

[1] https://lore.kernel.org/git/20260402191359.11304-1-viking4@gmail.com/

[2] 
https://git-scm.com/docs/git-send-email#Documentation/git-send-email.txt---in-reply-toidentifier

Thanks,
-Stolee


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [GSoC PATCH v2] backfill: auto-detect sparse-checkout from config
  2026-04-04 17:36 ` Derrick Stolee
@ 2026-04-06 16:27   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2026-04-06 16:27 UTC (permalink / raw)
  To: Derrick Stolee; +Cc: Trieu Huynh, git

Derrick Stolee <stolee@gmail.com> writes:

> On 4/4/26 7:15 AM, Trieu Huynh wrote:
>> From: Trieu Huynh <vikingtc4@gmail.com>
>> 
>> Commit 85127bcdea ("backfill: assume --sparse when sparse-checkout is
>> enabled") intended for 'git backfill' to consult the repository
>> configuration when the user does not pass '--sparse' or
>> '--no-sparse' on the command line. It added the sentinel check:
>> 
>>      if (ctx->sparse < 0)
>>          ctx->sparse = cfg->apply_sparse_checkout;
>> 
>> However, the ctx->sparse field is initialized to 0 instead of -1,
>> so this guard never triggers. Consequently, the repository config
>> (core.sparseCheckout) is never checked, and the command always
>> performs a full backfill even when sparse-checkout is enabled.
>
> Thanks for adding this context. This patch LGTM.

Yup, thanks, both of you.  The original patch without this
explanation may not be so obvious but after taking a look at what
that commit did, it is very clear what went wrong.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-06 16:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-04 11:15 [GSoC PATCH v2] backfill: auto-detect sparse-checkout from config Trieu Huynh
2026-04-04 17:36 ` Derrick Stolee
2026-04-06 16:27   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox