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

Blake McAlevey-Scurr Jul 09, 2018

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
Aaron Levinson Atlassian Team Jul 11, 2018

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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder :  #!/bin/bash source "$(dirname "$0")/" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

1,809 views 1 19
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