Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge.renames not work #5178

Open
1 task done
ZeroChiLi opened this issue Sep 27, 2024 · 4 comments
Open
1 task done

merge.renames not work #5178

ZeroChiLi opened this issue Sep 27, 2024 · 4 comments
Labels

Comments

@ZeroChiLi
Copy link

ZeroChiLi commented Sep 27, 2024

  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.46.0.windows.1
cpu: x86_64
built from commit: 2e6a859ffc0471f60f79c1256f766042b0d5d17d
sizeof-long: 4
sizeof-size_t: 8
shell-path: D:/git-sdk-64-build-installers/usr/bin/sh
feature: fsmonitor--daemon
libcurl: 8.9.0
OpenSSL: OpenSSL 3.2.2 4 Jun 2024
zlib: 1.3.1

  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.19045.4780]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
> type "$env:USERPROFILE\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

"C:\Program Files\Git\etc\install-options.txt"
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

no

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

CMD

git merge xxxxx
  • What did you expect to occur after running these commands?

no

  • What actually happened instead?

When I perform the merge operation, the result of find_renames in diffcore-rename.c is not what I expected, comparing two unrelated objects. I want to merge branches using merge when I turn off rename checking, I have set up git config merge.renames=false, but the code doesn't seem to support it?

//merge-ort.c
	/*
	 * detect_renames, verbosity, buffer_output, and obuf are ignored
	 * fields that were used by "recursive" rather than "ort" -- but
	 * sanity check them anyway.
	 */
	assert(opt->detect_renames >= -1 &&
	       opt->detect_renames <= DIFF_DETECT_COPY);

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

no

@dscho
Copy link
Member

dscho commented Sep 27, 2024

When I perform the merge operation, the result of find_renames in diffcore-rename.c is not what I expected, comparing two unrelated objects. I want to merge branches using merge when I turn off rename checking, I have set up git config merge.renames=false, but the code doesn't seem to support it?

//merge-ort.c
	/*
	 * detect_renames, verbosity, buffer_output, and obuf are ignored
	 * fields that were used by "recursive" rather than "ort" -- but
	 * sanity check them anyway.
	 */
	assert(opt->detect_renames >= -1 &&
	       opt->detect_renames <= DIFF_DETECT_COPY);

@ZeroChiLi Could you help us understand what you mean? One good way to do that would be to provide a Minimal, Complete, and Verifiable example, i.e. a detailed, step-by-step description that sets up a fresh Git repository and demonstrates precisely what is going wrong, by example.

@dscho dscho added the unclear label Sep 27, 2024
@ZeroChiLi
Copy link
Author

ZeroChiLi commented Sep 27, 2024

My project is very large and it may take some time to reproduce a mini project. My main problem is that there is no way to turn off the detect_rename when merging.
I tried git config merge.renames false,but detect_rename is still checked when merging branches.

@dscho
Copy link
Member

dscho commented Sep 27, 2024

there is no way to turn off the detect_rename when merging.

If this is really true, then something very simple like this should reproduce the bug (and I am a bit miffed that it was me who needed to write this, I specifically asked you to provide such an example, I will conclude my involvement in this ticket after this, as a consequence):

git init test-renames
cd test-renames

echo a >a
git add a
git commit -m a

# start a branch that renames the file
git mv a b
git commit -m rename

# start another branch that modifies the file
git reset --hard HEAD^
echo c >a
git commit -c a

# now merge, turning off rename detection
git -c merge.renames=false merge HEAD@{2}

# now test whether the file `b` has the contents `c`,
# which would mean that the rename was detected, still

@ZeroChiLi
Copy link
Author

I apologize for the misunderstanding; I thought it was an example where the result of the find_renames function was not as expected. Also, thank you for the example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants