From d4cd4a96eae4a970c161c8b99c9f1cf9e02d9fbf Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 5 Dec 2017 19:53:05 +0100 Subject: Gracefully handle cloud authentication failure in verbose mode If the credential functions return GIT_EUSER, a call to git_remote_fetch fails, but giterr_last() may return NULL. This led to a crash in verbose mode. Signed-off-by: Berthold Stoeger --- core/git-access.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/git-access.c b/core/git-access.c index 40ee25600..db35a3083 100644 --- a/core/git-access.c +++ b/core/git-access.c @@ -607,7 +607,9 @@ int sync_with_remote(git_repository *repo, const char *remote, const char *branc else report_error("Unable to fetch remote '%s'", remote); if (verbose) - fprintf(stderr, "remote fetch failed (%s)\n", giterr_last()->message); + // If we returned GIT_EUSER during authentication, giterr_last() returns NULL + fprintf(stderr, "remote fetch failed (%s)\n", + giterr_last() ? giterr_last()->message : "authentication failed"); error = 0; } else { error = check_remote_status(repo, origin, remote, branch, rt); -- cgit v1.2.3-70-g09d2