From: Derrick Stolee Date: Fri, 22 May 2026 18:24:30 +0000 (+0000) Subject: backfill: die on incompatible filter options X-Git-Tag: v2.55.0-rc0~26^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf24de4b7cd5f30b1539c8e8a25cca5b92d9b621;p=thirdparty%2Fgit.git 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 Signed-off-by: Junio C Hamano --- diff --git a/builtin/backfill.c b/builtin/backfill.c index 7ffab2ea74..b80f9ebe69 100644 --- a/builtin/backfill.c +++ b/builtin/backfill.c @@ -96,9 +96,8 @@ static void reject_unsupported_rev_list_options(struct rev_info *revs) if (revs->explicit_diff_merges) die(_("'%s' cannot be used with 'git backfill'"), "--diff-merges"); - if (revs->filter.choice) - die(_("'%s' cannot be used with 'git backfill'"), - "--filter"); + if (!path_walk_filter_compatible(&revs->filter)) + die(_("cannot backfill with these filter options")); } static int do_backfill(struct backfill_context *ctx) diff --git a/t/t5620-backfill.sh b/t/t5620-backfill.sh index 94f35ce190..ede89f8c33 100755 --- a/t/t5620-backfill.sh +++ b/t/t5620-backfill.sh @@ -15,6 +15,14 @@ test_expect_success 'backfill rejects unexpected arguments' ' test_grep "unrecognized argument: --unexpected-arg" err ' +test_expect_success 'backfill rejects incompatible filter options' ' + test_must_fail git backfill --objects --filter=tree:1 2>err && + test_grep "cannot backfill with these filter options" err && + + test_must_fail git backfill --objects --filter=blob:limit=10m 2>err && + test_grep "cannot backfill with these filter options" err +' + # We create objects in the 'src' repo. test_expect_success 'setup repo for object creation' ' echo "{print \$1}" >print_1.awk &&