Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I do a git diff between two commits in same branch using bitbucket api 2.0?

Claire Wood
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 10, 2019

I can see how to diff a specific commit using a url of the format 

https://api.bitbucket.org/2.0/repositories/{username}/{repo_slug}/diff/<commit1>..<commit2>

and between two different branches this appears to work. However, when comparing two commits from the same branch, it only appears to diff the changes made by commit2. 

Ideally I want the equivalent of running

$git diff <commit1> <commit2>

from the command line. 

Any pointers would be most welcome. 

 

 

1 answer

0 votes
Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 10, 2019

Hello @Claire Petley,

The diff REST endpoint you referred to generates a 3-way diff in case you pass a revspec of 2 commits (e.g. aaa..bbb): it shows the changes introduced by the left ref (aaa) as compared against the right ref (bbb).

So assuming that aaa is actually an ancestor of bbb (e.g. they're "on the same branch") you can see the diff introduced by all commits between them including bbb, you need to use the following revspec bbb..aaa. The result will be similar to the output of git diff aaa bbb.

Hope this helps. Let me know if you have any questions.

Cheers,
Daniil

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events