-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Conflicting files shown on pull request but merging without conflict #13679
Comments
the easyest workarounds would either be a rebase or a merge from base int head-branch localy and push result |
I found sometimes github also have the problem. It seems it depends on different merge style. |
Interesting. How are the conflicting files determined? |
check logic is here Lines 111 to 126 in 24330f7
|
maybe we can try this way
|
$ git merge test
Auto-merging settings.py
Merge made by the 'recursive' strategy.
settings.py | 41 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-) Please note the @a1012112796 your proposal would also require a complete checked out copy of the codebase. |
@zacheryph secound choice, should check diff beturn head branch and merge base if they are not same. only when the file has been changed is in |
Related: #6417 |
This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions. |
I think we need to be clear here that the automatic system in gitea can never be as good a merger as git on the command line. Why? Well git on the command line has a checked out copy and can do octopus merges and take account of history to resolve conflicts that the system cannot do. We can only do basic diff patch applications. |
In fact, github also has the problem. |
#6417 demonstrates a case where GitHub shows a PR as mergeable while Gitea doesn't, although I haven't tried that exact case in Gitea in a long time, maybe there have been improvements already |
I have a similar issue. Using git, I created a branch from a feature branch, deleted over 1000 of old files and directories. One of the directories contained 10 .docx Word files. I committed these changes, pushed them to my remote repository on the Gitea v1.14.1 server, and created a pull request to push the deletes to the feature branch. Gitea complained that "This pull request has changes conflicting with the target branch. ", listing the the 10 .docx Word files. No option was provided to merge the feature branch to my branch. In Gitea, on the Files Changed tab, it does show the contents of the docx files as being deleted. I even tried only including the deletion of the directory and the 10 docx files in a pull request, and Gitea still complained about it. `
|
At the risk of repeating myself - we cannot be as good at conflict resolution as git with a worktree. Having a worktree allows git to run Without a worktree present - which we cannot have - we are limited to a much stronger set of conditions. If you genuinely believe that the is a better algorithm for merge collision detection please provide it - however, it can only be run in a bare repository - not one with a worktree. (You are allow to create an index file though.) The above demonstration is a false comparison because there is a worktree present. |
@zeripath Note: |
Sorry - yes |
I am the responsible for deploying Gitea on the company. Some devs have found this issue, and after arriving to this thread I tried a couple solutions for the problem. Despite the fact that we have different merge strategies that "are not supported" by gitea for the reasons mentioned above, every time I restart the server, the devs are capable of creating the PRs. Why is that? Here is my error log and the issue seems to be the same. Why after a restart it works if the "merge strategy" is "limited"? :/
|
I quite often run into this as well. Our CI applies automatic dependency upgrades to Maven pom.xml. |
Hmm... I've just had a thought - maybe we can use What is really needed though is a few good testcases that reliable replicate the problem because without them we cannot be sure that any improvement we suggest is actually an improvement. |
Here's a minimal reproducer for my usecase: https://try.gitea.io/jpraet/conflict-detection/pulls/1 |
OK, my proposed PR using Can you give an example that should conflict too? |
The current TestPatch conflict code uses a plain git apply which does not properly account for 3-way merging. However, we can improve things using `git read-tree -m` to do a three-way merge. We can also use `--patience` to generate a nicer diff for applying patches too. Fix go-gitea#13679 Signed-off-by: Andrew Thornton <[email protected]>
This one should conflict: https://try.gitea.io/jpraet/conflict-detection/pulls/2 |
yup and #18004 does that correctly too. |
Unfortunately OP's https://try.gitea.io/test-gitea3/conflict-test/pulls/1 example is still detected as conflicting with #18004. |
OK if we do an git apply with --3way that will work but we can't do that for git <2.32.0. now |
To get this working properly means that I would need to reimplement git-merge-one-file but so that it can work without a worktree. I think that's possible and it would improve the cherry-pick PR I've written too. I'll look at it but I'll leave #18004 up as it's a clear improvement from what we currently have. If #18004 isn't merged by the time I've done that I'll update it. |
My repro from #6417 is no longer on Gitea, but the repository is still on Github if you want to try that one too :-) |
OK I've finally implemented git-merge-one-file within gitea - it wasn't actually that bad I can't believe I've been avoiding doing that for 3 almost years. |
…-file functionality (#18004) The current TestPatch conflict code uses a plain git apply which does not properly account for 3-way merging. However, we can improve things using `git read-tree -m` to do a three-way merge then follow the algorithm used in merge-one-file. We can also use `--patience` and/or `--histogram` to generate a nicer diff for applying patches too. Fix #13679 Fix #6417 Signed-off-by: Andrew Thornton <[email protected]>
Now that the git-merge-one-file algorithm is implemented, to improve further would require implementing a checkoutless git merge recursive or even ort. This would be quite a bit more difficult and potentially quite a bit slower. |
…-file functionality (go-gitea#18004) The current TestPatch conflict code uses a plain git apply which does not properly account for 3-way merging. However, we can improve things using `git read-tree -m` to do a three-way merge then follow the algorithm used in merge-one-file. We can also use `--patience` and/or `--histogram` to generate a nicer diff for applying patches too. Fix go-gitea#13679 Fix go-gitea#6417 Signed-off-by: Andrew Thornton <[email protected]>
1.12.5
and1.14.0+dev-251-g78204a7a7
2.24.1
[x]
):Description
I created a pull request which showed me that one of the files was conflicting. I then wanted to resolve this conflict locally but the merge worked just fine.
I re-created this on
try.gitea.io
with a simplified example, see this test repo: https://try.gitea.io/test-gitea3/conflict-testSteps taken:
master
test
test
master
Result:
This is the output when merging locally:
The text was updated successfully, but these errors were encountered: