Skip to content

Commit 6b79aee

Browse files
newrengitster
authored andcommitted
backfill: reject rev-list arguments that do not make sense
Some rev-list options accepted by setup_revisions() are silently ignored or actively counterproductive when used with 'git backfill', because the path-walk API has its own tree-walking logic that bypasses the mechanisms these options rely on: * -S/-G (pickaxe) and --diff-filter work by computing per-commit diffs in get_revision_1() and filtering commits whose diffs don't match. Since backfill's goal is to download all blobs reachable from commits in the range, filtering out commits based on diff content would silently skip blobs -- the opposite of what users want. * --follow disables path pruning (revs->prune) and only makes sense for tracking a single file through renames in log output. It has no useful interaction with backfill. * -L (line-log) computes line-level diffs to track the evolution of a function or line range. Like pickaxe, it filters commits based on diff content, which would cause blobs to be silently skipped. * --diff-merges controls how merge commit diffs are displayed. The path-walk API walks trees directly and never computes per-commit diffs, so this option would be silently ignored. * --filter (object filtering, e.g. --filter=blob:none) is used by the list-objects traversal but is completely ignored by the path-walk API, so it would silently do nothing. Rather than letting users think these options are being honored, reject them with a clear error message. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9f223ef commit 6b79aee

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

builtin/backfill.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,28 @@ static int fill_missing_blobs(const char *path UNUSED,
7878
return 0;
7979
}
8080

81+
static void reject_unsupported_rev_list_options(struct rev_info *revs)
82+
{
83+
if (revs->diffopt.pickaxe)
84+
die(_("'%s' cannot be used with 'git backfill'"),
85+
(revs->diffopt.pickaxe_opts & DIFF_PICKAXE_REGEX) ? "-G" : "-S");
86+
if (revs->diffopt.filter || revs->diffopt.filter_not)
87+
die(_("'%s' cannot be used with 'git backfill'"),
88+
"--diff-filter");
89+
if (revs->diffopt.flags.follow_renames)
90+
die(_("'%s' cannot be used with 'git backfill'"),
91+
"--follow");
92+
if (revs->line_level_traverse)
93+
die(_("'%s' cannot be used with 'git backfill'"),
94+
"-L");
95+
if (revs->explicit_diff_merges)
96+
die(_("'%s' cannot be used with 'git backfill'"),
97+
"--diff-merges");
98+
if (revs->filter.choice)
99+
die(_("'%s' cannot be used with 'git backfill'"),
100+
"--filter");
101+
}
102+
81103
static int do_backfill(struct backfill_context *ctx)
82104
{
83105
struct path_walk_info info = PATH_WALK_INFO_INIT;
@@ -144,6 +166,7 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit
144166

145167
if (argc > 1)
146168
die(_("unrecognized argument: %s"), argv[1]);
169+
reject_unsupported_rev_list_options(&ctx.revs);
147170

148171
repo_config(repo, git_default_config, NULL);
149172

0 commit comments

Comments
 (0)