index: use segment_parent_file() instead of direct field access

This commit is contained in:
Yuya Nishihara 2023-12-11 20:33:41 +09:00
parent 402e36bab7
commit e5c8252fb4
2 changed files with 5 additions and 5 deletions

View file

@ -149,7 +149,7 @@ impl MutableIndexSegment {
let other_ancestor = maybe_other_ancestor.as_ref().unwrap();
if maybe_own_ancestor.is_none() {
files_to_add.push(other_ancestor.clone());
maybe_other_ancestor = other_ancestor.parent_file.clone();
maybe_other_ancestor = other_ancestor.segment_parent_file().cloned();
continue;
}
let own_ancestor = maybe_own_ancestor.as_ref().unwrap();
@ -160,9 +160,9 @@ impl MutableIndexSegment {
< other_ancestor.as_composite().num_commits()
{
files_to_add.push(other_ancestor.clone());
maybe_other_ancestor = other_ancestor.parent_file.clone();
maybe_other_ancestor = other_ancestor.segment_parent_file().cloned();
} else {
maybe_own_ancestor = own_ancestor.parent_file.clone();
maybe_own_ancestor = own_ancestor.segment_parent_file().cloned();
}
}
@ -254,7 +254,7 @@ impl MutableIndexSegment {
}
num_new_commits += parent_file.segment_num_commits();
files_to_squash.push(parent_file.clone());
maybe_parent_file = parent_file.parent_file.clone();
maybe_parent_file = parent_file.segment_parent_file().cloned();
}
None => {
squashed =

View file

@ -123,7 +123,7 @@ impl CommitLookupEntry<'_> {
// ids
// TODO: add a fanout table like git's commit graph has?
pub(super) struct ReadonlyIndexSegment {
pub(super) parent_file: Option<Arc<ReadonlyIndexSegment>>,
parent_file: Option<Arc<ReadonlyIndexSegment>>,
pub(super) num_parent_commits: u32,
pub(super) name: String,
pub(super) commit_id_length: usize,