]> git.ipfire.org Git - thirdparty/git.git/commitdiff
backfill: die on incompatible filter options
authorDerrick Stolee <stolee@gmail.com>
Fri, 22 May 2026 18:24:30 +0000 (18:24 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 24 May 2026 09:41:06 +0000 (18:41 +0900)
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>
builtin/backfill.c
t/t5620-backfill.sh

index 7ffab2ea74f5cc7ed98587fa8e26f3746d18a163..b80f9ebe691080e50d098242d846da129cff38ce 100644 (file)
@@ -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)
index 94f35ce19016716b2ca8c22faffaa8a05fb3e7a6..ede89f8c333ca3415b4b50ac309456df7d675956 100755 (executable)
@@ -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 &&