{"thread":{"id":"65432","subject":"[GSoC PATCH v2] backfill: auto-detect sparse-checkout from config","startedAt":"2026-04-04T11:16:05Z","lastAt":"2026-04-06T16:27:43Z","messageCount":3,"participants":["Trieu Huynh","Derrick Stolee","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"540886","messageId":"20260404111557.17220-1-viking4@gmail.com","threadId":"65432","inReplyTo":null,"subject":"[GSoC PATCH v2] backfill: auto-detect sparse-checkout from config","fromName":"Trieu Huynh","fromEmail":"vikingtc4@gmail.com","sentAt":"2026-04-04T11:15:57Z","receivedAt":"2026-04-04T11:16:05Z","isPatch":true,"body":"From: Trieu Huynh <vikingtc4@gmail.com>\n\nCommit 85127bcdea (\"backfill: assume --sparse when sparse-checkout is\nenabled\") intended for 'git backfill' to consult the repository\nconfiguration when the user does not pass '--sparse' or\n'--no-sparse' on the command line. It added the sentinel check:\n\n    if (ctx->sparse < 0)\n        ctx->sparse = cfg->apply_sparse_checkout;\n\nHowever, the ctx->sparse field is initialized to 0 instead of -1,\nso this guard never triggers. Consequently, the repository config\n(core.sparseCheckout) is never checked, and the command always\nperforms a full backfill even when sparse-checkout is enabled.\n\nFix this by initializing ctx->sparse to -1, ensuring the existing\nfallback logic correctly reads the repository configuration when\nno explicit flags are provided.\n\nAdd a test to verify that 'git backfill' automatically respects\nsparse-checkout settings when no flags are passed.\n\nSigned-off-by: Trieu Huynh <vikingtc4@gmail.com>\n---\nv2:\n  - Update commit message to explicitly point to addressing 85127bcdea.\n  - The code change itself is unchanged.\n\n builtin/backfill.c  |  2 +-\n t/t5620-backfill.sh | 15 +++++++++++++++\n 2 files changed, 16 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/backfill.c b/builtin/backfill.c\nindex e80fc1b694..54acdfe290 100644\n--- a/builtin/backfill.c\n+++ b/builtin/backfill.c\n@@ -120,7 +120,7 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit\n \t\t.repo = repo,\n \t\t.current_batch = OID_ARRAY_INIT,\n \t\t.min_batch_size = 50000,\n-\t\t.sparse = 0,\n+\t\t.sparse = -1,\n \t};\n \tstruct option options[] = {\n \t\tOPT_UNSIGNED(0, \"min-batch-size\", &ctx.min_batch_size,\ndiff --git a/t/t5620-backfill.sh b/t/t5620-backfill.sh\nindex 58c81556e7..bed4987124 100755\n--- a/t/t5620-backfill.sh\n+++ b/t/t5620-backfill.sh\n@@ -119,6 +119,21 @@ test_expect_success 'backfill --sparse' '\n \ttest_line_count = 0 missing\n '\n \n+test_expect_success 'backfill auto-detects sparse-checkout from config' '\n+\tgit clone --sparse --filter=blob:none \\\n+\t\t--single-branch --branch=main \\\n+\t\t\"file://$(pwd)/srv.bare\" backfill-auto-sparse &&\n+\n+\tgit -C backfill-auto-sparse rev-list --quiet --objects --missing=print HEAD >missing &&\n+\ttest_line_count = 44 missing &&\n+\n+\tGIT_TRACE2_EVENT=\"$(pwd)/auto-sparse-trace\" git \\\n+\t\t-C backfill-auto-sparse backfill &&\n+\n+\ttest_trace2_data promisor fetch_count 4 <auto-sparse-trace &&\n+\ttest_trace2_data path-walk paths 5 <auto-sparse-trace\n+'\n+\n test_expect_success 'backfill --sparse without cone mode (positive)' '\n \tgit clone --no-checkout --filter=blob:none\t\t\\\n \t\t--single-branch --branch=main \t\t\\\n-- \n2.43.0\n\n"},{"id":"540909","messageId":"e16edc29-a281-42f8-a712-4114d6a3288c@gmail.com","threadId":"65432","inReplyTo":"20260404111557.17220-1-viking4@gmail.com","subject":"Re: [GSoC PATCH v2] backfill: auto-detect sparse-checkout from config","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2026-04-04T17:36:52Z","receivedAt":"2026-04-04T17:37:02Z","isPatch":true,"body":"On 4/4/26 7:15 AM, Trieu Huynh wrote:\n> From: Trieu Huynh <vikingtc4@gmail.com>\n> \n> Commit 85127bcdea (\"backfill: assume --sparse when sparse-checkout is\n> enabled\") intended for 'git backfill' to consult the repository\n> configuration when the user does not pass '--sparse' or\n> '--no-sparse' on the command line. It added the sentinel check:\n> \n>      if (ctx->sparse < 0)\n>          ctx->sparse = cfg->apply_sparse_checkout;\n> \n> However, the ctx->sparse field is initialized to 0 instead of -1,\n> so this guard never triggers. Consequently, the repository config\n> (core.sparseCheckout) is never checked, and the command always\n> performs a full backfill even when sparse-checkout is enabled.\n\nThanks for adding this context. This patch LGTM.\n\nnit: it helps to reply to your previous version [1] so the history\nof your patch series shows up in a single thread. No need to fix it\nnow because this version should be final. I'm a fan of using\nGitGitGadget to avoid making these kinds of mistakes, but you can\nuse 'git send-email --in-reply-to=<id>' [2] in the future.\n\n[1] https://lore.kernel.org/git/20260402191359.11304-1-viking4@gmail.com/\n\n[2] \nhttps://git-scm.com/docs/git-send-email#Documentation/git-send-email.txt---in-reply-toidentifier\n\nThanks,\n-Stolee\n\n"},{"id":"540980","messageId":"xmqqjyukcav6.fsf@gitster.g","threadId":"65432","inReplyTo":"e16edc29-a281-42f8-a712-4114d6a3288c@gmail.com","subject":"Re: [GSoC PATCH v2] backfill: auto-detect sparse-checkout from config","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-04-06T16:27:41Z","receivedAt":"2026-04-06T16:27:43Z","isPatch":true,"body":"Derrick Stolee <stolee@gmail.com> writes:\n\n> On 4/4/26 7:15 AM, Trieu Huynh wrote:\n>> From: Trieu Huynh <vikingtc4@gmail.com>\n>> \n>> Commit 85127bcdea (\"backfill: assume --sparse when sparse-checkout is\n>> enabled\") intended for 'git backfill' to consult the repository\n>> configuration when the user does not pass '--sparse' or\n>> '--no-sparse' on the command line. It added the sentinel check:\n>> \n>>      if (ctx->sparse < 0)\n>>          ctx->sparse = cfg->apply_sparse_checkout;\n>> \n>> However, the ctx->sparse field is initialized to 0 instead of -1,\n>> so this guard never triggers. Consequently, the repository config\n>> (core.sparseCheckout) is never checked, and the command always\n>> performs a full backfill even when sparse-checkout is enabled.\n>\n> Thanks for adding this context. This patch LGTM.\n\nYup, thanks, both of you.  The original patch without this\nexplanation may not be so obvious but after taking a look at what\nthat commit did, it is very clear what went wrong.\n\n"}]}