@@ -9,7 +9,7 @@ git-backfill - Download missing objects in a partial clone
SYNOPSIS
--------
[verse]
-'git backfill' [<options>]
+'git backfill' [--batch-size=<n>]
DESCRIPTION
-----------
@@ -45,6 +45,15 @@ time.
By default, `git backfill` downloads all blobs reachable from the `HEAD`
commit. This set can be restricted or expanded using various options.
+OPTIONS
+-------
+
+--min-batch-size=<n>::
+ Specify a minimum size for a batch of missing objects to request
+ from the server. This size may be exceeded by the last set of
+ blobs seen at a given path. The default minimum batch size is
+ 50,000.
+
SEE ALSO
--------
linkgit:git-clone[1].
@@ -21,14 +21,14 @@
#include "path-walk.h"
static const char * const builtin_backfill_usage[] = {
- N_("git backfill [<options>]"),
+ N_("git backfill [--batch-size=<n>]"),
NULL
};
struct backfill_context {
struct repository *repo;
struct oid_array current_batch;
- size_t batch_size;
+ size_t min_batch_size;
};
static void backfill_context_clear(struct backfill_context *ctx)
@@ -72,7 +72,7 @@ static int fill_missing_blobs(const char *path UNUSED,
oid_array_append(&ctx->current_batch, &list->oid[i]);
}
- if (ctx->current_batch.nr >= ctx->batch_size)
+ if (ctx->current_batch.nr >= ctx->min_batch_size)
download_batch(ctx);
return 0;
@@ -111,9 +111,11 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit
struct backfill_context ctx = {
.repo = repo,
.current_batch = OID_ARRAY_INIT,
- .batch_size = 50000,
+ .min_batch_size = 50000,
};
struct option options[] = {
+ OPT_INTEGER(0, "min-batch-size", &ctx.min_batch_size,
+ N_("Minimum number of objects to request at a time")),
OPT_END(),
};
@@ -59,6 +59,24 @@ test_expect_success 'do partial clone 1, backfill gets all objects' '
test_line_count = 0 revs2
'
+test_expect_success 'do partial clone 2, backfill min batch size' '
+ git clone --no-checkout --filter=blob:none \
+ --single-branch --branch=main \
+ "file://$(pwd)/srv.bare" backfill2 &&
+
+ GIT_TRACE2_EVENT="$(pwd)/batch-trace" git \
+ -C backfill2 backfill --min-batch-size=20 &&
+
+ # Batches were used
+ test_trace2_data promisor fetch_count 20 <batch-trace >matches &&
+ test_line_count = 2 matches &&
+ test_trace2_data promisor fetch_count 8 <batch-trace &&
+
+ # No more missing objects!
+ git -C backfill2 rev-list --quiet --objects --missing=print HEAD >revs2 &&
+ test_line_count = 0 revs2
+'
+
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd