summaryrefslogtreecommitdiffstats
path: root/subsurface-core/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'subsurface-core/file.c')
-rw-r--r--subsurface-core/file.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/subsurface-core/file.c b/subsurface-core/file.c
index 8286ce9f5..1337da3a2 100644
--- a/subsurface-core/file.c
+++ b/subsurface-core/file.c
@@ -57,7 +57,7 @@ int readfile(const char *filename, struct memblock *mem)
if (ret < 0)
goto free;
buf[ret] = 0;
- if (ret == mem->size)
+ if (ret == (int)mem->size) // converting to int loses a bit but size will never be that big
goto out;
errno = EIO;
ret = -1;
@@ -453,8 +453,7 @@ int check_git_sha(const char *filename)
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()) {
+ same_string(sha, saved_git_id)) {
fprintf(stderr, "already have loaded SHA %s - don't load again\n", sha);
return 0;
}
@@ -466,6 +465,7 @@ int parse_file(const char *filename)
{
struct git_repository *git;
const char *branch = NULL;
+ char *current_sha = copy_string(saved_git_id);
struct memblock mem;
char *fmt;
int ret;
@@ -473,22 +473,25 @@ int parse_file(const char *filename)
git = is_git_repository(filename, &branch, NULL, false);
if (prefs.cloud_git_url &&
strstr(filename, prefs.cloud_git_url)
- && git == dummy_git_repository)
+ && git == dummy_git_repository) {
/* opening the cloud storage repository failed for some reason
* give up here and don't send errors about git repositories */
+ free(current_sha);
return 0;
-
+ }
/* if this is a git repository, do we already have this exact state loaded ?
* get the SHA and compare with what we currently have */
if (git && git != dummy_git_repository) {
const char *sha = get_sha(git, branch);
if (!same_string(sha, "") &&
- same_string(sha, saved_git_id) &&
+ same_string(sha, current_sha) &&
!unsaved_changes()) {
fprintf(stderr, "already have loaded SHA %s - don't load again\n", sha);
+ free(current_sha);
return 0;
}
}
+ free(current_sha);
if (git)
return git_load_dives(git, branch);