git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Phillip Wood" <phillip.wood@dunelm.org.uk>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH v3] revert: optionally refer to commit in the "reference" format
Date: Wed, 1 Jun 2022 16:03:01 +0100	[thread overview]
Message-ID: <c0635170-5a52-c426-8231-d7291a79fa2c@gmail.com> (raw)
In-Reply-To: <xmqqfskpuh2w.fsf@gitster.g>

Hi Junio

On 01/06/2022 05:45, Junio C Hamano wrote:
> Phillip Wood <phillip.wood123@gmail.com> writes:
> 
>> I think the changes to the template message are good. We're still
>> adding "--reference" as a valid option to cherry-pick though which I
>> don't think is a good idea (though in the future we may want to allow
>> "cherry-pick -x --reference")
> 
> I love when people notice mistakes that the original author and
> other people missed, many eyes making all bugs shallow.
> 
> I am inclined to apply the following on top.  How does it look?

It looks good to me.

Best Wishes

Phillip

> Thanks.
> 
> ----- >8 --------- >8 --------- >8 --------- >8 -----
> Subject: [PATCH] revert: --reference should apply only to 'revert', not 'cherry-pick'
> 
> As 'revert' and 'cherry-pick' share a lot of code, it is easy to
> modify the behaviour of one command and inadvertently affect the
> other.  An earlier change to teach the '--reference' option and the
> 'revert.reference' configuration variable to the former was not
> careful enough and 'cherry-pick --reference' wasn't rejected as an
> error.
> 
> It is possible to think 'cherry-pick -x' might benefit from the
> '--reference' option, but it is fundamentally different from
> 'revert' in at least two ways to make it questionable:
> 
>   - 'revert' names a commit that is ancestor of the resulting commit,
>     so an abbreviated object name with human readable title is
>     sufficient to identify the named commit uniquely without using
>     the full object name.  On the other hand, 'cherry-pick'
>     usually [*] picks a commit that is not an ancestor.  It might be
>     even picking a private commit that never becomes part of the
>     public history.
> 
>   - The whole commit message of 'cherry-pick' is a copy of the
>     original commit, and there is nothing gained to repeat only the
>     title part on 'cherry-picked from' message.
> 
> [*] well, you could revert and then you can pick the original that
>      was reverted to get back to where you were, but then you can
>      revert the revert to do the same thing.
> 
> Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>   builtin/revert.c              | 9 +++++++--
>   sequencer.c                   | 2 +-
>   t/t3501-revert-cherry-pick.sh | 6 ++++++
>   3 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/builtin/revert.c b/builtin/revert.c
> index ada51e46b9..f84c253f4c 100644
> --- a/builtin/revert.c
> +++ b/builtin/revert.c
> @@ -116,8 +116,6 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
>   			N_("option for merge strategy"), option_parse_x),
>   		{ OPTION_STRING, 'S', "gpg-sign", &opts->gpg_sign, N_("key-id"),
>   		  N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
> -		OPT_BOOL(0, "reference", &opts->commit_use_reference,
> -			 N_("use the 'reference' format to refer to commits")),
>   		OPT_END()
>   	};
>   	struct option *options = base_options;
> @@ -132,6 +130,13 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
>   			OPT_END(),
>   		};
>   		options = parse_options_concat(options, cp_extra);
> +	} else if (opts->action == REPLAY_REVERT) {
> +		struct option cp_extra[] = {
> +			OPT_BOOL(0, "reference", &opts->commit_use_reference,
> +				 N_("use the 'reference' format to refer to commits")),
> +			OPT_END(),
> +		};
> +		options = parse_options_concat(options, cp_extra);
>   	}
>   
>   	argc = parse_options(argc, argv, NULL, options, usage_str,
> diff --git a/sequencer.c b/sequencer.c
> index 96fec6ef6d..4b66a1f79c 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -221,7 +221,7 @@ static int git_sequencer_config(const char *k, const char *v, void *cb)
>   		return ret;
>   	}
>   
> -	if (!strcmp(k, "revert.reference"))
> +	if (opts->action == REPLAY_REVERT && !strcmp(k, "revert.reference"))
>   		opts->commit_use_reference = git_config_bool(k, v);
>   
>   	status = git_gpg_config(k, v, NULL);
> diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh
> index a386ae9e88..fb4466599b 100755
> --- a/t/t3501-revert-cherry-pick.sh
> +++ b/t/t3501-revert-cherry-pick.sh
> @@ -205,4 +205,10 @@ test_expect_success 'identification of reverted commit (revert.reference)' '
>   	test_cmp expect actual
>   '
>   
> +test_expect_success 'cherry-pick is unaware of --reference (for now)' '
> +	test_when_finished "git reset --hard" &&
> +	test_must_fail git cherry-pick --reference HEAD 2>actual &&
> +	grep "^usage: git cherry-pick" actual
> +'
> +
>   test_done

  reply	other threads:[~2022-06-01 15:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-22  4:32 [PATCH] revert: optionally refer to commit in the "reference" format Junio C Hamano
2022-05-23 13:25 ` Johannes Schindelin
2022-05-23 22:48   ` Junio C Hamano
2022-05-27  6:01     ` [PATCH v3] " Junio C Hamano
2022-05-30 16:40       ` Johannes Schindelin
2022-05-31 14:00       ` Phillip Wood
2022-06-01  4:45         ` Junio C Hamano
2022-06-01 15:03           ` Phillip Wood [this message]
2022-06-01 15:14       ` Ævar Arnfjörð Bjarmason
2022-06-01 21:52         ` Junio C Hamano
2022-05-30 16:50     ` Side effects in Git's test suite, was Re: [PATCH] " Johannes Schindelin
2022-05-31  8:03       ` Ævar Arnfjörð Bjarmason
2022-05-23 13:45 ` Ævar Arnfjörð Bjarmason
2022-05-23 22:37   ` Junio C Hamano
2022-05-24  8:12     ` Ævar Arnfjörð Bjarmason
2022-05-24 19:11       ` Junio C Hamano
2022-05-26 11:17 ` Phillip Wood
2022-05-26 17:29   ` Junio C Hamano
2022-06-26  9:29 ` René Scharfe
2022-06-27 15:38   ` Junio C Hamano

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=c0635170-5a52-c426-8231-d7291a79fa2c@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).