From e63a782a71a0edbe67b035b03d41043009774643 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Thu, 16 May 2024 15:02:05 +0200 Subject: FileRoot: Fix parsing of ignore-special Git tree roots When populating the GitTree instance stored in a Git tree-type FileRoot with the ignore-special flag set, the GitTree instance would be created with an empty raw_id_ field, signaling that some of the entries might have been skipped and thus the root tree id is not anymore in a one-to-one correspondence with the stored list of entries. This however caused FileRoot instances with missing tree id information. This commit fixes the issue by always storing the raw_id_ field as the root id of the Git tree, as well as clarifying the relationship between this field and the ignore_special_ flag, including refactoring the tree id getters. (cherry picked from 06336198a38ffaec6c35df34580391579a7a7b22) --- src/buildtool/file_system/git_tree.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/buildtool/file_system/git_tree.cpp') diff --git a/src/buildtool/file_system/git_tree.cpp b/src/buildtool/file_system/git_tree.cpp index a5a3262d..e7a2f41d 100644 --- a/src/buildtool/file_system/git_tree.cpp +++ b/src/buildtool/file_system/git_tree.cpp @@ -88,12 +88,10 @@ auto GitTree::Read(gsl::not_null const& cas, check_symlinks, /*is_hex_id=*/false, ignore_special)) { - // the raw_id value is NOT recomputed when ignore_special==true, - // so we set it to empty to signal that it should not be used! - return GitTree::FromEntries(cas, - std::move(*entries), - ignore_special ? "" : *raw_id, - ignore_special); + // NOTE: the raw_id value is NOT recomputed when + // ignore_special==true. + return GitTree::FromEntries( + cas, std::move(*entries), *raw_id, ignore_special); } } else { @@ -164,7 +162,6 @@ auto GitTreeEntry::Tree(bool ignore_special) const& noexcept check_symlinks, /*is_hex_id=*/false, ignore_special)) { - // the raw_id value is not used when ignore_special==true return GitTree::FromEntries( cas_, std::move(*entries), raw_id_, ignore_special); } -- cgit v1.2.3