From aade92f3feba199a9e997aaed8fbc8eb0b610b0a Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Mon, 22 Jul 2024 17:29:02 +0200 Subject: git_commit_map: avoid duplicate creation and fix usage ... as CheckCommitExists returns an optional bool, not a plain one. --- src/other_tools/root_maps/commit_git_map.cpp | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'src/other_tools/root_maps/commit_git_map.cpp') diff --git a/src/other_tools/root_maps/commit_git_map.cpp b/src/other_tools/root_maps/commit_git_map.cpp index 8efd628a..479068e2 100644 --- a/src/other_tools/root_maps/commit_git_map.cpp +++ b/src/other_tools/root_maps/commit_git_map.cpp @@ -622,19 +622,22 @@ void EnsureCommit(GitRepoInfo const& repo_info, auto old_repo = GitRepo::Open(old); auto no_logging = std::make_shared( [](auto /*unused*/, auto /*unused*/) {}); - if (old_repo and GitRepo::Open(old)->CheckCommitExists( - repo_info.hash, no_logging)) { - TakeCommitFromOlderGeneration(old, - storage_config, - repo_root, - repo_info, - git_cas, - critical_git_op_map, - progress, - ts, - ws_setter, - logger); - return; + if (old_repo) { + auto check_result = + old_repo->CheckCommitExists(repo_info.hash, no_logging); + if (check_result and *check_result) { + TakeCommitFromOlderGeneration(old, + storage_config, + repo_root, + repo_info, + git_cas, + critical_git_op_map, + progress, + ts, + ws_setter, + logger); + return; + } } } } -- cgit v1.2.3