From: Tao Klerks <tao@klerks.biz>
To: phillip.wood@dunelm.org.uk
Cc: Tao Klerks via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2] cherry-pick: refuse cherry-pick sequence if index is dirty
Date: Wed, 6 Sep 2023 07:02:39 +0200 [thread overview]
Message-ID: <CAPMMpoj8udDuDferkaRfoKDV6EHMVO6fH3_GE9SUN51VKbwvJA@mail.gmail.com> (raw)
In-Reply-To: <999f12b2-38d6-f446-e763-4985116ad37d@gmail.com>
On Tue, May 30, 2023 at 4:16 PM Phillip Wood <phillip.wood123@gmail.com> wrote:
>
> Hi Tao
>
> On 28/05/2023 10:08, Tao Klerks via GitGitGadget wrote:
> > From: Tao Klerks <tao@klerks.biz>
> >
> <SNIP>
>
> I found the changes up to this point a bit confusing. Maybe I've missed
> something but I don't think they are really related to fixing the bug
> described in the commit message. As such they're a distraction from the
> "real" fix.
>
Understood, thanks - *if* I kept them, they should be in a separate
"prep refactor" commit.
The reason I did all this was just that I needed to build a new
message that displayed the correct cherry-pick action name - something
that was, in the existing code, done by repeating the entire advice
message. I didn't want to do the same, and if I was going add what I
needed to construct the message more dynamically I figured I should
update the existing repetition-based approach.
>
> > + requested_action_name = cherry_pick_action_name(requested_action);
>
> We already have the function action_name() so I don't think we need to
> add cherry_pick_action_name().
The reason I had added a new one was that action_name() also supported
"REPLAY_INTERACTIVE_REBASE", which should not be an option in the
codepath that I was refactoring. I wanted to retain the existing
"defensiveness", but that clearly got in the way of both brevity and
clarity.
> Also the name of the new function is
> confusing as it may return "revert".
Yeah, the name was supposed to reflect the context ("cherry-pick logic
which also covers revert, as opposed to rebase which also uses
sequencer but is a substantially separate flow"), rather than the
output value.
>
> > + if (require_clean_index(r, requested_action_name,
> > + _("Please commit or stash them."), 1, 1))
>
> How does this interact with "--no-commit"? I think the check that you
> refer to in the commit message is in do_pick_commit() where we have
>
> if (opts->no_commit) {
> /*
> * We do not intend to commit immediately. We just want to
> * merge the differences in, so let's compute the tree
> * that represents the "current" state for the merge machinery
> * to work on.
> */
> if (write_index_as_tree(&head, r->index, r->index_file, 0, NULL))
> return error(_("your index file is unmerged."));
> } else {
> unborn = repo_get_oid(r, "HEAD", &head);
> /* Do we want to generate a root commit? */
> if (is_pick_or_similar(command) && opts->have_squash_onto &&
> oideq(&head, &opts->squash_onto)) {
> if (is_fixup(command))
> return error(_("cannot fixup root commit"));
> flags |= CREATE_ROOT_COMMIT;
> unborn = 1;
> } else if (unborn)
> oidcpy(&head, the_hash_algo->empty_tree);
> if (index_differs_from(r, unborn ? empty_tree_oid_hex() : "HEAD",
> NULL, 0))
> return error_dirty_index(r, opts);
> }
>
> I think it would be simpler to reuse the existing check by extracting
> the "else" clause above into a separate function in sequencer.c and call
> it here guarded by "if (!opts->no_commit)" as well as in that "else"
> clause in do_pick_commit()
That sounds very plausible.
I will (very belatedly) have a go, and submit another version sometime soon.
Thanks so much for taking the time to review, and my apologies for the
months-later context revival!
prev parent reply other threads:[~2023-09-06 5:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-23 8:32 [PATCH] cherry-pick: refuse cherry-pick sequence if index is dirty Tao Klerks via GitGitGadget
2023-05-23 16:01 ` Tao Klerks
2023-05-24 0:06 ` Junio C Hamano
2023-05-24 9:33 ` Tao Klerks
2023-05-30 13:01 ` Phillip Wood
2023-05-28 9:08 ` [PATCH v2] " Tao Klerks via GitGitGadget
2023-05-30 14:16 ` Phillip Wood
2023-09-06 5:02 ` Tao Klerks [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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPMMpoj8udDuDferkaRfoKDV6EHMVO6fH3_GE9SUN51VKbwvJA@mail.gmail.com \
--to=tao@klerks.biz \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--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.
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).