Merging a pull request with 'rebase and fast-forward' strategy fails with merge conflict in Bitbucket Server
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Fisheye および Crucible は除く
要約
Merging a pull request with 'rebase and fast-forward' strategy gives merge conflict error in Bitbucket server. However, there is no actual conflict within commits as they are empty. The pull request can be merged with a different merge strategy without issues.
On the UI, it errors with
The merge could not be completed automatically. Please clone 'project/repo, checkout 'branch_1' and merge 'branch_2' (or commit 'commit_hash_2') manually, resolving any conflicts, and push the result.
環境
Bitbucket server / Datacenter 6.10.0
Git on the server was built from the source
診断
From Bitbucket logs, we see the merge operation fails with
com.atlassian.bitbucket.scm.MergeException: The merge could not be completed automatically. Please clone '<PROJ/REPOSITORY>', checkout '<BRANCH1>' and merge '<BRANCH2>' (or commit '<commit-hash>') manually, resolving any conflicts, and push the result.
.
Caused by: com.atlassian.bitbucket.scm.CommandFailedException: '/opt/git/git_current/bin/git rebase -q --no-verify commit_hash_1 commit_hash_2' exited with code 1 saying: /opt/git/git_current/libexec/git-core/git-sh-setup: line 46: /opt/tmp/git/libexec/git-core/git-sh-i18n: No such file or directory
原因
Git couldn't find the file /opt/tmp/git/libexec/git-core/git-sh-i18n
ソリューション
Confirm if the file /opt/tmp/git/libexec/git-core/git-sh-i18n
exists and is being used by the git that Bitbucket Server is using.
In this case, the file that git couldn't find is git-core/git-sh-i18n
- As this is a core git file, this error might indicate that the git binary being used is incomplete and git should be reinstalled.
- If the file is present, it can be pointed to using environment variables. Using Git Internals - Environment Variables as a guide, GIT_EXEC_PATH can be set for the Bitbucket Server user (atlbitbucket) so that it points to the correct git path.