Commit comments are lost in pull request after rebase from master in Bitbucket Datacenter

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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.

*Except Fisheye and Crucible

Summary

Comments for commits in the pull request (PR) Diff view are lost after rebase from the master in Bitbucket Datacenter. The comments do appear in the Pull request Overview tab as outdated but not seen in the Diff view.

(Auto-migrated image: description temporarily unavailable)

Environment

The solution has been validated in Bitbucket Datacenter 8.9.6 but may be applicable to other versions

Diagnosis

The behaviour can be reproduced using the following steps.

  1. Create 2 files a.txt, b.txt and committed to Master as part of 1st commit 'A'.

  2. Create a branch, modify file a.txt and commit with commit ID 'C'.

  3. Create a PR from branch b1 to master and add a comment to the file a.txt. The comment is associated with source commit "A" and target commit "C"

  4. On the master branch, make a commit to file b.txt (with the commit ID B). The git tree looks something like

    1 2 Master -> A --- B branch -> \ _ _ C
  5. Rebase from master branch

  6. comment on a file a.txt will disappear after rebase in diff view. After the rebase operation, the git tree looks like

    1 2 Master -> A --- B branch -> \ _ _ D

Cause

The comment is associated with source commit "A" and target commit "C". The entries are stored in bb_comment_thread table in the database. The comment information created on the file a.txt is stored in the table as

id

created_timestamp

updated_timestamp

from_hash

to_hash

is_orphaned

to_path

resolved

1

creation_timestamp

updated_timestamp

A

C

false

a.txt

false

With the rebase option, the branch commit is rebased to the tip of the master branch. During the rebase process, the commit history is rewritten. The "C" commit is removed, and the "D" commit is added.

1 2 Master -> A --- B branch -> \ _ _ D

The comment information on the table after the rebase operation looks like

id

created_timestamp

updated_timestamp

from_hash

to_hash

is_orphaned

to_path

resolved

1

creation_timestamp

updated_timestamp

A

C (no longer available)

true

a.txt

false

The to_hashC is no longer available because of rebase operation, the comment is outdated and is_orphaned flag is marked true. Since the comment is associated with source commit "A" and target commit "C", and the commit "C" is no longer found, the comment is orphaned and not shown for commit "D". So, we see that the comment as "outdated" in pull request overview tab but not shown in pull request Diff view.

(Auto-migrated image: description temporarily unavailable)

Solution

The comment is anchored using the from_hash and to_hash. The comment is marked outdated on the remove commit (due to rebase operation) in the PR overview and thus not shown in the Diff view as it's outdated. This behaviour is intentional. The original context is retained on the overview and marked as "Outdated," allowing you to see how the content looked when you added your comment. Still, it has been removed from the diff because the current content of the file isn't in a valid context.

To overcome the problem, avoid a rebase operation that rewrites commit history.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.