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

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

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Mar 7, 2019, 15:21 UTC
Message-ID
<556113c0-b952-522b-d7b4-233c313d158f@gmail.com>
In-Reply-To
<68ec2b7cd7457e9bcd3f6f211774457c73ef8646.1551951770.git.liu.denton@gmail.com>
Hi Denton

Thanks for doing this, I think it looks ok but it would be better to make these changes earlier in the series so they come before what is now patch 3

Best Wishes
Phillip
On 07/03/2019 09:58, Denton Liu wrote:
Show 110 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>
> ---
>   builtin/commit.c |  2 +-
>   builtin/merge.c  |  4 ++--
>   builtin/revert.c |  2 +-
>   sequencer.c      | 10 +++++++---
>   sequencer.h      |  2 +-
>   5 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 43291d79bd..0072a5817a 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -1167,7 +1167,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
>   		die(_("Only one of --include/--only/--all/--interactive/--patch can be used."));
>   	if (argc == 0 && (also || (only && !amend && !allow_empty)))
>   		die(_("No paths with --include/--only does not make sense."));
> -	cleanup_mode = get_cleanup_mode(cleanup_arg, use_editor);
> +	cleanup_mode = get_cleanup_mode(cleanup_arg, use_editor, 1);
>   
>   	handle_untracked_files_arg(s);
>   
> diff --git a/builtin/merge.c b/builtin/merge.c
> index d4217ebcf5..3b597ec540 100644
> --- a/builtin/merge.c
> +++ b/builtin/merge.c
> @@ -916,7 +916,7 @@ static int suggest_conflicts(void)
>   	 * Thus, we will get the cleanup mode which is returned when we _are_ using
>   	 * an editor.
>   	 */
> -	append_conflicts_hint(&msgbuf, get_cleanup_mode(cleanup_arg, 1));
> +	append_conflicts_hint(&msgbuf, get_cleanup_mode(cleanup_arg, 1, 1));
>   	fputs(msgbuf.buf, fp);
>   	strbuf_release(&msgbuf);
>   	fclose(fp);
> @@ -1424,7 +1424,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
>   	if (option_edit < 0)
>   		option_edit = default_edit_option();
>   
> -	cleanup_mode = get_cleanup_mode(cleanup_arg, 0 < option_edit);
> +	cleanup_mode = get_cleanup_mode(cleanup_arg, 0 < option_edit, 1);
>   
>   	if (!use_strategies) {
>   		if (!remoteheads)
> diff --git a/builtin/revert.c b/builtin/revert.c
> index fe18036be7..a96f2ecd8a 100644
> --- a/builtin/revert.c
> +++ b/builtin/revert.c
> @@ -139,7 +139,7 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
>   		opts->allow_empty = 1;
>   
>   	if (cleanup_arg)
> -		opts->default_msg_cleanup = get_cleanup_mode(cleanup_arg, 1);
> +		opts->default_msg_cleanup = get_cleanup_mode(cleanup_arg, 1, 1);
>   
>   	/* Check for incompatible command line arguments */
>   	if (cmd) {
> diff --git a/sequencer.c b/sequencer.c
> index 5c04bae7ac..7d18c55223 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -170,7 +170,7 @@ static int git_sequencer_config(const char *k, const char *v, void *cb)
>   		if (status)
>   			return status;
>   
> -		opts->default_msg_cleanup = get_cleanup_mode(s, !is_rebase_i(opts));
> +		opts->default_msg_cleanup = get_cleanup_mode(s, !is_rebase_i(opts), 0);
>   
>   		free((char *)s);
>   		return status;
> @@ -488,7 +488,7 @@ static int fast_forward_to(const struct object_id *to, const struct object_id *f
>   }
>   
>   enum commit_msg_cleanup_mode get_cleanup_mode(const char *cleanup_arg,
> -	int use_editor)
> +	int use_editor, int die_on_error)
>   {
>   	if (!cleanup_arg || !strcmp(cleanup_arg, "default"))
>   		return use_editor ? COMMIT_MSG_CLEANUP_ALL :
> @@ -502,7 +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
> +	else if (!die_on_error) {
> +		warning(_("Invalid cleanup mode %s, falling back to default"), cleanup_arg);
> +		return use_editor ? COMMIT_MSG_CLEANUP_ALL :
> +				    COMMIT_MSG_CLEANUP_SPACE;
> +	} else
>   		die(_("Invalid cleanup mode %s"), cleanup_arg);
>   }
>   
> diff --git a/sequencer.h b/sequencer.h
> index aa99503dd7..c4c80051ea 100644
> --- a/sequencer.h
> +++ b/sequencer.h
> @@ -94,7 +94,7 @@ void append_signoff(struct strbuf *msgbuf, int ignore_footer, unsigned flag);
>   void append_conflicts_hint(struct strbuf *msgbuf,
>   		enum commit_msg_cleanup_mode cleanup_mode);
>   enum commit_msg_cleanup_mode get_cleanup_mode(const char *cleanup_arg,
> -	int use_editor);
> +	int use_editor, int die_on_error);
>   
>   void cleanup_message(struct strbuf *msgbuf,
>   	enum commit_msg_cleanup_mode cleanup_mode, int verbose);
> 
Previous: Denton Liu
Message 25 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.