backfill: die on incompatible filter options

The 'git backfill' command uses the path-walk API in a critical way: it uses the objects output from the command to find the batches of missing objects that should be requested from the server. Unlike 'git pack-objects', we cannot fall back to another mechanism. The previous change added the path_walk_filter_compatible() method that we can reuse here. Use it during argument validation in cmd_backfill(). Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed May 22, 2026 at 18:24 UTC bf24de4b7cd5f30b1539c8e8a25cca5b92d9b621
2 files changed +10 -3
builtin/backfill.c
+2 -3
@@ -96,9 +96,8 @@ static void reject_unsupported_rev_list_options(struct rev_info *revs)
96 if (revs->explicit_diff_merges)
97 die(_("'%s' cannot be used with 'git backfill'"),
98 "--diff-merges");
99 - if (revs->filter.choice)
100 - die(_("'%s' cannot be used with 'git backfill'"),
101 - "--filter");
99 + if (!path_walk_filter_compatible(&revs->filter))
100 + die(_("cannot backfill with these filter options"));
101 }
102
103 static int do_backfill(struct backfill_context *ctx)
t/t5620-backfill.sh
+8
@@ -15,6 +15,14 @@ test_expect_success 'backfill rejects unexpected arguments' '
15 test_grep "unrecognized argument: --unexpected-arg" err
16 '
17
18 +test_expect_success 'backfill rejects incompatible filter options' '
19 + test_must_fail git backfill --objects --filter=tree:1 2>err &&
20 + test_grep "cannot backfill with these filter options" err &&
21 +
22 + test_must_fail git backfill --objects --filter=blob:limit=10m 2>err &&
23 + test_grep "cannot backfill with these filter options" err
24 +'
25 +
26 # We create objects in the 'src' repo.
27 test_expect_success 'setup repo for object creation' '
28 echo "{print \$1}" >print_1.awk &&