diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-10-26 18:37:15 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-10-26 20:44:02 +0200 |
commit | 1be44351757ba453675cee6bf318442dbf5e3803 (patch) | |
tree | a2fbfaf7517eebf8a49a18fe3ba32ba995c1395b /core | |
parent | bd54e94606293ba37c7e52f5dfe530e6750d0804 (diff) | |
download | subsurface-1be44351757ba453675cee6bf318442dbf5e3803.tar.gz |
git save: don't save the git_id if just creating empty repo
Otherwise the following call to do_git_save will potentially have incorrect information
about the cache validity of the dives in the divelist.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/save-git.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/core/save-git.c b/core/save-git.c index b77402657..436335a51 100644 --- a/core/save-git.c +++ b/core/save-git.c @@ -1099,7 +1099,7 @@ static void create_commit_message(struct membuffer *msg) put_format(msg, "Created by %s\n", subsurface_user_agent()); } -static int create_new_commit(git_repository *repo, const char *remote, const char *branch, git_oid *tree_id) +static int create_new_commit(git_repository *repo, const char *remote, const char *branch, git_oid *tree_id, bool create_empty) { int ret; git_reference *ref; @@ -1184,7 +1184,14 @@ static int create_new_commit(git_repository *repo, const char *remote, const cha if (git_reference_set_target(&ref, ref, &commit_id, "Subsurface save event")) return report_error("Failed to update branch '%s'", branch); - set_git_id(&commit_id); + + /* + * if this was the empty commit to initialize a new repo, don't remember the + * commit_id, otherwise we'll think that the cache is valid and fail when building + * the tree when we actually try to store the dive data + */ + if (! create_empty) + set_git_id(&commit_id); git_signature_free(author); @@ -1251,7 +1258,7 @@ int do_git_save(git_repository *repo, const char *branch, const char *remote, bo return report_error("git tree write failed"); /* And save the tree! */ - if (create_new_commit(repo, remote, branch, &id)) + if (create_new_commit(repo, remote, branch, &id, create_empty)) return report_error("creating commit failed"); if (remote && prefs.cloud_background_sync && !prefs.git_local_only) { |