git/list[1] front-page[2] threads[3] people[4] search[5] about
wed 2026-10-07 16:26 UTC

[GSoC PATCH] backfill: add --[no-]progress option

From
Trieu Huynh <vikingtc4@gmail.com>
Date
Mar 29, 2026, 15:24 UTC
Message-ID
<20260329152443.525493-1-vikingtc4@gmail.com>

'git backfill' is silent when downloading missing objects, giving no feedback during potentially long-running operations on large repositories. By contrast, 'git fetch', 'git gc', and 'git index-pack' all support --[no-]progress.

Add a --[no-]progress option to 'git backfill' by:
 - Calling display_progress() in download_batch() to advance the
   counter after each batch is fetched.
 - Defaulting to showing progress when stderr is a terminal
   (isatty(2)), matching the behaviour of 'git fetch'.
 - Allowing the user to override the default via --[no-]progress.

nit: progress.h was already included but unused, this commit puts it to use.

Add tests to verify that:
 - --progress shows "Downloading batches" on stderr.
 - --no-progress suppresses output even on a TTY.
 - No flag on a non-TTY is silent (isatty default).
Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
---
 builtin/backfill.c  | 16 ++++++++++++++++
 t/t5620-backfill.sh | 24 ++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
diff --git a/builtin/backfill.c b/builtin/backfill.c
index e9a33e81be..27a301f9b2 100644
--- a/builtin/backfill.c
+++ b/builtin/backfill.c
@@ -35,6 +35,9 @@ struct backfill_context {
 	struct oid_array current_batch;
 	size_t min_batch_size;
 	int sparse;
+	int show_progress;
+	size_t batches_requested;
+	struct progress *progress;
 };
 
 static void backfill_context_clear(struct backfill_context *ctx)
@@ -54,6 +57,7 @@ static void download_batch(struct backfill_context *ctx)
 	 * avoid possible duplicate downloads of the same objects.
 	 */
 	odb_reprepare(ctx->repo->objects);
+	display_progress(ctx->progress, ++ctx->batches_requested);
 }
 
 static int fill_missing_blobs(const char *path UNUSED,
@@ -120,12 +124,15 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit
 		.current_batch = OID_ARRAY_INIT,
 		.min_batch_size = 50000,
 		.sparse = 0,
+		.show_progress = -1,
 	};
 	struct option options[] = {
 		OPT_UNSIGNED(0, "min-batch-size", &ctx.min_batch_size,
 			     N_("Minimum number of objects to request at a time")),
 		OPT_BOOL(0, "sparse", &ctx.sparse,
 			 N_("Restrict the missing objects to the current sparse-checkout")),
+		OPT_BOOL(0, "progress", &ctx.show_progress,
+			 N_("show progress while downloading missing objects")),
 		OPT_END(),
 	};
 	struct repo_config_values *cfg = repo_config_values(the_repository);
@@ -141,7 +148,16 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit
 	if (ctx.sparse < 0)
 		ctx.sparse = cfg->apply_sparse_checkout;
 
+	if (ctx.show_progress < 0)
+		ctx.show_progress = isatty(2);
+
+	if (ctx.show_progress)
+		ctx.progress = start_progress(ctx.repo, _("Downloading batches"), 0);
+
 	result = do_backfill(&ctx);
+	if (ctx.show_progress)
+		stop_progress(&ctx.progress);
+
 	backfill_context_clear(&ctx);
 	return result;
 }
diff --git a/t/t5620-backfill.sh b/t/t5620-backfill.sh
index 58c81556e7..ff67e8ecea 100755
--- a/t/t5620-backfill.sh
+++ b/t/t5620-backfill.sh
@@ -77,6 +77,30 @@ test_expect_success 'do partial clone 2, backfill min batch size' '
 	test_line_count = 0 revs2
 '
 
+test_expect_success 'backfill --progress shows progress' '
+	git clone --no-checkout --filter=blob:none \
+		--single-branch --branch=main \
+		"file://$(pwd)/srv.bare" clone-progress &&
+	git -C clone-progress backfill --progress 2>err &&
+	test_grep "Downloading batches" err
+'
+
+test_expect_success 'backfill --no-progress is silent' '
+	git clone --no-checkout --filter=blob:none \
+		--single-branch --branch=main \
+		"file://$(pwd)/srv.bare" clone-no-progress &&
+	git -C clone-no-progress backfill --no-progress 2>err &&
+	test_grep ! "Downloading batches" err
+'
+
+test_expect_success 'backfill no flag on non-TTY is silent' '
+	git clone --no-checkout --filter=blob:none \
+		--single-branch --branch=main \
+		"file://$(pwd)/srv.bare" clone-notty &&
+	git -C clone-notty backfill 2>err &&
+	test_grep ! "Downloading batches" err
+'
+
 test_expect_success 'backfill --sparse without sparse-checkout fails' '
 	git init not-sparse &&
 	test_must_fail git -C not-sparse backfill --sparse 2>err &&
-- 
2.43.0
Next: Derrick Stolee
Message 1 of 6 in “backfill: add --[no-]progress option”
  1. backfill: add --[no-]progress optionTrieu Huynh, Mar 29, 2026
  2. Derrick StoleeApr 6, 2026
  3. Junio C HamanoApr 6, 2026
  4. Trieu HuynhApr 7, 2026
  5. Trieu HuynhApr 7, 2026
  6. Junio C HamanoApr 7, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.