Search code examples
libgit2

Is there any way to hook into the host name used by `git_remote_connect`?


Since libssh2 doesn't read the SSH config file I'm trying to implement my own support for aliases like this:

Host github
  HostName github.com

and the remote URL uses the host alias like this: git@github:path/to/repo.git.

Is there any way to hook into the host name or URL used by git_remote_connect or the SSH transport so that I can transform github into github.com? I was thinking about adding a new callback but I don't want to reinvent the wheel if there's already a way to do this.


Solution

  • I eventually added a new callback to look up the URL for a remote. It's not in upstream libgit2 but it probably could be if it's useful to anybody else.