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 {