@dvzrv's approach is good. I added the necessary `ifdef`s in #1165.
However, as said in the PR, in the long term more code refactoring will be necessary as the whole `git_buf` object is now meant to be readonly and we use APIs to modify it but those APIs are already deprecated.