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

Re: [PATCH v3 1/5] parse-options: Allow PARSE_OPT_NOARG in integer arguments

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 20, 2010, 19:49 UTC
Message-ID
<7vlj81awtc.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1282331702-5115-2-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
> When the option parser encounters an OPTION_INTEGER argument,
> PARSE_OPT_NOARG should imply that the default value should be used.
Sorry but why?

Doesn't NOARG mean "Do not take an argument, if you give me an argument that is an error"?

I would understand if this were OPT_OPTARG, though.
Confused...
Show 23 quoted lines
>
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> Cc: Jakub Narebski <jnareb@gmail.com>
> ---
>  parse-options.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/parse-options.c b/parse-options.c
> index e0c3641..7ec9886 100644
> --- a/parse-options.c
> +++ b/parse-options.c
> @@ -138,6 +138,9 @@ static int get_value(struct parse_opt_ctx_t *p,
>  			*(int *)opt->value = 0;
>  			return 0;
>  		}
> +		if (opt->flags & PARSE_OPT_NOARG)
> +			*(int *)opt->value = opt->defval;
> +			return 0;
>  		if (opt->flags & PARSE_OPT_OPTARG && !p->opt) {
>  			*(int *)opt->value = opt->defval;
>  			return 0;
> -- 
> 1.7.2.2.409.gdbb11.dirty
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 3 of 15 in “fmt-merge-msg improvements”
  1. 0/5 fmt-merge-msg improvementsRamkumar Ramachandra, Aug 20, 2010
  2. 1/5 parse-options: Allow PARSE_OPT_NOARG in integer argumentsRamkumar Ramachandra, Aug 20, 2010
  3. Junio C HamanoAug 20, 2010
  4. Ramkumar RamachandraAug 20, 2010
  5. Jonathan NiederAug 21, 2010
  6. 2/5 fmt-merge-msg: Make the number of log entries in commit message configurableRamkumar Ramachandra, Aug 20, 2010
  7. Jonathan NiederAug 21, 2010
  8. Ramkumar RamachandraAug 21, 2010
  9. 3/5 fmt-merge-msg: Update command line options to sync with config optionsRamkumar Ramachandra, Aug 20, 2010
  10. Jonathan NiederAug 21, 2010
  11. Ramkumar RamachandraAug 21, 2010
  12. 4/5 fmt-merge-msg: Remove deprecated --summary optionRamkumar Ramachandra, Aug 20, 2010
  13. Jonathan NiederAug 21, 2010
  14. Ramkumar RamachandraAug 21, 2010
  15. 5/5 fmt-merge-msg: Update fmt-merge-msg and merge-config documentationRamkumar Ramachandra, Aug 20, 2010

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.