git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-checkout: fix argument parsing to detect ambiguous arguments.

From
Pierre Habouzit <madcoder@debian.org>
Date
Jul 23, 2008, 01:32 UTC
Message-ID
<20080723013203.GJ11831@artemis.madism.org>
In-Reply-To
<alpine.DEB.1.00.0807230215480.8986@racer>
On Wed, Jul 23, 2008 at 01:17:52AM +0000, Johannes Schindelin wrote:
Show 25 quoted lines
> Hi,
> 
> On Wed, 23 Jul 2008, Pierre Habouzit wrote:
> 
> > 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.
  No I was mistaken about what verify_non_filename did, actually I
should not code when I'm so obviously tired, and I wanted
verify_non_filename to do what I meant instead of checking what it does
;P
  I believe my resent patch is better.
> However, you may want to verify_non_filename() when argc == 1 _and_ 
> get_sha1() succeeded.  Because then, <path> is ambiguous.
  Yes and the reverse when we have sucessfully parsed something that
looks like a path as a path. Anyways, someone should carefully proofread
my resent patch, it's likely that errors slipped through given my sleep
deprivation atm.
Previous: Johannes SchindelinNext: Pierre Habouzit
Message 4 of 16 in “git-checkout: fix argument parsing to detect ambiguous arguments.”
  1. git-checkout: fix argument parsing to detect ambiguous arguments.Pierre Habouzit, Jul 23, 2008
  2. Pierre HabouzitJul 23, 2008
  3. Johannes SchindelinJul 23, 2008
  4. Pierre HabouzitJul 23, 2008
  5. git-checkout: fix argument parsing to detect ambiguous arguments.Pierre Habouzit, Jul 23, 2008
  6. Pierre HabouzitJul 23, 2008
  7. Johannes SchindelinJul 23, 2008
  8. Resubmit after a night of sleepPierre Habouzit, Jul 23, 2008
  9. 1/2 git-checkout: fix command line parsing.Pierre Habouzit, Jul 23, 2008
  10. 2/2 git-checkout: improve error messages, detect ambiguities.Pierre Habouzit, Jul 23, 2008
  11. Junio C HamanoJul 23, 2008
  12. Junio C HamanoJul 24, 2008
  13. Pierre HabouzitJul 24, 2008
  14. checkout: mention '--' in the docsSZEDER Gábor, Jul 23, 2008
  15. bash: offer only paths after '--' for 'git checkout'SZEDER Gábor, Jul 23, 2008
  16. Shawn O. PearceJul 25, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.