mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
git access: rename 'check_git_sha()' function
That function name was incomprehensible. What did it check? And what did the return value mean? So let's rename it to something that actually describes what it does, and reverse the meaning of the return value while at it. So now it's called 'remote_repo_uptodate()', and it returns true if the remote repository branch has the same value as our 'saved_git_id'. It's still a bit obscure, but at least within the context of the only user, the code now makes _more_ sense than it used to: if (remote_repo_uptodate(fileNamePrt.data(), &info)) { appendTextToLog("Cloud sync shows local cache was current"); but maybe we could come up with even better semantics and naming, and make it even clearer. Requested-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
6f5783b203
commit
96337dbbcf
3 changed files with 5 additions and 5 deletions
|
@ -273,7 +273,7 @@ static int parse_file_buffer(const char *filename, struct memblock *mem, struct
|
||||||
return parse_xml_buffer(filename, mem->buffer, mem->size, table, trips, sites, devices, filter_presets, NULL);
|
return parse_xml_buffer(filename, mem->buffer, mem->size, table, trips, sites, devices, filter_presets, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_git_sha(const char *filename, struct git_info *info)
|
bool remote_repo_uptodate(const char *filename, struct git_info *info)
|
||||||
{
|
{
|
||||||
char *current_sha = copy_string(saved_git_id);
|
char *current_sha = copy_string(saved_git_id);
|
||||||
|
|
||||||
|
@ -282,14 +282,14 @@ bool check_git_sha(const char *filename, struct git_info *info)
|
||||||
if (!empty_string(sha) && same_string(sha, current_sha)) {
|
if (!empty_string(sha) && 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);
|
free(current_sha);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Either the repository couldn't be opened, or the SHA couldn't
|
// Either the repository couldn't be opened, or the SHA couldn't
|
||||||
// be found.
|
// be found.
|
||||||
free(current_sha);
|
free(current_sha);
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parse_file(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites,
|
int parse_file(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites,
|
||||||
|
|
|
@ -40,7 +40,7 @@ struct git_info {
|
||||||
|
|
||||||
extern bool is_git_repository(const char *filename, struct git_info *info);
|
extern bool is_git_repository(const char *filename, struct git_info *info);
|
||||||
extern bool open_git_repository(struct git_info *info);
|
extern bool open_git_repository(struct git_info *info);
|
||||||
extern bool check_git_sha(const char *filename, struct git_info *info);
|
extern bool remote_repo_uptodate(const char *filename, struct git_info *info);
|
||||||
extern int sync_with_remote(struct git_info *);
|
extern int sync_with_remote(struct git_info *);
|
||||||
extern int git_save_dives(struct git_info *, bool select_only);
|
extern int git_save_dives(struct git_info *, bool select_only);
|
||||||
extern int git_load_dives(struct git_info *, struct dive_table *table, struct trip_table *trips,
|
extern int git_load_dives(struct git_info *, struct dive_table *table, struct trip_table *trips,
|
||||||
|
|
|
@ -737,7 +737,7 @@ void QMLManager::loadDivesWithValidCredentials()
|
||||||
struct git_info info;
|
struct git_info info;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (check_git_sha(fileNamePrt.data(), &info) == 0) {
|
if (remote_repo_uptodate(fileNamePrt.data(), &info)) {
|
||||||
appendTextToLog("Cloud sync shows local cache was current");
|
appendTextToLog("Cloud sync shows local cache was current");
|
||||||
} else {
|
} else {
|
||||||
appendTextToLog("Cloud sync brought newer data, reloading the dive list");
|
appendTextToLog("Cloud sync brought newer data, reloading the dive list");
|
||||||
|
|
Loading…
Reference in a new issue