aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-28 08:21:03 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-28 08:21:03 -0800
commitc7c9fb0bb0cb4a1fb0168f4dc5f7c20635672bff (patch)
tree71111019337fd9a5d97b29f90aa651a267a956f5
parent04054c04290d51c87cb4bcf6f0d17045e679c6a8 (diff)
downloadsubsurface-c7c9fb0bb0cb4a1fb0168f4dc5f7c20635672bff.tar.gz
Git storage: be more careful when checking if this SHA is already loaded
In commit 8c1cc4524d19 ("Don't reload identical data") I got a little carried away. Before comparing SHAs we need to make sure that a) this is a git repository at all b) we have an actual SHA before we claim to have the data loaded Reported-by: Paul-Erik Törrönen <poltsi@777-team.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--subsurface-core/file.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/subsurface-core/file.c b/subsurface-core/file.c
index 188a24100..62b38eddb 100644
--- a/subsurface-core/file.c
+++ b/subsurface-core/file.c
@@ -435,7 +435,7 @@ static int parse_file_buffer(const char *filename, struct memblock *mem)
int parse_file(const char *filename)
{
struct git_repository *git;
- const char *branch;
+ const char *branch = NULL;
struct memblock mem;
char *fmt;
int ret;
@@ -448,14 +448,17 @@ int parse_file(const char *filename)
* give up here and don't send errors about git repositories */
return 0;
- /* do we already have this exact state loaded ?
+ /* if this is a git repository, do we already have this exact state loaded ?
* get the SHA and compare with what we currently have */
- const char * sha = get_sha(git, branch);
- if (same_string(sha, saved_git_id) && !unsaved_changes()) {
- fprintf(stderr, "already have loaded SHA %s - don't load again\n", sha);
- return 0;
+ if (git && git != dummy_git_repository) {
+ const char *sha = get_sha(git, branch);
+ if (!same_string(sha, "") &&
+ same_string(sha, saved_git_id) &&
+ !unsaved_changes()) {
+ fprintf(stderr, "already have loaded SHA %s - don't load again\n", sha);
+ return 0;
+ }
}
-
if (git && !git_load_dives(git, branch))
return 0;