From 222709196ac9003db7ee63b61820f4b33ea49070 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 12 Feb 2023 20:56:50 -0800 Subject: [PATCH] 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. --- lib/src/repo.rs | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/lib/src/repo.rs b/lib/src/repo.rs index ad555b4f5..43d395d4c 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -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 {