How to update a file with API using SHA


Looking at the docs here:

I was surprised to see unlike GitHub and Bitbucket you can update a file without passing a SHA (in fact it does not accept a SHA). This means we can’t safely fetch file contents, make edits, and then update the file. If an update has happened in the mean time the SHA protects us from accidentally overwriting work.

Is there a more sophisticated API to use which doesn’t involve an entire git checkout? It’s a shame because that endpoint is surely easier than alternatives.


Nevermind I realised that’s what last_commit_id is for, though it would be nice if this endpoint returned the updated SHA so another request wasn’t necessary, and 409 status code on conflict rather than generic 400