Missing file url upon calling the diffstat endpoint

Paolo.Ascari
Contributor
May 18, 2023

Hello, using the Bitbucket CLOUD API, and after calling the .../diffstat/xxxx..yyyy endpoint I'm getting the following response:

type          : diffstat
lines_added : 5
lines_removed : 1
status : merge conflict
old : @{path=myfile; type=commit_file; escaped_path=myfile; links=}
new : @{path=myfile; type=commit_file; escaped_path=myfile; links=}

However, inspecting the two "links" fields, only the old one is populated with the appropriate .../src/yyyy/myfile endpoint URI, whereas the new one has "links={}".

If I perform a 3-way diff, instead, i.e. calling .../diffstat/xxxx..yyyy?topic=false, then both old and new are correctly populated with their respective endpoints.

Is this by design? If so, why is the new link not available in my first example?

Edit: I should add that the 3-way diff returns a status of 'modified' instead of 'merge conflict', as shown above... which to me doesn't make sense, because regardless of the diff strategy, I'm still comparing the same 2 commits...?

Thanks in advance for any feedback.

1 answer

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 22, 2023

Hi Paolo!

I will reach out to the development team regarding the missing links from the new field and I will get back to you.

Regarding the 'merge conflict' status, I replied to your other question here that the topic query parameter was introduced last year and it does not return the 'merge conflict' status as we will eventually remove this status.

Kind regards,
Theodora

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 26, 2023

Hi Paolo,

I reached out to the development team regarding your question.

When the topic query parameter is not used with the diffstat API endpoint, you are getting a preview merge diff. What this means is that we simulate a merge on the backend and generate a temporary merge commit. Then we compute the diff between this merge commit against the head commit of the destination branch.

Since this merge commit is temporary, the links in new are missing because the merge commit is discarded and doesn't exist in your repo.

This type of diff was previously used in PRs in Bitbucket Cloud before we made the changes announced here last year:

The diffstat API endpoint without topic is still using the preview merge diff, so that we don't break existing integrations that rely on the merge conflict status (since we have no other API endpoint that shows conflicts yet).


When topic=true is used with this endpoint, it will produce a three dot diff, equivalent to

git diff --stat main...feature

When topic=false is used with this endpoint, it will produce a two dot diff, equivalent to

git diff --stat main..feature

The documentation for this endpoint states incorrectly that a three dot diff is returned when the topic query parameter is true or absent and we have notified the documentation team to update it.

For the difference between a two dot diff and a three dot diff, you can check the Git documentation here:

I hope this helps to clarify, please feel free to let me know if you have any other questions.

Kind regards,
Theodora

Paolo.Ascari
Contributor
May 30, 2023

Hi Theodora

Thank you so much for explaining everything in full detail.

I look forward to the introduction of the much anticipated API endpoint that shows conflicts, and then we will review our integration approach.

Cheers,

Paolo

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 30, 2023

Hi Paolo,

You are very welcome, please feel free to reach out if you ever need anything else!

Have a good day,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events