Add an equivalent of `git remote set-head`.
When cloning a repository, both git and libgit2 create a remotes/origin/HEAD symbolic ref which point to the remote's default ref. In libgit2, this is implemented in https://github.com/libgit2/libgit2/blob/503b66cf00ad7dca940148529f60b1a409ccc462/src/libgit2/clone.c#L166.
However, if instead of cloning a repository one adds a remote using git remote add followed by git fetch, then the remotes/origin/HEAD symbolic ref is never created.
With git, the git remote set-head --auto command can be used to address this. It performs the same job as would have been done implicitly by git clone. There is, as far as I am aware, no equivalent public API in libgit2. While it is probably possible to implement this outside of libgit2, given that the implementation is already there in clone.c, it seems like a shame not to expose it.
The API could look something like:
int git_remote_set_head(git_repository *repo, const char *remote, const char *branch); If NULL, the branch could be determined using git_remote_default_branch (this is the equivalent of the CLI's --auto flag).
Source: libgit2/libgit2