mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cloud storage: give user friendly error messages
Instead of showing the git URL and talking about failures to clone repositories, simply tell the user what's happening with the cloud storage. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
3ad517d87a
commit
abde615c1c
1 changed files with 13 additions and 1 deletions
14
git-access.c
14
git-access.c
|
@ -15,6 +15,7 @@
|
|||
#include "strndup.h"
|
||||
#include "qthelperfromc.h"
|
||||
#include "git-access.h"
|
||||
#include "gettext.h"
|
||||
|
||||
/*
|
||||
* The libgit2 people are incompetent at making libraries. They randomly change
|
||||
|
@ -293,7 +294,18 @@ static git_repository *create_local_repo(const char *localdir, const char *remot
|
|||
return 0;
|
||||
error = git_clone(&cloned_repo, remote, localdir, &opts);
|
||||
if (error) {
|
||||
report_error("git clone of %s failed (%s)", remote, giterr_last()->message);
|
||||
char *msg = giterr_last()->message;
|
||||
int len = sizeof("Reference 'refs/remotes/origin/' not found" + strlen(branch));
|
||||
char *pattern = malloc(len);
|
||||
snprintf(pattern, len, "Reference 'refs/remotes/origin/%s' not found", branch);
|
||||
if (strstr(remote, "https://cloud.subsurface-divelog.org/git") && strstr(msg, pattern)) {
|
||||
report_error(translate("gettextFromC", "Subsurface cloud storage is empty"));
|
||||
} else if (strstr(remote, "https://cloud.subsurface-divelog.org/git")) {
|
||||
report_error(translate("gettextFromC", "Error connecting to Subsurface cloud storage"));
|
||||
} else {
|
||||
report_error(translate("gettextFromC", "git clone of %s failed (%s)"), remote, msg);
|
||||
}
|
||||
free(pattern);
|
||||
return NULL;
|
||||
}
|
||||
return cloned_repo;
|
||||
|
|
Loading…
Add table
Reference in a new issue