Skip to content

Commit ea169a6

Browse files
committed
Fix tree-entry-ordering implementation (#293)
As it was missing the final length test as seen here: https://github.com/git/git/blob/main/read-cache.c#L531:L531
1 parent 28c056c commit ea169a6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: git-object/src/tree/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ impl PartialOrd for Entry {
9090
impl Ord for Entry {
9191
/// Entries compare by the common portion of the filename. This is critical for proper functioning of algorithms working on trees.
9292
fn cmp(&self, other: &Self) -> Ordering {
93-
let len = self.filename.len().min(other.filename.len());
94-
self.filename[..len].cmp(&other.filename[..len])
93+
let common_len = self.filename.len().min(other.filename.len());
94+
self.filename[..common_len]
95+
.cmp(&other.filename[..common_len])
96+
.then_with(|| self.filename.len().cmp(&other.filename.len()))
9597
}
9698
}
9799

0 commit comments

Comments
 (0)