summaryrefslogtreecommitdiffstats
path: root/core/git-access.c
diff options
context:
space:
mode:
authorGravatar Jan Mulder <jlmulder@xs4all.nl>2017-07-29 09:39:49 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-07-29 08:30:08 -0700
commite76f527fe53063663bdf1f71ca870e7009743f25 (patch)
treed56d334a022eb6e72e7412224f407d76ddb27e09 /core/git-access.c
parent61a35d0bd71b08bfcfedae1ded90ec4d47b82176 (diff)
downloadsubsurface-e76f527fe53063663bdf1f71ca870e7009743f25.tar.gz
Correctly create cloud account from mobile
The creation of a cloud account from mobile was broken. This fixes it. Basically, we need to go online for a moment, and setup a correct local and remote repo for the cloud storage. Tested for the following scenarios: 1) inital account creation including PIN handling from mobile, from a clean install . 2) open an already validated cloud account from a clean install. 3) open no-cloud style local account. 4) Switch between 2 already validated could accounts. 5) Try to create a cloud account without data connection. Notice that scenario 4) does not work perfectly. A restart of the app is needed to see the new logbook. So that is to be fixed. Scenario 5) seems a non realistic corner case. This does not work in a gracefull way. The user needs to remove the app, install it again, and retry with data connection. Further notice this is backgroud/core processing only. So no QML UI changes as proposed (for example) bij Davide. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Diffstat (limited to 'core/git-access.c')
-rw-r--r--core/git-access.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/core/git-access.c b/core/git-access.c
index fc2c1223a..05b3d02fd 100644
--- a/core/git-access.c
+++ b/core/git-access.c
@@ -736,7 +736,9 @@ static git_repository *create_local_repo(const char *localdir, const char *remot
if (verbose > 1)
fprintf(stderr, "git storage: returned from git_clone() with error %d\n", error);
if (error) {
- char *msg = giterr_last()->message;
+ char *msg = "";
+ if (giterr_last())
+ 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);
@@ -784,12 +786,23 @@ static struct git_repository *get_remote_repo(const char *localdir, const char *
return NULL;
}
return update_local_repo(localdir, remote, branch, rt);
+ } else {
+ /* we have no local cache yet */
+ if (is_subsurface_cloud) {
+ /* and take us temporarly online to create a local and
+ * remote cloud repo.
+ */
+ git_repository *ret;
+ bool glo = prefs.git_local_only;
+ prefs.git_local_only = false;
+ ret = create_local_repo(localdir, remote, branch, rt);
+ prefs.git_local_only = glo;
+ return ret;
+ }
}
- if (!prefs.git_local_only)
- return create_local_repo(localdir, remote, branch, rt);
- else
- return 0;
+ /* all normal cases are handled above */
+ return 0;
}
/*