Missing file url upon calling the diffstat endpoint
Asked by Paolo.Ascari:

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.


Answers:
author: Theodora Boudale
body: 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](https://community.atlassian.com/t5/Bitbucket-questions/Bitbucket-Cloud-Check-if-a-pull-request-has-conflicts/qaq-p/2361098) 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

comments: author: Theodora Boudale
body: 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:

* <https://bitbucket.org/blog/improving-performance-on-complex-diffs>

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).

<br />

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:

* <https://git-scm.com/docs/git-diff>

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

Kind regards,  
Theodora


author: Paolo.Ascari
body: 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


author: Theodora Boudale
body: Hi Paolo,

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

Have a good day,  
Theodora


Tags: api

bitbucket-cloud

cloud