libgit2/libgit2 — pull request #2553 by carlosmn (2014-09-04 15:01:02+00:00)
Title: ssh: store error message immediately after a failed agent call

When the call to the agent fails, we must retrieve the error message
just after the function call, as other calls may overwrite it.

As the agent authentication is the only one which has a teardown and
there does not seem to be a way to get the error message from a stored
error number, this tries to introduce some small changes to store the
error from the agent.

Clearing the error at the beginning of the loop lets us know whether the
agent has already set the libgit2 error message and we should skip it,
or if we should set it.

This should fix #2547 though it's feels like a kludge. But it's probably not that bad, since the API we should have would have a lot more interaction with the user to let them choose which identity to use, so this needs to get replaced anyway.