mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
git storage: compare with correct SHA when checking if cache is current
Otherwise by the time we make the comparison the saved_git_id has already been updated. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
485c5a4ebd
commit
092d0478c3
1 changed files with 7 additions and 3 deletions
10
core/file.c
10
core/file.c
|
@ -440,24 +440,28 @@ int check_git_sha(const char *filename)
|
||||||
struct git_repository *git;
|
struct git_repository *git;
|
||||||
const char *branch = NULL;
|
const char *branch = NULL;
|
||||||
|
|
||||||
|
char *current_sha = strdup(saved_git_id);
|
||||||
git = is_git_repository(filename, &branch, NULL, false);
|
git = is_git_repository(filename, &branch, NULL, false);
|
||||||
if (prefs.cloud_git_url &&
|
if (prefs.cloud_git_url &&
|
||||||
strstr(filename, 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,
|
/* opening the cloud storage repository failed for some reason,
|
||||||
* so we don't know if there is additional data in the remote */
|
* so we don't know if there is additional data in the remote */
|
||||||
|
free(current_sha);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
/* if this is a git repository, 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 */
|
* get the SHA and compare with what we currently have */
|
||||||
if (git && git != dummy_git_repository) {
|
if (git && git != dummy_git_repository) {
|
||||||
const char *sha = get_sha(git, branch);
|
const char *sha = get_sha(git, branch);
|
||||||
if (!same_string(sha, "") &&
|
if (!same_string(sha, "") &&
|
||||||
same_string(sha, saved_git_id)) {
|
same_string(sha, current_sha)) {
|
||||||
fprintf(stderr, "already have loaded SHA %s - don't load again\n", sha);
|
fprintf(stderr, "already have loaded SHA %s - don't load again\n", sha);
|
||||||
|
free(current_sha);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(current_sha);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue