mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cloud storage: make do_git_save available to other modules
And add a parameter that tells it whether to try to save any Subsurface data or whether to just create a branch and push it out. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f6981f0210
commit
ef85875cd0
2 changed files with 7 additions and 5 deletions
|
@ -18,6 +18,7 @@ extern struct git_repository *is_git_repository(const char *filename, const char
|
|||
extern int sync_with_remote(struct git_repository *repo, const char *remote, const char *branch, enum remote_transport rt);
|
||||
extern int git_save_dives(struct git_repository *, const char *, const char *remote, bool select_only);
|
||||
extern int git_load_dives(struct git_repository *, const char *);
|
||||
extern int do_git_save(git_repository *repo, const char *branch, const char *remote, bool select_only, bool create_empty);
|
||||
extern const char *saved_git_id;
|
||||
extern void clear_git_id(void);
|
||||
extern void set_git_id(const struct git_oid *);
|
||||
|
|
11
save-git.c
11
save-git.c
|
@ -1116,7 +1116,7 @@ static int write_git_tree(git_repository *repo, struct dir *tree, git_oid *resul
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int do_git_save(git_repository *repo, const char *branch, const char *remote, bool select_only)
|
||||
int do_git_save(git_repository *repo, const char *branch, const char *remote, bool select_only, bool create_empty)
|
||||
{
|
||||
struct dir tree;
|
||||
git_oid id;
|
||||
|
@ -1127,9 +1127,10 @@ static int do_git_save(git_repository *repo, const char *branch, const char *rem
|
|||
if (git_treebuilder_new(&tree.files, repo, NULL))
|
||||
return report_error("git treebuilder failed");
|
||||
|
||||
/* Populate our tree data structure */
|
||||
if (create_git_tree(repo, &tree, select_only))
|
||||
return -1;
|
||||
if (!create_empty)
|
||||
/* Populate our tree data structure */
|
||||
if (create_git_tree(repo, &tree, select_only))
|
||||
return -1;
|
||||
|
||||
if (write_git_tree(repo, &tree, &id))
|
||||
return report_error("git tree write failed");
|
||||
|
@ -1152,7 +1153,7 @@ int git_save_dives(struct git_repository *repo, const char *branch, const char *
|
|||
|
||||
if (repo == dummy_git_repository)
|
||||
return report_error("Unable to open git repository '%s'", branch);
|
||||
ret = do_git_save(repo, branch, remote, select_only);
|
||||
ret = do_git_save(repo, branch, remote, select_only, false);
|
||||
git_repository_free(repo);
|
||||
free((void *)branch);
|
||||
return ret;
|
||||
|
|
Loading…
Add table
Reference in a new issue