Skip to content

Conflict detection for PR is broken with git >= 2.32.0 #18514

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

Closed
kvaster opened this issue Feb 1, 2022 · 1 comment · Fixed by #18536
Closed

Conflict detection for PR is broken with git >= 2.32.0 #18514

kvaster opened this issue Feb 1, 2022 · 1 comment · Fixed by #18536
Labels
Milestone

Comments

@kvaster
Copy link
Contributor

kvaster commented Feb 1, 2022

Gitea Version

1.16.0, 1.17.0+dev-74-g80048c091

Git Version

2.35.1, gitea demo git version

Operating System

No response

How are you running Gitea?

Built by myself and https://try.gitea.io

Database

No response

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Description

  • Create new repository
  • Create commit with simple text file with simple content: 1
  • Create branch feature1 with modified file content: 11
  • Create PR feature1 -> master
  • Create one more commit in master with modified conflicting content: 12
  • Create branch feature2 with modified file content: 13
  • Create PR feature2 -> master

Both feature1 and feature2 PRs will show:

  • This pull request can be merged automatically.
  • This branch is out-of-date with the base branch

Pressing 'Update branch by merge' or 'Update branch by rebase' will show no any visual changes (just page refresh) on demo site and will show 'Merge conflict checking is in progress. Try again in few moments' on my own install (refreshing page will show no changes).

Pressing 'Create merge commit' will show red panel reporting merge conflict with bad translation: 'editor.merge_conflict'.

Pressing 'Rebase then fast-forward' or 'Rebase then create merge commit' will show red panel reporting error message.

Pressing 'Create squash commit' will show server internal error 500.

Screenshots

image

image

image

@kvaster
Copy link
Contributor Author

kvaster commented Feb 1, 2022

I found at least one problem: https://github.com/go-gitea/gitea/blame/main/services/pull/patch.go#L347

This code applies --3way additional flag for git patch apply. Here goes output of this command (git version 2.35.1, also tested with git version 2.32.0):

git apply --check --cached --3way /tmp/patch1881667419
Applied patch to 'README.md' with conflicts.

and

git apply --check --cached /tmp/patch1881667419 
error: patch failed: README.md:1
error: README.md: patch does not apply

And following code is unable to parse output with --3way argument: https://github.com/go-gitea/gitea/blame/main/services/pull/patch.go#L384

@kvaster kvaster changed the title Conflict detection for PR is broken Conflict detection for PR is broken with git >= 2.32.0 Feb 1, 2022
zeripath added a commit to zeripath/gitea that referenced this issue Feb 1, 2022
Unforunately git apply --3way reports conflicts differently than standard patches
resulting in conflicts being missed.

Adjust the conflict detection code to account for this different error reporting.

Fix go-gitea#18514

Signed-off-by: Andrew Thornton <[email protected]>
zeripath added a commit to zeripath/gitea that referenced this issue Feb 1, 2022
Backport go-gitea#18536

Unforunately git apply --3way reports conflicts differently than standard patches
resulting in conflicts being missed.

Adjust the conflict detection code to account for this different error reporting.

Fix go-gitea#18514

Signed-off-by: Andrew Thornton <[email protected]>
@zeripath zeripath added this to the 1.16.1 milestone Feb 1, 2022
lunny added a commit that referenced this issue Feb 2, 2022
* Detect conflicts with 3way merge

Unforunately git apply --3way reports conflicts differently than standard patches
resulting in conflicts being missed.

Adjust the conflict detection code to account for this different error reporting.

Fix #18514

Signed-off-by: Andrew Thornton <[email protected]>

* and three-way failed

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: Lunny Xiao <[email protected]>
zeripath added a commit that referenced this issue Feb 2, 2022
Backport #18536

Unforunately git apply --3way reports conflicts differently than standard patches
resulting in conflicts being missed.

Adjust the conflict detection code to account for this different error reporting.

Fix #18514

Signed-off-by: Andrew Thornton <[email protected]>
Chianina pushed a commit to Chianina/gitea that referenced this issue Mar 28, 2022
* Detect conflicts with 3way merge

Unforunately git apply --3way reports conflicts differently than standard patches
resulting in conflicts being missed.

Adjust the conflict detection code to account for this different error reporting.

Fix go-gitea#18514

Signed-off-by: Andrew Thornton <[email protected]>

* and three-way failed

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: Lunny Xiao <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants