diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-10-30 12:22:09 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-10-30 12:27:29 -0700 |
commit | 2878f32a224e02ed76cff6b799883f4e319f9e3a (patch) | |
tree | 3a71e5ad5be27509641b26c716f69ff1f9619479 /core/git-access.c | |
parent | 1c42750cdf08e425a9f9000a1784a868bf797ef8 (diff) | |
download | subsurface-2878f32a224e02ed76cff6b799883f4e319f9e3a.tar.gz |
Improve parsing of git error message
This is rather fragile code, and the capitalization of the error message
in libgit2 changed at some point. But commit 794739b4c0 ("strstr is a
case sensitive compare") didn't really fix the problem - as it broke
that same check for older libgit2 versions.
Instead use our new helper function to make it work with libgit2 old and
new.
Also, add some more error output so the next time we run into this it's
more obvious what broke and where.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/git-access.c')
-rw-r--r-- | core/git-access.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/core/git-access.c b/core/git-access.c index 05b3d02fd..1966ab61d 100644 --- a/core/git-access.c +++ b/core/git-access.c @@ -737,15 +737,20 @@ static git_repository *create_local_repo(const char *localdir, const char *remot fprintf(stderr, "git storage: returned from git_clone() with error %d\n", error); if (error) { char *msg = ""; - if (giterr_last()) + if (giterr_last()) { msg = giterr_last()->message; + fprintf(stderr, "error message was %s\n", msg); + } int len = sizeof("reference 'refs/remotes/origin/' not found") + strlen(branch); char *pattern = malloc(len); + // it seems that we sometimes get 'Reference' and sometimes 'reference' snprintf(pattern, len, "reference 'refs/remotes/origin/%s' not found", branch); - if (strstr(remote, prefs.cloud_git_url) && strstr(msg, pattern)) { + if (strstr(remote, prefs.cloud_git_url) && includes_string_caseinsensitive(msg, pattern)) { /* we're trying to open the remote branch that corresponds * to our cloud storage and the branch doesn't exist. * So we need to create the branch and push it to the remote */ + if (verbose) + fprintf(stderr, "remote repo didn't include our branch\n"); cloned_repo = create_and_push_remote(localdir, remote, branch); #if !defined(DEBUG) && !defined(SUBSURFACE_MOBILE) } else if (is_subsurface_cloud) { |