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

Git diff show different files than PR (Pull Request)

jhownfs April 13, 2023

Hi Guys, how are you?

 

I noticed that when I do a git diff between the source and destination branch, more files appear than in the PR (pull request), for some reason, which I still don't understand.

example: git diff --name-only origin/develop origin/qa.

PR show - file 1, file 2, file 3.

git diff show - file 1, file 2, file 3, file 4, file 5

Does anyone know the reason for this behavior? why does diff perish more files than in PR?

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 17, 2023

Hi @jhownfs,

The diff command you are using is equivalent to the two-dot diff command

git diff --name-only origin/develop..origin/qa

The two dot diff will show changes in both the source and the destination branches.

The pull requests diff in Bitbucket Cloud is using a three-dot diff instead

git diff --name-only origin/develop...origin/qa

This type of diff will show only changes in the source branch, starting at a common ancestor of both branches. It will not show any changes made to the destination branch.

If file 4 and file 5 were changed in the destination branch only, this explains why they will not show in the PR diff on Bitbucket Cloud site.

If you want to see the changes made to the destination branch in a PR, you can merge the destination branch into the source branch.

You can find more details here:

More information about git diff:

git diff [<options>] <commit> <commit>…​ <commit> [--] [<path>…​]

This form is to view the results of a merge commit. The first listed <commit> must be the merge itself; the remaining two or more commits should be its parents. Convenient ways to produce the desired set of revisions are to use the suffixes ^@ and ^!. If A is a merge commit, then git diff A A^@, git diff A^! and git show A all give the same combined diff.

git diff [<options>] <commit>..<commit> [--] [<path>…​]

This is synonymous to the earlier form (without the ..) for viewing the changes between two arbitrary <commit>. If <commit> on one side is omitted, it will have the same effect as using HEAD instead.

git diff [<options>] <commit>...<commit> [--] [<path>…​]

This form is to view the changes on the branch containing and up to the second <commit>, starting at a common ancestor of both <commit>. git diff A...B is equivalent to git diff $(git merge-base A B) B. You can omit any one of <commit>, which has the same effect as using HEAD instead.

Kind regards,
Theodora

Denis February 12, 2024

Hi Theodora, 

 

I am sorry to say that this choice to use diff ...  induces misunderstanding.

 

At the very least, bitbucket should display the "real" commit hash used for diff, explaining that this is the most recent common ancestor. Because at the moment, all it does is spreading confusion, as bitbucket displays a commit hash that is not used for the diff.

I posted a screenshot to illustrate this.
bitbucketDiffExplained.PNG

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 13, 2024

Hi Denis,

Thank you for reaching out.

Can you please confirm if you are using Bitbucket Cloud (repos hosted in https://bitbucket.org/) or Bitbucket Server (different, custom URL)?

This question concerns Bitbucket Cloud, but I can't find a Bitbucket Cloud account with your email address.

Kind regards,
Theodora

Denis February 13, 2024

Hello :)

I use a private company Bitbucket Server. I hope I don't have to tell you which, because I am not in charge of commercial aspects

 

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 13, 2024

Hi Denis,

Bitbucket Server has a different source code base than Bitbucket Cloud. Support for Server products ends on Feb 15, 2024 so there will be no new features available on the Server version. If you have a Bitbucket Data Center license instead, you can reach out to the support team via https://support.atlassian.com/contact/#/ and ask for a feature request to be created about what you're asking.

Kind regards,
Theodora

Denis February 13, 2024

We have the data center version, but I understand this "diff ..." was due to performance issue so, will it have any effect that I make a ticket to our support ? :)

In any case thank for your time.

 

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 14, 2024

Hi Denis,

The support will not be able to change the diff algorithm. There is an existing feature request where you can add your feedback and vote: https://jira.atlassian.com/browse/BSERV-7375

You mentioned something earlier about showing the common ancestor in the PR along with an explanation. The support team can help create a feature request for that too.

Kind regards,
Theodora

Denis February 14, 2024

Will definitly do :) thank you Theodora !

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 14, 2024

You are very welcome, Denis! Please feel free to reach out if you need anything further!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events