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

Re: [PATCH v2 3/3] sequencer.c: don't die on invalid cleanup_arg

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 7, 2019, 08:01 UTC
Message-ID
<xmqq5zsvm7uc.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<f3af8000aec51e49f3fe8f90dbfec61606596b2e.1551940635.git.liu.denton@gmail.com>
Denton Liu <liu.denton@gmail.com> writes:
Show 25 quoted lines
> When get_cleanup_mode was provided with an invalid cleanup_arg, it used
> to die. Warn user and fallback to default behaviour if an invalid
> cleanup_arg is given.
>
> Signed-off-by: Denton Liu <liu.denton@gmail.com>
> ---
>  sequencer.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index 5c04bae7ac..f9bdfa90ad 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -502,8 +502,11 @@ enum commit_msg_cleanup_mode get_cleanup_mode(const char *cleanup_arg,
>  	else if (!strcmp(cleanup_arg, "scissors"))
>  		return use_editor ? COMMIT_MSG_CLEANUP_SCISSORS :
>  				    COMMIT_MSG_CLEANUP_SPACE;
> -	else
> -		die(_("Invalid cleanup mode %s"), cleanup_arg);
> +	else {
> +		warning(_("Invalid cleanup mode %s, falling back to default"), cleanup_arg);
> +		return use_editor ? COMMIT_MSG_CLEANUP_ALL :
> +				    COMMIT_MSG_CLEANUP_SPACE;
> +	}
>  }
In what different contexts does this get called, I wonder?
I think
	$ git cherry-pick --cleanup=bogus ...

should error out, instead of falling back to anything else, while having

	[commit] cleanup = bogus

in .git/config should *not* say anything if you are not running a command that does not get affected by the commit.cleanup variable, and with such a bogus configuration, a command that does use the variable should either also die, or fallback with a warning.

I have a suspicion that the change is breaking the error detection done for the command line argument parsing, and if that is the case, then it is a bad idea. But I may have misread the code.

Thanks.
Previous: Denton LiuNext: Denton Liu
Message 14 of 25 in “cherry-pick/revert cleanup scissors fix”
  1. 0/2 cherry-pick/revert cleanup scissors fixDenton Liu, Mar 6, 2019
  2. 1/2 t3507: cleanup space after redirection operatorsDenton Liu, Mar 6, 2019
  3. 2/2 cherry-pick/revert: add scissors line on merge conflictDenton Liu, Mar 6, 2019
  4. Phillip WoodMar 6, 2019
  5. Denton LiuMar 7, 2019
  6. Denton LiuMar 7, 2019
  7. 0/3 cherry-pick/revert cleanup scissors fixDenton Liu, Mar 7, 2019
  8. 1/3 t3507: cleanup space after redirection operatorsDenton Liu, Mar 7, 2019
  9. Junio C HamanoMar 7, 2019
  10. 2/3 cherry-pick/revert: add scissors line on merge conflictDenton Liu, Mar 7, 2019
  11. Junio C HamanoMar 7, 2019
  12. Denton LiuMar 7, 2019
  13. 3/3 sequencer.c: don't die on invalid cleanup_argDenton Liu, Mar 7, 2019
  14. Junio C HamanoMar 7, 2019
  15. 0/4 cherry-pick/revert cleanup scissors fixDenton Liu, Mar 7, 2019
  16. 1/4 merge-options.txt: correct typoDenton Liu, Mar 7, 2019
  17. Junio C HamanoMar 8, 2019
  18. 2/4 t3507: cleanup space after redirection operatorsDenton Liu, Mar 7, 2019
  19. 3/4 cherry-pick/revert: add scissors line on merge conflictDenton Liu, Mar 7, 2019
  20. Phillip WoodMar 7, 2019
  21. Denton LiuMar 7, 2019
  22. Phillip WoodMar 7, 2019
  23. Junio C HamanoMar 8, 2019
  24. 4/4 sequencer.c: don't die on invalid cleanup_argDenton Liu, Mar 7, 2019
  25. Phillip WoodMar 7, 2019

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.