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

Re: [PATCH v2 4/4] diff: use skip_to_optional_val_default()

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 4, 2017, 14:28 UTC
Message-ID
<xmqqd13uo9d1.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20171204125617.4931-4-chriscool@tuxfamily.org>
Christian Couder <christian.couder@gmail.com> writes:
Show 5 quoted lines
> -	} else if (!strcmp(arg, "--submodule"))
> -		options->submodule_format = DIFF_SUBMODULE_LOG;
> -	else if (skip_prefix(arg, "--submodule=", &arg))
> +	} else if (skip_to_optional_val_default(arg, "--submodule", &arg, "log"))
>  		return parse_submodule_opt(options, arg);

It may be annoying if we later diagnose that DIFF_SUBMODULE_LOG may not be used in the context (e.g. together with some other optoins that are set in "options" variable) and have to throw an error message at the user. parse_submodule_opt() would not know if that string "log" came from the user or substituted by the helper, and in the latter case, "don't use --submodule=log here" is a message that is not quite appropriate.

This may be minor enough not matter in practice, but I dunno. I didn't look at other hunks in this step very carefully but I would expect that whenever you use "default" to substitute, you'll have the same information lossage.

Previous: Christian CouderNext: Junio C Hamano
Message 6 of 7 in “git-compat-util: introduce skip_to_optional_val()”
  1. 1/4 git-compat-util: introduce skip_to_optional_val()Christian Couder, Dec 4, 2017
  2. 2/4 index-pack: use skip_to_optional_val()Christian Couder, Dec 4, 2017
  3. 3/4 diff: use skip_to_optional_val()Christian Couder, Dec 4, 2017
  4. Junio C HamanoDec 4, 2017
  5. 4/4 diff: use skip_to_optional_val_default()Christian Couder, Dec 4, 2017
  6. Junio C HamanoDec 4, 2017
  7. Junio C HamanoDec 4, 2017

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.