`--[no-]sparse`::
Only download objects if they appear at a path that matches the
- current sparse-checkout.
+ current sparse-checkout. If the sparse-checkout feature is enabled,
+ then `--sparse` is assumed and can be disabled with `--no-sparse`.
SEE ALSO
--------
+/* We need this macro to access core_apply_sparse_checkout */
+#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "git-compat-util.h"
#include "config.h"
#include "repository.h"
#include "commit.h"
#include "dir.h"
+#include "environment.h"
#include "hex.h"
#include "tree.h"
#include "tree-walk.h"
repo_config(repo, git_default_config, NULL);
+ if (ctx.sparse < 0)
+ ctx.sparse = core_apply_sparse_checkout;
+
result = do_backfill(&ctx);
backfill_context_clear(&ctx);
return result;
test_line_count = 0 revs2
'
+test_expect_success 'backfill --sparse without sparse-checkout fails' '
+ git init not-sparse &&
+ test_must_fail git -C not-sparse backfill --sparse 2>err &&
+ grep "problem loading sparse-checkout" err
+'
+
test_expect_success 'backfill --sparse' '
git clone --sparse --filter=blob:none \
--single-branch --branch=main \
test_trace2_data promisor fetch_count 8 <sparse-trace2 &&
test_trace2_data path-walk paths 15 <sparse-trace2 &&
git -C backfill3 rev-list --quiet --objects --missing=print HEAD >missing &&
- test_line_count = 24 missing
+ test_line_count = 24 missing &&
+
+ # Disabling the --sparse option (on by default) will download everything
+ git -C backfill3 backfill --no-sparse &&
+ git -C backfill3 rev-list --quiet --objects --missing=print HEAD >missing &&
+ test_line_count = 0 missing
'
test_expect_success 'backfill --sparse without cone mode (positive)' '