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

Re: How to turn off rename detection for cherry-pick?

From
PRPavel Rappo <pavel.rappo@gmail.com>
Date
Aug 29, 2024, 08:47 UTC
Message-ID
<CAChcVunYDO_KAmEOoWEL2q63_Gzua-Kt3BmE5Snb8==K9Cww1w@mail.gmail.com>
In-Reply-To
<CAChcVumj41NCAcjzLyDGAyb+-QuL0Ha1AANe67jKVBT8xDRYdg@mail.gmail.com>

The reason I ask this is that we've run into a (probably practically rare) case where cherry-pick changes a wrong file. We want to be able to detect such cases.

Distilled from the actual repo, here is the case. Create a repo first:
    mkdir cherry-pick-carefully
    cd cherry-pick-carefully
    git init -b main .
    cat << EOF > x.txt
    1
    2
    3
    4
    5
    EOF
    git add x.txt
    git commit -m "Add x.txt"
    git checkout -b feature
    git rm x.txt
    git add x.txt
    git commit -m "Delete x.txt"
    cat << EOF > y.txt
    1
    2
    3
    4
    EOF
    git add y.txt
    git commit -m "Add y.txt, similar but not equal"
    cat << EOF > y.txt
    1
    2
    4
    EOF
    git add y.txt
    git commit -m "Slightly change y.txt"
    git checkout main
Now try to cherry-pick feature's head commit onto main:
    cd cherry-pick-carefully
    git cherry-pick feature

With a default git configuration, this should (surprisingly to many) change x.txt instead of y.txt, which is not what the user would expect.

Previous: Pavel RappoNext: Jeff King
Message 2 of 10 in “How to turn off rename detection for cherry-pick?”
  1. Pavel RappoAug 26, 2024
  2. Pavel RappoAug 29, 2024
  3. Jeff KingAug 29, 2024
  4. Pavel RappoAug 29, 2024
  5. Jeff KingAug 30, 2024
  6. Pavel RappoAug 30, 2024
  7. Elijah NewrenAug 30, 2024
  8. Junio C HamanoAug 30, 2024
  9. Junio C HamanoAug 30, 2024
  10. Junio C HamanoAug 30, 2024

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.