mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-28 15:34:22 +00:00
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:
parent
d6909002f0
commit
222709196a
1 changed files with 10 additions and 25 deletions
|
@ -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> {
|
||||
|
|
Loading…
Reference in a new issue