git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Denton Liu <liu.denton@gmail.com>,
	Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v3 4/4] sequencer.c: don't die on invalid cleanup_arg
Date: Thu, 7 Mar 2019 15:21:00 +0000	[thread overview]
Message-ID: <556113c0-b952-522b-d7b4-233c313d158f@gmail.com> (raw)
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:
> 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);
> 

      reply	other threads:[~2019-03-07 15:21 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-06 10:30 [PATCH 0/2] cherry-pick/revert cleanup scissors fix Denton Liu
2019-03-06 10:30 ` [PATCH 1/2] t3507: cleanup space after redirection operators Denton Liu
2019-03-06 10:30 ` [PATCH 2/2] cherry-pick/revert: add scissors line on merge conflict Denton Liu
2019-03-06 16:29   ` Phillip Wood
2019-03-07  0:04     ` Denton Liu
2019-03-07  0:16     ` Denton Liu
2019-03-07  6:44 ` [PATCH v2 0/3] cherry-pick/revert cleanup scissors fix Denton Liu
2019-03-07  6:44   ` [PATCH v2 1/3] t3507: cleanup space after redirection operators Denton Liu
2019-03-07  7:34     ` Junio C Hamano
2019-03-07  6:44   ` [PATCH v2 2/3] cherry-pick/revert: add scissors line on merge conflict Denton Liu
2019-03-07  7:52     ` Junio C Hamano
2019-03-07  9:19       ` Denton Liu
2019-03-07  6:44   ` [PATCH v2 3/3] sequencer.c: don't die on invalid cleanup_arg Denton Liu
2019-03-07  8:01     ` Junio C Hamano
2019-03-07  9:58   ` [PATCH v3 0/4] cherry-pick/revert cleanup scissors fix Denton Liu
2019-03-07  9:58     ` [PATCH v3 1/4] merge-options.txt: correct typo Denton Liu
2019-03-08  3:40       ` Junio C Hamano
2019-03-07  9:58     ` [PATCH v3 2/4] t3507: cleanup space after redirection operators Denton Liu
2019-03-07  9:58     ` [PATCH v3 3/4] cherry-pick/revert: add scissors line on merge conflict Denton Liu
2019-03-07 15:24       ` Phillip Wood
2019-03-07 17:56         ` Denton Liu
2019-03-07 18:36           ` Phillip Wood
2019-03-08  0:09             ` Junio C Hamano
2019-03-07  9:58     ` [PATCH v3 4/4] sequencer.c: don't die on invalid cleanup_arg Denton Liu
2019-03-07 15:21       ` Phillip Wood [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=556113c0-b952-522b-d7b4-233c313d158f@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=liu.denton@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    --subject='Re: [PATCH v3 4/4] sequencer.c: don'\''t die on invalid cleanup_arg' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git