Re: How to turn off rename detection for cherry-pick?
- From
- Pavel 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 mainNow try to cherry-pick feature's head commit onto main:
cd cherry-pick-carefully
git cherry-pick featureWith a default git configuration, this should (surprisingly to many) change x.txt instead of y.txt, which is not what the user would expect.