It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Raw diff/patch from bitbucket server api Edited

I have an application that needs the raw diff of a PR in the form that you would expect from `git diff <commitA> <commitB>`. But the Bitbucket Server API only seems to show diffs in a custom json format. Did I miss some way to query the raw diff? Or perhaps the json is a standard format I'm not aware of. I can always deal with it manually if need be. 

Raw example:

diff --git a/file2.test b/file2.test
new file mode 100644
index 0000000..75b3cd7
--- /dev/null
+++ b/file2.test
@@ -0,0 +1 @@

JSON example:

"fromHash": "eee37aed1be4acd61e3a62346a93aa77fc04487c",
"toHash": "937b78681510f8dfd0a9185f01109edc8ca99569",
"contextLines": 10,
"whitespace": "SHOW",
"diffs": [{
"source": null,
"destination": {
"components": ["file2.test"],
"parent": "",
"name": "file2.test",
"extension": "test",
"toString": "file2.test"
"hunks": [{
"sourceLine": 0,
"sourceSpan": 0,
"destinationLine": 1,
"destinationSpan": 1,
"segments": [{
"type": "ADDED",
"lines": [{
"source": 0,
"destination": 1,
"line": "ayyo",
"truncated": false
"truncated": false
"truncated": false
"truncated": false
"truncated": false

 edit: formatting

1 answer

0 votes

Hello Blake,


Welcome to the Atlassian Community!


Most APIs usually return it's payload in JSON format as far as I know, but that is what we parse to display data on the page. But if your application requires the typical git diff return, is it possible to simply run the git diff from your application? You could give it a user in Bitbucket server to have separate credentials and it can clone and run git diff on its own.


Aaron Levinson
Dev Tools Support Engineer

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Atlassian supported Jenkins integration for Bitbucket Server

We’ve been building a plugin to integrate Bitbucket Server and Jenkins CI, and I’m excited to announce that our alpha is ready to download and install. It lets you seamlessly configure a Jenkins job ...

453 views 0 10
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you