Re: [PATCH] git-checkout: fix argument parsing to detect ambiguous arguments.
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jul 23, 2008, 01:17 UTC
- Message-ID
- <alpine.DEB.1.00.0807230215480.8986@racer>
- In-Reply-To
- <1216774940-4955-1-git-send-email-madcoder@debian.org>
Hi,
On Wed, 23 Jul 2008, Pierre Habouzit wrote:
Show 18 quoted lines
> diff --git a/builtin-checkout.c b/builtin-checkout.c
> index fbd5105..1490e8e 100644
> --- a/builtin-checkout.c
> +++ b/builtin-checkout.c
> @@ -438,9 +438,14 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
>
> opts.track = git_branch_track;
>
> - argc = parse_options(argc, argv, options, checkout_usage, 0);
> - if (argc) {
> + argc = parse_options(argc, argv, options, checkout_usage,
> + PARSE_OPT_KEEP_DASHDASH);
> +
> + if (argc && strcmp(argv[0], "--")) {
> arg = argv[0];
> +
> + if (argc == 1 || strcmp(argv[1], "--"))
> + verify_non_filename(NULL, arg);Why "argc == 1"? Should "git checkout <path>" really fail? That would be a change in behavior that _would_ hit me.
However, you may want to verify_non_filename() when argc == 1 _and_ get_sha1() succeeded. Because then, <path> is ambiguous.
Ciao, Dscho