From 16708110d85714d6ca02623be0cbc99f387e3b77 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 19 Aug 2024 12:50:42 +0200 Subject: GitOpParams: Remove unneeded branch field The 'branch' field is deprecated, not being used by any of the critical Git operations, thus it can be removed. --- src/other_tools/git_operations/git_ops_types.hpp | 6 +----- src/other_tools/ops_maps/content_cas_map.cpp | 1 - src/other_tools/ops_maps/critical_git_op_map.hpp | 3 +-- src/other_tools/ops_maps/git_tree_fetch_map.cpp | 5 ----- src/other_tools/ops_maps/import_to_git_map.cpp | 3 --- src/other_tools/root_maps/commit_git_map.cpp | 4 ---- src/other_tools/root_maps/content_git_map.cpp | 6 ------ src/other_tools/root_maps/distdir_git_map.cpp | 1 - src/other_tools/root_maps/fpath_git_map.cpp | 3 --- src/other_tools/root_maps/tree_id_git_map.cpp | 1 - test/other_tools/git_operations/critical_git_ops.test.cpp | 6 ------ 11 files changed, 2 insertions(+), 37 deletions(-) diff --git a/src/other_tools/git_operations/git_ops_types.hpp b/src/other_tools/git_operations/git_ops_types.hpp index 7c4b03a5..3dfdd4a8 100644 --- a/src/other_tools/git_operations/git_ops_types.hpp +++ b/src/other_tools/git_operations/git_ops_types.hpp @@ -27,27 +27,23 @@ struct GitOpParams { std::filesystem::path target_path{}; /*key*/ std::string git_hash{}; /*key*/ - std::string branch{}; /*key*/ std::optional message{ std::nullopt}; // useful for commits and tags std::optional init_bare{std::nullopt}; // useful for git init GitOpParams(std::filesystem::path const& target_path_, std::string git_hash_, - std::string branch_, std::optional message_ = std::nullopt, std::optional init_bare_ = std::nullopt) : target_path{std::filesystem::absolute(ToNormalPath(target_path_))}, git_hash{std::move(git_hash_)}, - branch{std::move(branch_)}, message{std::move(message_)}, init_bare{init_bare_} {}; [[nodiscard]] auto operator==(GitOpParams const& other) const noexcept -> bool { // not all fields are keys - return target_path == other.target_path and - git_hash == other.git_hash and branch == other.branch; + return target_path == other.target_path and git_hash == other.git_hash; } }; diff --git a/src/other_tools/ops_maps/content_cas_map.cpp b/src/other_tools/ops_maps/content_cas_map.cpp index eac0cf36..0c6ccd25 100644 --- a/src/other_tools/ops_maps/content_cas_map.cpp +++ b/src/other_tools/ops_maps/content_cas_map.cpp @@ -137,7 +137,6 @@ auto CreateContentCASMap( { storage_config->GitRoot(), // target_path "", // git_hash - "", // branch std::nullopt, // message true // init_bare }, diff --git a/src/other_tools/ops_maps/critical_git_op_map.hpp b/src/other_tools/ops_maps/critical_git_op_map.hpp index fa091655..8c75874c 100644 --- a/src/other_tools/ops_maps/critical_git_op_map.hpp +++ b/src/other_tools/ops_maps/critical_git_op_map.hpp @@ -34,7 +34,7 @@ using GitOpKeyMap = std::unordered_map< AsyncMapConsumerLoggerPtr const&)>>; struct GitOpKey { - GitOpParams params{"", "", ""}; /* key (with exceptions) */ + GitOpParams params{"", ""}; /* key (with exceptions) */ GitOpType op_type{GitOpType::DEFAULT_OP}; /* key */ [[nodiscard]] auto operation(GitOpParams const& params, @@ -96,7 +96,6 @@ struct hash { size_t seed{}; hash_combine(&seed, ct.target_path); hash_combine(&seed, ct.git_hash); - hash_combine(&seed, ct.branch); return seed; } }; diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.cpp b/src/other_tools/ops_maps/git_tree_fetch_map.cpp index 550dab7e..cceda079 100644 --- a/src/other_tools/ops_maps/git_tree_fetch_map.cpp +++ b/src/other_tools/ops_maps/git_tree_fetch_map.cpp @@ -133,7 +133,6 @@ void TagAndSetRoot(std::string tree_id, { repo, // target_path tree_id, // git_hash - "", // branch "Keep referenced tree alive" // message }, .op_type = GitOpType::KEEP_TREE}; @@ -180,7 +179,6 @@ void TakeTreeFromOlderGeneration( { source, // target_path tree_id, // git_hash - "", // branch "Tag commit for fetching" // message }, .op_type = GitOpType::KEEP_TREE}; @@ -273,7 +271,6 @@ auto CreateGitTreeFetchMap( { storage_config->GitRoot(), // target_path "", // git_hash - "", // branch std::nullopt, // message true // init_bare }, @@ -458,7 +455,6 @@ auto CreateGitTreeFetchMap( { tmp_dir->GetPath(), // target_path "", // git_hash - "", // branch fmt::format("Content of tree {}", key.hash), // message }, @@ -604,7 +600,6 @@ auto CreateGitTreeFetchMap( { storage_config->GitRoot(), // target_path *op_result.result, // git_hash - "", // branch "Keep referenced tree alive" // message }, .op_type = GitOpType::KEEP_TAG}; diff --git a/src/other_tools/ops_maps/import_to_git_map.cpp b/src/other_tools/ops_maps/import_to_git_map.cpp index ddbfa115..7e9331b0 100644 --- a/src/other_tools/ops_maps/import_to_git_map.cpp +++ b/src/other_tools/ops_maps/import_to_git_map.cpp @@ -36,7 +36,6 @@ void KeepCommitAndSetTree( { storage_config.GitRoot(), // target_path commit, // git_hash - "", // branch "Keep referenced tree alive" // message }, .op_type = GitOpType::KEEP_TAG}; @@ -107,7 +106,6 @@ auto CreateImportToGitMap( { key.target_path, // target_path "", // git_hash - "", // branch fmt::format("Content of {} {}", key.repo_type, key.content), // message @@ -138,7 +136,6 @@ auto CreateImportToGitMap( { storage_config->GitRoot(), // target_path "", // git_hash - "", // branch std::nullopt, // message true // init_bare }, diff --git a/src/other_tools/root_maps/commit_git_map.cpp b/src/other_tools/root_maps/commit_git_map.cpp index 9f6943c8..873f7484 100644 --- a/src/other_tools/root_maps/commit_git_map.cpp +++ b/src/other_tools/root_maps/commit_git_map.cpp @@ -201,7 +201,6 @@ void TagAndSetRoot(std::filesystem::path const& repo_root, { repo_root, // target_path repo_info.hash, // git_hash - "", // branch "Keep referenced tree alive" // message }, .op_type = GitOpType::KEEP_TAG}; @@ -281,7 +280,6 @@ void TakeCommitFromOlderGeneration( { source, // target_path repo_info.hash, // git_hash - "", // branch "Tag commit for fetching" // message }, .op_type = GitOpType::KEEP_TAG}; @@ -692,7 +690,6 @@ void EnsureCommit(GitRepoInfo const& repo_info, { storage_config->GitRoot(), // target_path "", // git_hash - "", // branch std::nullopt, // message true // init_bare }, @@ -1104,7 +1101,6 @@ auto CreateCommitGitMap( { repo_root, // target_path "", // git_hash - "", // branch std::nullopt, // message not just_mr_paths->git_checkout_locations.contains( fetch_repo) // init_bare diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp index 652f4a25..38aa21a6 100644 --- a/src/other_tools/root_maps/content_git_map.cpp +++ b/src/other_tools/root_maps/content_git_map.cpp @@ -260,7 +260,6 @@ void ResolveContentTree( { storage_config->GitRoot(), // target_path resolved_tree_id, // git_hash - "", // branch "Keep referenced tree alive" // message }, .op_type = GitOpType::KEEP_TREE}; @@ -546,7 +545,6 @@ void HandleLocallyKnownTree( { storage_config->GitRoot(), // target_path "", // git_hash - "", // branch std::nullopt, // message true // init_bare }, @@ -694,7 +692,6 @@ void HandleKnownInOlderGenerationAfterTaggingAndInit( { storage_config->GitRoot(), // target_path tree_id, // git_hash - "", // branch "Keep referenced tree alive" // message }, .op_type = GitOpType::KEEP_TREE}; @@ -760,7 +757,6 @@ void HandleKnownInOlderGenerationAfterTagging( { storage_config->GitRoot(), // target_path "", // git_hash - "", // branch std::nullopt, // message true // init_bare }, @@ -843,7 +839,6 @@ void HandleKnownInOlderGeneration( { source, // target_path *archive_tree_id, // git_hash - "", // branch "Tag commit for fetching" // message }, .op_type = GitOpType::KEEP_TREE}; @@ -1023,7 +1018,6 @@ auto CreateContentGitMap( { storage_config->GitRoot(), // target_path "", // git_hash - "", // branch std::nullopt, // message true // init_bare }, diff --git a/src/other_tools/root_maps/distdir_git_map.cpp b/src/other_tools/root_maps/distdir_git_map.cpp index 9171daae..2d2ad107 100644 --- a/src/other_tools/root_maps/distdir_git_map.cpp +++ b/src/other_tools/root_maps/distdir_git_map.cpp @@ -172,7 +172,6 @@ auto CreateDistdirGitMap( { storage_config->GitRoot(), // target_path "", // git_hash - "", // branch std::nullopt, // message true // init_bare }, diff --git a/src/other_tools/root_maps/fpath_git_map.cpp b/src/other_tools/root_maps/fpath_git_map.cpp index 2de194d9..d4a46486 100644 --- a/src/other_tools/root_maps/fpath_git_map.cpp +++ b/src/other_tools/root_maps/fpath_git_map.cpp @@ -177,7 +177,6 @@ void ResolveFilePathTree( { storage_config->GitRoot(), // target_path resolved_tree_id, // git_hash - "", // branch "Keep referenced tree alive" // message }, .op_type = GitOpType::KEEP_TREE}; @@ -294,7 +293,6 @@ auto CreateFilePathGitMap( { *repo_root, // target_path "", // git_hash - "", // branch }, .op_type = GitOpType::GET_HEAD_ID}; critical_git_op_map->ConsumeAfterKeysReady( @@ -351,7 +349,6 @@ auto CreateFilePathGitMap( { storage_config->GitRoot(), // target_path "", // git_hash - "", // branch std::nullopt, // message true // init_bare }, diff --git a/src/other_tools/root_maps/tree_id_git_map.cpp b/src/other_tools/root_maps/tree_id_git_map.cpp index ad06b34d..3a33d11b 100644 --- a/src/other_tools/root_maps/tree_id_git_map.cpp +++ b/src/other_tools/root_maps/tree_id_git_map.cpp @@ -234,7 +234,6 @@ auto CreateTreeIdGitMap( { storage_config->GitRoot(), // target_path "", // git_hash - "", // branch std::nullopt, // message true // init_bare }, diff --git a/test/other_tools/git_operations/critical_git_ops.test.cpp b/test/other_tools/git_operations/critical_git_ops.test.cpp index 36a95af4..ac1f371c 100644 --- a/test/other_tools/git_operations/critical_git_ops.test.cpp +++ b/test/other_tools/git_operations/critical_git_ops.test.cpp @@ -173,7 +173,6 @@ TEST_CASE("Critical git operations", "[critical_git_op_map]") { { path_init_commit, // target_path "", // git_hash - "", // branch "Init commit" // message }, .op_type = GitOpType::INITIAL_COMMIT}, @@ -181,7 +180,6 @@ TEST_CASE("Critical git operations", "[critical_git_op_map]") { { path_init_bare, // target_path "", // git_hash - "", // branch std::nullopt, // message true // init_bare }, @@ -190,7 +188,6 @@ TEST_CASE("Critical git operations", "[critical_git_op_map]") { { path_init_non_bare, // target_path "", // git_hash - "", // branch std::nullopt, // message false // init_bare }, @@ -199,7 +196,6 @@ TEST_CASE("Critical git operations", "[critical_git_op_map]") { { *path_keep_tag, // target_path kRootCommit, // git_hash - "", // branch "keep-commit" // message }, .op_type = GitOpType::KEEP_TAG}, @@ -207,14 +203,12 @@ TEST_CASE("Critical git operations", "[critical_git_op_map]") { { *path_get_head_id, // target_path "", // git_hash - "", // branch }, .op_type = GitOpType::GET_HEAD_ID}, GitOpKey{.params = { *path_keep_tree, // target_path kBazSymId, // git_hash - "", // branch "keep-tree" // message }, .op_type = GitOpType::KEEP_TREE}}, -- cgit v1.2.3