mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
git storage: init local repository
So far we didn't do that at all, we either relied on the user manually creating a local repo, or we cloned a remote repo. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d6b36c47cb
commit
9ba090c31f
2 changed files with 15 additions and 0 deletions
|
@ -429,6 +429,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
|
||||
|
@ -919,3 +924,12 @@ 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;
|
||||
int ret = git_repository_init(&repo, filename, false);
|
||||
if (ret != 0)
|
||||
(void)report_error("Create local repo failed with error code %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ extern void set_git_id(const struct git_oid *);
|
|||
void set_git_update_cb(int(*)(bool, const char *));
|
||||
int git_storage_update_progress(bool reset, const char *text);
|
||||
char *get_local_dir(const char *remote, const char *branch);
|
||||
int git_create_local_repo(const char *filename);
|
||||
|
||||
extern int last_git_storage_update_val;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue