libgit2/libgit2 — pull request #1972 by ghedo (2013-11-19 19:52:38+00:00)
Title: ssh: add support for ssh-agent authentication

As per title. This works by calling `git_cred_ssh_key_new` with a NULL privatekey (the other parameters are ignored, except for username). An alternative implementation would be to add a new cred type (e.g. `GIT_CREDTYPE_SSH_AGENT`) and relative `git_cred_ssh_agent_new()`, but the other one seemed less intrusive. Though if you like this better (or have an even better idea) just tell me.

As for the error messages, apparently `libssh2_agent_free` sets its own messages and that's what the `ssh_error` call gets (after the loop in `_git_ssh_authenticate_session`) which means that whenever there is an agent error, what libgit2 sets as message is something like "Failed to authenticate SSH session: failed closing the agent socket" which isn't extremely helpful. The alternative would be to call `ssh_error` directly inside `ssh_agent_auth` and check `rc` immediately after the `ssh_agent_auth` call inside the switch in `_git_ssh_authenticate_session`. This is rather ugly, so I left it as-is for now.