git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Brian Lyles <brianmlyles@gmail.com>
To: phillip.wood@dunelm.org.uk
Cc: git@vger.kernel.org, me@ttaylorr.com, newren@gmail.com,
	gitster@pobox.com
Subject: Re: [PATCH 4/4] cherry-pick: Add `--empty` for more robust redundant commit handling
Date: Sat, 27 Jan 2024 17:56:31 -0600	[thread overview]
Message-ID: <CAHPHrSf+joHe6ikErHLgWrk-_qjSROS-dXCHagxWGDAF=2deDg@mail.gmail.com> (raw)
In-Reply-To: <b897771e-c60e-4e41-bfae-3bcfdd832be1@gmail.com>

[+cc Junio]

On Tue, Jan 23, 2024 at 8:25 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
>
> Hi Brian
>
>
> On 19/01/2024 05:59, brianmlyles@gmail.com wrote:
>
> > The `--keep-redundant-commits` option will be documented as a deprecated
> > synonym of `--empty=keep`, and will be supported for backwards
> > compatibility for the time being.
>
> I'm not sure if we need to deprecate it as in "it will be removed in the
> future" or just reduce it prominence in favor of --empty

This is also related to Junio's comment:

> On Tue, Jan 23, 2024 at 12:01 PM Junio C Hamano <gitster@pobox.com>
wrote:
>
> True, especially since --empty=keep is much less descriptive and the
> part after "note that ..." below will take a long time before
> sticking in readers' brain.

My primary motivation here was simply for consistency with `--empty` for
both git-rebase(1) and git-am(1). In theory, I am not opposed to
updating this patch to instead simply add a `--drop-redundant-commits`
option if we feel that provides better usability. However, I think that
the consistency would be better.

I will happily defer to the group consensus here, with the options I see
being:

1. No deprecation: just make `--keep-redundant-commits` a synonym of
  `--empty=keep`
2. Soft deprecation: Give a warning when `--keep-redundant-commits` is
  used
3. Add `--drop-redundant-commits` instead of `--empty`

My preference would be 2, followed by 1 and then 3.

> I'm still on the fence about "stop" vs "ask". I see in your tests you've
> accidentally used "ask" which makes me wonder if that is the more
> familiar term for users who probably use "git rebase" more often than
> "git am".

Oh, thank you for catching that. The cause here was actually because I
had initially written these tests prior to adding the "ask -> stop"
change rather than familiarity. I simply failed to update the tests
after moving things around.

> The code changes look good but I think we want to update
> verify_opt_compatible() to check for "--empty" being combined with
> "--continue" etc. as well.

It looks like `--keep-redundant-commits` was not being included in these
checks previously. I suspect that to be an oversight though.

I can add this for v2.

>
> >       if (cleanup_arg) {
> >               opts->default_msg_cleanup = get_cleanup_mode(cleanup_arg, 1);
> >               opts->explicit_cleanup = 1;
> > diff --git a/sequencer.c b/sequencer.c
> > index 582bde8d46..c49c27c795 100644
> > --- a/sequencer.c
> > +++ b/sequencer.c
> > @@ -2934,6 +2934,9 @@ static int populate_opts_cb(const char *key, const char *value,
> >       else if (!strcmp(key, "options.allow-empty-message"))
> >               opts->allow_empty_message =
> >                       git_config_bool_or_int(key, value, ctx->kvi, &error_flag);
> > +     else if (!strcmp(key, "options.drop-redundant-commits"))
> > +             opts->drop_redundant_commits =
> > +                     git_config_bool_or_int(key, value, ctx->kvi, &error_flag);
> >       else if (!strcmp(key, "options.keep-redundant-commits"))
> >               opts->keep_redundant_commits =
> >                       git_config_bool_or_int(key, value, ctx->kvi, &error_flag);
> > @@ -3478,6 +3481,9 @@ static int save_opts(struct replay_opts *opts)
> >       if (opts->allow_empty_message)
> >               res |= git_config_set_in_file_gently(opts_file,
> >                               "options.allow-empty-message", "true");
> > +     if (opts->drop_redundant_commits)
> > +             res |= git_config_set_in_file_gently(opts_file,
> > +                             "options.drop-redundant-commits", "true");
>
> It is good that we're saving the option - it would be good to add a test
> to check that we remember --empty after stopping for a conflict resolution.

I can add a test for this in v2

> >       if (opts->keep_redundant_commits)
> >               res |= git_config_set_in_file_gently(opts_file,
> >                               "options.keep-redundant-commits", "true");
> > diff --git a/t/t3505-cherry-pick-empty.sh b/t/t3505-cherry-pick-empty.sh
> > index 6adfd25351..ae0cf7886a 100755
> > --- a/t/t3505-cherry-pick-empty.sh
> > +++ b/t/t3505-cherry-pick-empty.sh
> > @@ -89,7 +89,7 @@ test_expect_success 'cherry-pick a commit that becomes no-op (prep)' '
> >       git commit -m "add file2 on the side"
> >   '
> >
> > -test_expect_success 'cherry-pick a no-op without --keep-redundant' '
> > +test_expect_success 'cherry-pick a no-op with neither --keep-redundant nor --empty' '
> >       git reset --hard &&
> >       git checkout fork^0 &&
> >       test_must_fail git cherry-pick main
> > @@ -104,4 +104,28 @@ test_expect_success 'cherry-pick a no-op with --keep-redundant' '
> >       test_cmp expect actual
> >   '
> >
> > +test_expect_success 'cherry-pick a no-op with --empty=ask' '
> > +     git reset --hard &&
> > +     git checkout fork^0 &&
> > +     test_must_fail git cherry-pick --empty=ask main
>
> This is an example of why it is a good idea to check the error message
> when using "test_must_fail" as here the test will fail due to a bad
> value passed to "--empty" rather than for the reason we want the test to
> check. It would be good to add a separate test to check that we reject
> invalid "--empty" values.

An excellent catch, thank you. Will be addressed in v2

> > +'
> > +
> > +test_expect_success 'cherry-pick a no-op with --empty=drop' '
> > +     git reset --hard &&
> > +     git checkout fork^0 &&
> > +     git cherry-pick --empty=drop main &&
> > +     git show -s --format=%s >actual &&
> > +     echo "add file2 on the side" >expect &&
> > +     test_cmp expect actual
>
> I think you could simplify this by using test_commit_message

Thanks for pointing that function out -- you're absolutely right. Will
be addressed in v2.


Thanks for the review,
Brian Lyles


  parent reply	other threads:[~2024-01-27 23:57 UTC|newest]

Thread overview: 118+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19  5:59 [PATCH 1/4] sequencer: Do not require `allow_empty` for redundant commit options brianmlyles
2024-01-19  5:59 ` [PATCH 2/4] docs: Clean up `--empty` formatting in `git-rebase` and `git-am` brianmlyles
2024-01-23 14:24   ` Phillip Wood
2024-01-27 21:22     ` Brian Lyles
2024-02-01 14:02       ` Phillip Wood
2024-01-19  5:59 ` [PATCH 3/4] rebase: Update `--empty=ask` to `--empty=drop` brianmlyles
2024-01-23 14:24   ` Phillip Wood
2024-01-27 21:49     ` Brian Lyles
2024-02-01 14:02       ` Phillip Wood
2024-01-19  5:59 ` [PATCH 4/4] cherry-pick: Add `--empty` for more robust redundant commit handling brianmlyles
2024-01-20 20:24   ` Kristoffer Haugsbakk
2024-01-21 18:28     ` Brian Lyles
2024-01-21 22:05       ` Kristoffer Haugsbakk
2024-01-21 22:41       ` Junio C Hamano
2024-01-22 10:40       ` Phillip Wood
2024-01-22 20:55       ` Kristoffer Haugsbakk
2024-01-23  5:23         ` Brian Lyles
2024-01-23  7:11           ` Kristoffer Haugsbakk
2024-01-23 17:32           ` Junio C Hamano
2024-01-23 18:41             ` Subject: [PATCH] CoC: whitespace fix Junio C Hamano
2024-01-24  3:06               ` Elijah Newren
2024-01-23 18:49             ` [PATCH 4/4] cherry-pick: Add `--empty` for more robust redundant commit handling Junio C Hamano
2024-01-23 14:25   ` Phillip Wood
2024-01-23 18:01     ` Junio C Hamano
2024-01-28  0:07       ` Brian Lyles
2024-01-27 23:56     ` Brian Lyles [this message]
2024-01-20 21:38 ` [PATCH 1/4] sequencer: Do not require `allow_empty` for redundant commit options Kristoffer Haugsbakk
2024-01-21 18:19   ` Brian Lyles
2024-01-23 14:23 ` Phillip Wood
2024-01-23 18:18   ` Junio C Hamano
2024-01-24 11:01   ` Phillip Wood
2024-01-24 11:01 ` Phillip Wood
2024-01-27 23:30   ` Brian Lyles
2024-01-28 16:36     ` Brian Lyles
2024-01-29 10:55       ` Phillip Wood
2024-02-10  5:50         ` Brian Lyles
2024-02-01 10:57     ` Phillip Wood
2024-02-10  4:34       ` Brian Lyles
2024-02-10  7:43 ` [PATCH v2 0/8] cherry-pick: add `--empty` Brian Lyles
2024-02-22 16:39   ` phillip.wood123
2024-02-10  7:43 ` [PATCH v2 1/8] docs: address inaccurate `--empty` default with `--exec` Brian Lyles
2024-02-10  7:43 ` [PATCH v2 2/8] docs: clean up `--empty` formatting in git-rebase(1) and git-am(1) Brian Lyles
2024-02-10  7:43 ` [PATCH v2 3/8] rebase: update `--empty=ask` to `--empty=drop` Brian Lyles
2024-02-11  4:54   ` Brian Lyles
2024-02-14 11:05     ` Phillip Wood
2024-02-22 16:34   ` phillip.wood123
2024-02-22 18:27     ` Junio C Hamano
2024-02-10  7:43 ` [PATCH v2 4/8] sequencer: treat error reading HEAD as unborn branch Brian Lyles
2024-02-22 16:34   ` phillip.wood123
2024-02-23  5:28     ` Brian Lyles
2024-02-25 16:57       ` phillip.wood123
2024-02-10  7:43 ` [PATCH v2 5/8] sequencer: do not require `allow_empty` for redundant commit options Brian Lyles
2024-02-22 16:35   ` phillip.wood123
2024-02-10  7:43 ` [PATCH v2 6/8] cherry-pick: decouple `--allow-empty` and `--keep-redundant-commits` Brian Lyles
2024-02-22 16:35   ` Phillip Wood
2024-02-22 18:41     ` Junio C Hamano
2024-02-10  7:43 ` [PATCH v2 7/8] cherry-pick: enforce `--keep-redundant-commits` incompatibility Brian Lyles
2024-02-22 16:35   ` Phillip Wood
2024-02-23  6:23     ` Brian Lyles
2024-02-23 17:41       ` Junio C Hamano
2024-02-25 16:58       ` phillip.wood123
2024-02-26  3:04         ` Brian Lyles
2024-02-10  7:43 ` [PATCH v2 8/8] cherry-pick: add `--empty` for more robust redundant commit handling Brian Lyles
2024-02-11 20:50   ` Jean-Noël AVILA
2024-02-12  1:35     ` Brian Lyles
2024-02-22 16:36   ` phillip.wood123
2024-02-23  6:58     ` Brian Lyles
2024-02-25 16:57       ` phillip.wood123
2024-02-26  2:21         ` Brian Lyles
2024-02-26  3:32         ` Brian Lyles
2024-02-27 10:39           ` phillip.wood123
2024-02-27 17:33             ` Junio C Hamano
2024-03-10 18:41 ` [PATCH v3 0/7] " Brian Lyles
2024-03-13 16:12   ` phillip.wood123
2024-03-10 18:42 ` [PATCH v3 1/7] docs: address inaccurate `--empty` default with `--exec` Brian Lyles
2024-03-10 18:42 ` [PATCH v3 2/7] docs: clean up `--empty` formatting in git-rebase(1) and git-am(1) Brian Lyles
2024-03-10 18:42 ` [PATCH v3 3/7] rebase: update `--empty=ask` to `--empty=stop` Brian Lyles
2024-03-10 18:42 ` [PATCH v3 4/7] sequencer: treat error reading HEAD as unborn branch Brian Lyles
2024-03-11  0:07   ` Junio C Hamano
2024-03-11 16:54     ` Junio C Hamano
2024-03-12  2:04       ` Brian Lyles
2024-03-12 22:25         ` Junio C Hamano
2024-03-16  3:05           ` Brian Lyles
2024-03-13 15:10   ` phillip.wood123
2024-03-16  3:07     ` Brian Lyles
2024-03-10 18:42 ` [PATCH v3 5/7] sequencer: do not require `allow_empty` for redundant commit options Brian Lyles
2024-03-10 18:42 ` [PATCH v3 6/7] cherry-pick: enforce `--keep-redundant-commits` incompatibility Brian Lyles
2024-03-10 18:42 ` [PATCH v3 7/7] cherry-pick: add `--empty` for more robust redundant commit handling Brian Lyles
2024-03-13 16:10   ` phillip.wood123
2024-03-13 17:17     ` Junio C Hamano
2024-03-16  5:20       ` Brian Lyles
2024-03-20 19:35         ` phillip.wood123
2024-03-20 23:36 ` [PATCH v4 0/7] " Brian Lyles
2024-03-25 14:38   ` phillip.wood123
2024-03-25 16:12     ` Brian Lyles
2024-03-25 19:36       ` phillip.wood123
2024-03-25 20:57         ` Junio C Hamano
2024-03-20 23:36 ` [PATCH v4 1/7] docs: address inaccurate `--empty` default with `--exec` Brian Lyles
2024-03-20 23:36 ` [PATCH v4 2/7] docs: clean up `--empty` formatting in git-rebase(1) and git-am(1) Brian Lyles
2024-03-20 23:36 ` [PATCH v4 3/7] rebase: update `--empty=ask` to `--empty=stop` Brian Lyles
2024-03-20 23:36 ` [PATCH v4 4/7] sequencer: handle unborn branch with `--allow-empty` Brian Lyles
2024-03-21  9:52   ` Dirk Gouders
2024-03-21 16:22     ` Junio C Hamano
2024-03-21 19:45       ` Dirk Gouders
2024-03-20 23:37 ` [PATCH v4 5/7] sequencer: do not require `allow_empty` for redundant commit options Brian Lyles
2024-03-20 23:37 ` [PATCH v4 6/7] cherry-pick: enforce `--keep-redundant-commits` incompatibility Brian Lyles
2024-03-20 23:37 ` [PATCH v4 7/7] cherry-pick: add `--empty` for more robust redundant commit handling Brian Lyles
2024-03-25 23:16 ` [PATCH v5 0/7] " Brian Lyles
2024-03-26 14:45   ` phillip.wood123
2024-03-26 18:28     ` Junio C Hamano
2024-03-27 16:37       ` phillip.wood123
2024-03-25 23:16 ` [PATCH v5 1/7] docs: address inaccurate `--empty` default with `--exec` Brian Lyles
2024-03-25 23:16 ` [PATCH v5 2/7] docs: clean up `--empty` formatting in git-rebase(1) and git-am(1) Brian Lyles
2024-03-25 23:16 ` [PATCH v5 3/7] rebase: update `--empty=ask` to `--empty=stop` Brian Lyles
2024-03-25 23:16 ` [PATCH v5 4/7] sequencer: handle unborn branch with `--allow-empty` Brian Lyles
2024-03-25 23:16 ` [PATCH v5 5/7] sequencer: do not require `allow_empty` for redundant commit options Brian Lyles
2024-03-25 23:16 ` [PATCH v5 6/7] cherry-pick: enforce `--keep-redundant-commits` incompatibility Brian Lyles
2024-03-25 23:16 ` [PATCH v5 7/7] cherry-pick: add `--empty` for more robust redundant commit handling Brian Lyles

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='CAHPHrSf+joHe6ikErHLgWrk-_qjSROS-dXCHagxWGDAF=2deDg@mail.gmail.com' \
    --to=brianmlyles@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.com \
    --cc=newren@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).