[PATCH] backfill: handle unexpected arguments
- From
Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
- Date
- Mar 21, 2026, 03:16 UTC
- Message-ID
- <20260321031643.5185-1-r.siddharth.shrimali@gmail.com>
git backfill takes no non-option arguments. However, if extra arguments are passed with git backfill, parse_options() leaves them in argc and the command currently ignores them silently, giving the user no indication that something is wrong.
Add a check after parse_options() to call usage_with_options() if any unexpected arguments remain. This prints the correct usage and exits with an error, consistent with how other Git commands such as git-gc and git-repack handle this situation.
Signed-off-by: Siddharth Shrimali <r.siddharth.shrimali@gmail.com> --- builtin/backfill.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/builtin/backfill.c b/builtin/backfill.c index e9a33e81be..0eb171478a 100644 --- a/builtin/backfill.c +++ b/builtin/backfill.c @@ -135,6 +135,9 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit argc = parse_options(argc, argv, prefix, options, builtin_backfill_usage, 0); + + if (argc) + usage_with_options(builtin_backfill_usage, options); repo_config(repo, git_default_config, NULL);
-- 2.51.2