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?
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
git diff [<options>] <commit>..<commit> [--] [<path>…]^@
and^!
. If A is a merge commit, thengit diff A A^@
,git diff A^!
andgit show A
all give the same combined diff.This is synonymous to the earlier form (without the
git diff [<options>] <commit>...<commit> [--] [<path>…]..
) 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.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 togit 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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are very welcome, Denis! Please feel free to reach out if you need anything further!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.