git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] cherry-pick: refuse cherry-pick sequence if index is dirty

From
Tao Klerks <tao@klerks.biz>
Date
May 23, 2023, 16:01 UTC
Message-ID
<CAPMMpojV1Ts=OKM0FbBHU6=EB5RKNxHucX-8VQmYoQBNefKpqQ@mail.gmail.com>
In-Reply-To
<pull.1535.git.1684830767336.gitgitgadget@gmail.com>

On Tue, May 23, 2023 at 10:32 AM Tao Klerks via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 22 quoted lines
>
> From: Tao Klerks <tao@klerks.biz>
>
> Cherry-pick, like merge or rebase, refuses to run when there are changes
> in the index. However, if a cherry-pick sequence is requested, this
> refusal happens "too late": when the cherry-pick sequence has already
> started, and an "--abort" or "--quit" is needed to resume normal
> operation.
>
> Normally, when an operation is "in-progress" and you want to go back to
> where you were before, "--abort" is the right thing to run. If you run
> "git cherry-pick --abort" in this specific situation, however, your
> staged changes are destroyed as part of the abort! Generally speaking,
> the abort process assumes any changes in the index are part of the
> operation to be aborted.
>
> Add an earlier check in the cherry-pick sequence process to ensure that
> the index is clean, reusing the already-generalized method used for
> rebase. Also add a test.
>
> Signed-off-by: Tao Klerks <tao@klerks.biz>
> ---

My apologies for the premature submission: I've now realized I used the wrong existing check. "git rebase" checks for a clean *worktree* (ignoring untracked files), and that is what I reused here. What git merge and git cherry-pick check for, and what I should have added a check for here, is a clean *index*.

The current implementation of this patch is far too restrictive. It doesn't break any tests (and maybe I should add one now that I know), but it's doing the wrong thing.

Tao
Previous: Tao Klerks via GitGitGadgetNext: Junio C Hamano
Message 2 of 8 in “cherry-pick: refuse cherry-pick sequence if index is dirty”
  1. cherry-pick: refuse cherry-pick sequence if index is dirtyTao Klerks via GitGitGadget, May 23, 2023
  2. Tao KlerksMay 23, 2023
  3. Junio C HamanoMay 24, 2023
  4. Tao KlerksMay 24, 2023
  5. Phillip WoodMay 30, 2023
  6. cherry-pick: refuse cherry-pick sequence if index is dirtyTao Klerks via GitGitGadget, May 28, 2023
  7. Phillip WoodMay 30, 2023
  8. Tao KlerksSep 6, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.