mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
1c42750cdf
commit
2878f32a22
1 changed files with 7 additions and 2 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue