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

parse-options: ambiguous LASTARG_DEFAULT and OPTARG

From
Stephen Boyd <bebarino@gmail.com>
Date
Jun 5, 2009, 05:43 UTC
Message-ID
<4A28B072.8030006@gmail.com>
Hi,
This in builtin-branch.c
        {
		OPTION_CALLBACK, 0, "merged", &merge_filter_ref,
		"commit", "print only merged branches",
		PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NONEG,
		opt_parse_merge_filter, (intptr_t) "HEAD",
	},
and the usage message for "git-branch -h" will print out
    --merged <commit>
when I'm expecting
    --merged[=<commit>]

This is because the PARSE_OPT_OPTARG flag is not used. Is this correct? The default value is still set correctly in some cases, but become ambiguous in other cases. Take this for example

    $ git branch --merged --verbose
    fatal: malformed object name --verbose
but
    $ git branch --verbose --merged
works fine.

The simple fix is to just add PARSE_OPT_OPTARG to the flags, and fix a test or two. But I'm wondering if doing that will become problematic for end-users. Essentially you can no longer do git branch --merged master, you must do git branch --merged=master.

Next: René Scharfe
Message 1 of 9 in “parse-options: ambiguous LASTARG_DEFAULT and OPTARG”
  1. Stephen BoydJun 5, 2009
  2. René ScharfeJun 6, 2009
  3. Stephen BoydJun 6, 2009
  4. show-branch: don't use LASTARG_DEFAULT with OPTARGStephen Boyd, Jun 7, 2009
  5. René ScharfeJun 8, 2009
  6. Junio C HamanoJun 8, 2009
  7. parse-options: add parse_options_check to validate option specs.Pierre Habouzit, Jun 9, 2009
  8. Pierre HabouzitJun 12, 2009
  9. René ScharfeJun 12, 2009

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.