summaryrefslogtreecommitdiffstats
path: root/core/git-access.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-04-30 12:40:52 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-04-30 12:40:52 -0700
commit241dd7cb81364521d78250f800e8508211575254 (patch)
tree1ea443fe4589f0f247db4304de38e857e18100f6 /core/git-access.c
parent2e6588dc0ef8d7698cc5dbe831f524a6e394145d (diff)
parentba9288fab6d7aa8527f7a75a717cdc88a68facd9 (diff)
downloadsubsurface-241dd7cb81364521d78250f800e8508211575254.tar.gz
Merge branch 'offlineDefault'
Diffstat (limited to 'core/git-access.c')
-rw-r--r--core/git-access.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/git-access.c b/core/git-access.c
index dba9cbec5..fe3a918ac 100644
--- a/core/git-access.c
+++ b/core/git-access.c
@@ -450,6 +450,11 @@ static int try_to_update(git_repository *repo, git_remote *origin, git_reference
return report_error("Unable to get local or remote SHA1");
}
if (git_merge_base(&base, repo, local_id, remote_id)) {
+ // TODO:
+ // if they have no merge base, they actually are different repos
+ // so instead merge this as merging a commit into a repo - git_merge() appears to do that
+ // but needs testing and cleanup afterwards
+ //
if (is_subsurface_cloud)
goto cloud_data_error;
else
@@ -940,3 +945,17 @@ struct git_repository *is_git_repository(const char *filename, const char **bran
*branchp = branch;
return repo;
}
+
+int git_create_local_repo(const char *filename)
+{
+ git_repository *repo;
+ char *path = strdup(filename);
+ char *branch = strchr(path, '[');
+ if (branch)
+ *branch = '\0';
+ int ret = git_repository_init(&repo, path, false);
+ free(path);
+ if (ret != 0)
+ (void)report_error("Create local repo failed with error code %d", ret);
+ return ret;
+}