core: turn saved_git_id into a std::string

Simplifies memory management. Think about unglobalizing this,
once everything is in C++ so that we can put an std::string
into struct divelog.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-02-28 08:49:42 +01:00
parent 45cb0c09fc
commit bf05dec52b
4 changed files with 15 additions and 14 deletions

View file

@ -266,20 +266,18 @@ static int parse_file_buffer(const char *filename, struct memblock *mem, struct
extern "C" bool remote_repo_uptodate(const char *filename, struct git_info *info)
{
char *current_sha = copy_string(saved_git_id);
std::string current_sha = saved_git_id;
if (is_git_repository(filename, info) && open_git_repository(info)) {
const char *sha = get_sha(info->repo, info->branch);
if (!empty_string(sha) && same_string(sha, current_sha)) {
if (!sha.empty() && current_sha == sha) {
fprintf(stderr, "already have loaded SHA %s - don't load again\n", sha);
free(current_sha);
return true;
}
}
// Either the repository couldn't be opened, or the SHA couldn't
// be found.
free(current_sha);
return false;
}