From: Phillip Wood <phillip.wood123@gmail.com>
To: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>, git@vger.kernel.org
Cc: gitster@pobox.com, ps@pks.im, stolee@gmail.com
Subject: Re: [PATCH v3] backfill: handle unexpected arguments
Date: Sun, 22 Mar 2026 16:38:03 +0000 [thread overview]
Message-ID: <45a949f3-8b90-4046-995f-da1df265abfe@gmail.com> (raw)
In-Reply-To: <20260322053207.60992-1-r.siddharth.shrimali@gmail.com>
On 22/03/2026 05:32, Siddharth Shrimali wrote:
> 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 ignores them silently, giving the
> user no indication that something is wrong.
>
> Add a check after parse_options() to report an error if any unexpected
> arguments remain. To ensure the user understands why the command
> failed, print an error message specifying the unknown argument
> followed by the short usage string. This matches the behavior of
> other Git commands such as git bugreport.
>
> Also, add a test in t5620 to ensure the unexpected arguments are
> rejected with the correct error message and that the full option
> descriptions are not printed.
Nicely explained
> diff --git a/t/t5620-backfill.sh b/t/t5620-backfill.sh
> index 58c81556e7..3f1eeb67e8 100755
> --- a/t/t5620-backfill.sh
> +++ b/t/t5620-backfill.sh
> @@ -176,6 +176,12 @@ test_expect_success 'backfill --sparse without cone mode (negative)' '
> test_line_count = 12 missing
> '
>
> +test_expect_success 'backfill rejects unexpected arguments' '
> + test_must_fail git -C backfill1 backfill unexpected-arg >err 2>&1 &&
> + grep "unknown argument .*unexpected-arg" err &&
> + ! grep "Minimum number of objects" err
Using test_grep would make test failures easier to debug as it prints a
diagnostic message if it fails. Note that "! grep" should become
"test_grep !" to ensure the diagnostic message is printed when the
expression matches.
Thanks
Phillip
> +'
> +
> . "$TEST_DIRECTORY"/lib-httpd.sh
> start_httpd
>
next prev parent reply other threads:[~2026-03-22 16:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-21 3:16 [PATCH] backfill: handle unexpected arguments Siddharth Shrimali
2026-03-21 4:42 ` Junio C Hamano
2026-03-21 5:03 ` Junio C Hamano
2026-03-21 17:47 ` [PATCH v2] " Siddharth Shrimali
2026-03-22 1:13 ` Junio C Hamano
2026-03-22 5:32 ` [PATCH v3] " Siddharth Shrimali
2026-03-22 16:38 ` Phillip Wood [this message]
2026-03-22 18:06 ` Junio C Hamano
2026-03-22 23:01 ` Derrick Stolee
2026-03-23 1:01 ` Junio C Hamano
2026-03-23 1:42 ` Derrick Stolee
2026-03-23 6:17 ` Siddharth Shrimali
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45a949f3-8b90-4046-995f-da1df265abfe@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=ps@pks.im \
--cc=r.siddharth.shrimali@gmail.com \
--cc=stolee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.