Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket shows unexpected diff

Jens Müller
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 5, 2018

I created a feature brunch from a tag of the master branch I made changes in one file which are also changed in the master branch. If i create a pullrequest i expect that both files (on actual master branch and the feature branch) are the same, but i get a diff wich looks like bitbucket diffs against the tag on the master branch and not the actual version. Can anybody tell me why it shows the diff?

 

PullRequest

diff.JPG

File on master

master.JPG

File on feature branch

feature.JPGNetwork view

network.JPG

 

 

3 answers

1 accepted

1 vote
Answer accepted
Kristy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 23, 2018

Hi @Jens Müller,

 

On the 'Create Pull Request' page and the 'Compare Branch' page Bitbucket Server shows a 'common ancestor' diff (also known as a 2-way diff). This diff finds the commit that is common to both the source and target branches (known as the common ancestor commit) and compares the latest commit on the source branch with the common ancestor commit. This means that the diff you see does not contain any of the changes from the target branch that happened after you branched.

 

However, if in the diff view of a created pull request Bitbucket shows the effective diff (also known as a 3-way diff). To show this diff, Bitbucket creates a temporary merge between the source and target branch, and then shows you the diff between that merge commit and the tip of the target branch. This means that the changes you are seeing in a pull request contain the changes from the target branch and represent what the target branch will look like after you perform the merge.

 

The article 'A better pull request' explains this concept really well.

 

Hope that helps!

Kristy

Kristy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 23, 2018

Also, in the example you used you will find that the pull request will have a merge conflict because both the source and the target branch modified the same line of the same file.

Jens Müller
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 24, 2018

Hi @Kristy thanks for the answer. Can you explain why there are different merge methods? it is very confusing for me.

Also it confused me that the target commit id is shown as  faf836af17b  which is the latest commit on master.

Also i see no information about a merge conflict. It Shows only "No changes" on the "created pull" page

Adam Hughes December 30, 2022

Thank you for this answer, but FWIW, I HATE this.  Our team has had numerous PRs with diffs where we were sure we put a change into an env, only to see it reappear in a diff.  This got us into trouble a few times, as we just assumed something was awry.  Only now discovering that BB renders the diff for a PR differently than a diff for a branches comparison.  

 

While I don't understand this, I really would prefer some note in the UI or some setting to specify which we prefer.  In our case, the 3-way diff is NOT what we want.

 

PS I am talking about BBCloud, not BBServer, which has the same/similar problem.

Like # people like this
Deleted user March 16, 2023

I agree with Adam Hughes, above.  We're seeing this currently in our repo.

We have `dev`, `staging`, and `production` branches.  We branch off of `production` and merge separately into the three environment branches, to give us better control of what's deployed to each environment.

But even if we make sure the same branches are merged into dev, staging, and production in the same order, we still frequently end up with these spurious changes cluttering up our PR diffs.  This happens even when a diff between the two branches (e.g. dev and production) shows that there are no differences whatsoever.  Just now a member of our team created a feature off production, set a PR to merge to dev, and got two merges added into the diff that have no relevance, and whose contents are already in both dev and production.

This is not helpful, and we need the option to turn this off.

Like smoorthy likes this
3 votes
pawelgurw
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 30, 2021

For anyone reading this post v7 (2020):

unfortunately Bitbucket disabled 3-way diff in v7  resulting in "incorrect" diff mentioned in this question to becomes new standard, i.e. 2-way diff.

0 votes
Vinay Talla June 12, 2024

Hi @Kristy ,

we are facing an issue as described below which may lead us to missing files in BitBucket:

Below is sequence of steps performed to validate missing files in Bitbukect:

1. created clone branches for dev, stage and master as dev-XCC-2780, stage-XCC-2780, master-XCC-2780

created a local branch XCC-2780 from master and added a line "# BitBucket Missing Files XCC-2780, created branch from master" in the file "Clair-Setup/clairScanImages.sh"

merged XCC-2780(local branch) to master-XCC-2780(master clone) pull request link --> Configurations: #752 created branch master
MERGED

created branch XCC-2780-1 from dev and made same changes as above and merged to dev-XCC-2780 pull request link --> Configurations: #753 created from dev
MERGED

also merged changes from dev-XCC-2780 to stage-XCC-2780 pull request link ---> Configurations: #754 created from dev
MERGED

As above changes already merged to master-XCC-2780 from branch XCC-2780(local branch), so the pull request from stage-XCC-2780 to master-XCC-2780 should be empty but we see same changes been displayed.
pull request link ---> Configurations: #755 created from dev
OPEN

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events