diff options
Diffstat (limited to 'subsurface-core/file.c')
-rw-r--r-- | subsurface-core/file.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/subsurface-core/file.c b/subsurface-core/file.c index 62b38eddb..644956dbd 100644 --- a/subsurface-core/file.c +++ b/subsurface-core/file.c @@ -432,6 +432,33 @@ static int parse_file_buffer(const char *filename, struct memblock *mem) return parse_xml_buffer(filename, mem->buffer, mem->size, &dive_table, NULL); } +int check_git_sha(const char *filename) +{ + struct git_repository *git; + const char *branch = NULL; + + git = is_git_repository(filename, &branch, NULL, false); + if (prefs.cloud_git_url && + strstr(filename, prefs.cloud_git_url) + && git == dummy_git_repository) + /* opening the cloud storage repository failed for some reason, + * so we don't know if there is additional data in the remote */ + return 1; + + /* 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) && + !unsaved_changes()) { + fprintf(stderr, "already have loaded SHA %s - don't load again\n", sha); + return 0; + } + } + return 1; +} + int parse_file(const char *filename) { struct git_repository *git; |