Hi all!
We have missing trees errors on one remote git repository on the Bitbucket server.
We searched for the missing trees listed by "git fsck" using "git rev-list --reflog --ful-history --all". We found that all the missing trees are not contained in branches.
Some of the missing trees are contained in the MERGE commit in the stash-refs/pull-requests directory, and some are in logs/stash-refs/pull-requests directory.
We deleted some of the pull requests directly from the bitbucket UI, to get rid of the missing trees errors.
When we recreate the PR for the same branches and go to "diff" tab - we get a missing object error. When we run 'git ls-tree -r' on the new MERGE commit in the stash-refs - we see a newly corrupted object.
Seems that the behind-the-scene merge that Bitbucket does for each PR is creating corrupt objects in this repository, in the Bitbucket server only. These commits are called "Automatic Merge" and are created by opening a new Pull Request.
When we open the pull request in the Bitbucket UI and click on the "diff" tab we see the following error:
'/usr/bin/git diff-tree -C -r --format=%H <commit hash1> <commit hash2> --' exited with code 128 saying: error: object file ./objects/e7/<object> is empty fatal: loose object e7<hash> (stored in ./objects/e7/<object>) is corrupt.
This object is a missing tree and is a contained in the merge commit located in stash-refs/pull-requests/<PR #>/merge . Because this is created as a merge commit for a pull request on the Bitbucket server it does not exist on any developer machine or in any other location. There are also missing objects which are contained in "logs/stash-refs/pull-requests". According to this post: https://community.atlassian.com/t5/Bitbucket-questions/Diff-on-bitbucket-pull-request-does-not-show-code/qaq-p/822457#M28708 those are the "dark merges" of Bitbucket. Those merges point to corrupted trees. Is it possible to delete this dark merge directory and have Bitbucket recreated these merges?
Also - how can we completely delete old MERGED pull requests from the UI/server in order to get rid of the missing objects they hold?
Thanks!
Yael