git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Phillip Wood <phillip.wood@dunelm.org.uk>
Cc: Git Mailing List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	Denton Liu <liu.denton@gmail.com>
Subject: Re: [PATCH] sequencer: fix cleanup with --signoff and -x
Date: Fri, 29 Mar 2019 16:51:50 +0100 (STD)	[thread overview]
Message-ID: <nycvar.QRO.7.76.6.1903291651340.41@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <20190329110842.30604-1-phillip.wood123@gmail.com>

Hi Phillip,

On Fri, 29 Mar 2019, Phillip Wood wrote:

> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>
> Before commit 356ee4659b ("sequencer: try to commit without forking 'git
> commit'", 2017-11-24) when --signoff or -x were given on the command
> line the commit message was cleaned up with --cleanup=space or
> commit.cleanup if it was set. Unfortunately this behavior was lost when
> I implemented committing without forking. Fix this and add some tests to
> catch future regressions.
>
> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> ---

Looks good to me!

Thank you,
Dscho

>
> This clashes with dl/merge-cleanup-scissors-fix, I've sent some
> rebased patches to Denton and he's going to send a re-roll based on
> those.
>
>  sequencer.c              | 24 +++++++++++++++++-------
>  sequencer.h              |  1 +
>  t/t3511-cherry-pick-x.sh | 20 ++++++++++++++++++++
>  3 files changed, 38 insertions(+), 7 deletions(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index 0db410d590..15457bbe71 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -172,17 +172,22 @@ static int git_sequencer_config(const char *k, const char *v, void *cb)
>  		if (status)
>  			return status;
>
> -		if (!strcmp(s, "verbatim"))
> +		if (!strcmp(s, "verbatim")) {
>  			opts->default_msg_cleanup = COMMIT_MSG_CLEANUP_NONE;
> -		else if (!strcmp(s, "whitespace"))
> +			opts->explicit_cleanup = 1;
> +		} else if (!strcmp(s, "whitespace")) {
>  			opts->default_msg_cleanup = COMMIT_MSG_CLEANUP_SPACE;
> -		else if (!strcmp(s, "strip"))
> +			opts->explicit_cleanup = 1;
> +		} else if (!strcmp(s, "strip")) {
>  			opts->default_msg_cleanup = COMMIT_MSG_CLEANUP_ALL;
> -		else if (!strcmp(s, "scissors"))
> +			opts->explicit_cleanup = 1;
> +		} else if (!strcmp(s, "scissors")) {
>  			opts->default_msg_cleanup = COMMIT_MSG_CLEANUP_SPACE;
> -		else
> +			opts->explicit_cleanup = 1;
> +		} else {
>  			warning(_("invalid commit message cleanup mode '%s'"),
>  				  s);
> +		}
>
>  		free((char *)s);
>  		return status;
> @@ -1382,8 +1387,13 @@ static int try_to_commit(struct repository *r,
>  		msg = &commit_msg;
>  	}
>
> -	cleanup = (flags & CLEANUP_MSG) ? COMMIT_MSG_CLEANUP_ALL :
> -					  opts->default_msg_cleanup;
> +	if (flags & CLEANUP_MSG)
> +		cleanup = COMMIT_MSG_CLEANUP_ALL;
> +	else if ((opts->signoff || opts->record_origin) &&
> +		 !opts->explicit_cleanup)
> +		cleanup = COMMIT_MSG_CLEANUP_SPACE;
> +	else
> +		cleanup = opts->default_msg_cleanup;
>
>  	if (cleanup != COMMIT_MSG_CLEANUP_NONE)
>  		strbuf_stripspace(msg, cleanup == COMMIT_MSG_CLEANUP_ALL);
> diff --git a/sequencer.h b/sequencer.h
> index 4d505b3590..82bc7a48d5 100644
> --- a/sequencer.h
> +++ b/sequencer.h
> @@ -47,6 +47,7 @@ struct replay_opts {
>
>  	char *gpg_sign;
>  	enum commit_msg_cleanup_mode default_msg_cleanup;
> +	int explicit_cleanup;
>
>  	/* Merge strategy */
>  	char *strategy;
> diff --git a/t/t3511-cherry-pick-x.sh b/t/t3511-cherry-pick-x.sh
> index 9888bf34b9..84a587daf3 100755
> --- a/t/t3511-cherry-pick-x.sh
> +++ b/t/t3511-cherry-pick-x.sh
> @@ -298,4 +298,24 @@ test_expect_success 'cherry-pick preserves commit message' '
>  	test_cmp expect actual
>  '
>
> +test_expect_success 'cherry-pick -x cleans commit message' '
> +	pristine_detach initial &&
> +	git cherry-pick -x mesg-unclean &&
> +	git log -1 --pretty=format:%B >actual &&
> +	printf "%s\n(cherry picked from commit %s)\n" \
> +		"$mesg_unclean" $(git rev-parse mesg-unclean) |
> +			git stripspace >expect &&
> +	test_cmp expect actual
> +'
> +
> +test_expect_success 'cherry-pick -x respects commit.cleanup' '
> +	pristine_detach initial &&
> +	git -c commit.cleanup=strip cherry-pick -x mesg-unclean &&
> +	git log -1 --pretty=format:%B >actual &&
> +	printf "%s\n(cherry picked from commit %s)\n" \
> +		"$mesg_unclean" $(git rev-parse mesg-unclean) |
> +			git stripspace -s >expect &&
> +	test_cmp expect actual
> +'
> +
>  test_done
> --
> 2.21.0
>
>

      reply	other threads:[~2019-03-29 15:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-29 11:08 [PATCH] sequencer: fix cleanup with --signoff and -x Phillip Wood
2019-03-29 15:51 ` Johannes Schindelin [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=nycvar.QRO.7.76.6.1903291651340.41@tvgsbejvaqbjf.bet \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=liu.denton@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).