BitBucket 4.14 diff between any two commits

I want to show a list of files on a repo that were changed between any two commits. When user clicks on individual file he will sill the diff between the revision i have provided. I do not need an UI element for this , just URL is fine. I looked at 

https://bitbucket.org/site/master/issues/4779/ability-to-diff-between-any-two-commits

But that link does not work in bitbucket 4.14, the enterprise version tht we have in our organization. Is there some way to do so in version 4.14 ? 

2 answers

2 votes

Hey Victor, 

It appears that you're looking for the Bitbucket Server feature request BSERV-2896. The link you posted is for Bitbucket Cloud which is a different code base. I posted a workaround there I think you might find helpful. I'll outline it below: 

You can tag commits that you wish to diff and then create a pull request and selecting tags instead of branches.

diftag.png

If you are willing to go outside of the UI, we have REST API that you can utilize to diff arbitrary commits. Here is our documentation on that REST API end point:

https://developer.atlassian.com/static/rest/stash/3.11.3/stash-rest.html#idp257216


The command line for diffs is: "git diff A B", where it shows the changes from A to B. Our REST URL looks like

/rest/api/latest/projects/KEY/repos/slug/changes?since=A&until=B 

(where A and B have the same relevance). That will list all the files that changed.

You can call /rest/api/latest/projects/KEY/repos/slug/diff/<one file>?since=A&until=B. Write the file path you want the diff for after "/diff/" and before "?since".

*Example:*


https://mybitbucket.com/rest/api/latest/projects/STASH/repos/stash/changes?since=689fcf1017dc944ab976433a9ead8f2912d83622&until=a222a1f58c17f9164eb498eeaadde94675a49467}}
https://mybitbucket.com/rest/api/latest/projects/STASH/repos/stash/diff/dao-impl/src/main/java/com/atlassian/stash/internal/pull/HibernateRescopeRequestDao.java?since=689fcf1017dc944ab976433a9ead8f2912d83622&until=a222a1f58c17f9164eb498eeaadde94675a49467

You will have to include a path after {{/diff}}. You can't just ask for the entire diff
So something like this will return a 400 Bad Request:

https://mybitbucket.com/rest/api/latest/projects/STASH/repos/stash/diff?since=689fcf1017dc944ab976433a9ead8f2912d83622&until=a222a1f58c17f9164eb498eeaadde94675a49467

I realize that neither of these are great options, but hopefully these workarounds can hold you over.

Error

We were unable to load this page.

That's all I get in diff tab :( 

Can you send me the link?

Hi. I can't, it's private repo.

I get it. You can also try replacing the commit id's with the version's

Thanks for your help! I was using short (7 digit) id instead of full id and thats why it didn't work.

Oops! I should have been more clear. It's good that you figured it out.

It seems to only work when diffing 2 branches. It does not work for me if it's the same branch.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

695 views 5 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you