Merge pull request #1717 from libgit2/arrbee/pr-1706-merged-and-cleaned PR 1706 plus error reporting cleanups