repo: remove code for conflict between root commit/change id

The two ids no longer share a prefix, so we don't need to worry about
one being a prefix of the other.
This commit is contained in:
Martin von Zweigbergk 2023-02-12 20:56:50 -08:00 committed by Martin von Zweigbergk
parent d6909002f0
commit 222709196a

View file

@ -293,31 +293,16 @@ impl ReadonlyRepo {
}
pub fn shortest_unique_id_prefix_len(&self, target_id_bytes: &[u8]) -> usize {
let root_commit_id = self.store().root_commit_id();
let root_change_id = self.store().root_change_id();
if target_id_bytes == root_commit_id.as_bytes()
|| target_id_bytes == root_change_id.as_bytes()
{
// The root change/commit ids share the same prefix, and they are found in both
// indices with different lengths. So we have to feed bytes of valid lengths.
cmp::max(
self.index()
.shortest_unique_commit_id_prefix_len(root_commit_id),
self.change_id_index()
.shortest_unique_prefix_len(root_change_id),
)
} else {
// For `len = index.shortest(id)`, a prefix of length `len` will disambiguate
// `id` from all other ids in the index. This will be just as true for
// `max(len, anything_else)`, so a max of such lengths will disambiguate in all
// indices.
cmp::max(
self.index()
.shortest_unique_commit_id_prefix_len(&CommitId::from_bytes(target_id_bytes)),
self.change_id_index()
.shortest_unique_prefix_len(&ChangeId::from_bytes(target_id_bytes)),
)
}
// For `len = index.shortest(id)`, a prefix of length `len` will disambiguate
// `id` from all other ids in the index. This will be just as true for
// `max(len, anything_else)`, so a max of such lengths will disambiguate in all
// indices.
cmp::max(
self.index()
.shortest_unique_commit_id_prefix_len(&CommitId::from_bytes(target_id_bytes)),
self.change_id_index()
.shortest_unique_prefix_len(&ChangeId::from_bytes(target_id_bytes)),
)
}
pub fn store(&self) -> &Arc<Store> {