Skip to main content

tree_entry_cmp

Function tree_entry_cmp 

Source
pub fn tree_entry_cmp(
    a_name: &[u8],
    a_is_tree: bool,
    b_name: &[u8],
    b_is_tree: bool,
) -> Ordering
Expand description

Git’s tree-entry sort comparator.

Trees are sorted byte-by-byte by "<name>" for blobs and "<name>/" for sub-trees, so a directory foo sorts after a file foo-bar but before fooz. This matches base_name_compare in tree.c.

§Parameters

  • a_name: name bytes of the first entry
  • a_is_tree: whether the first entry is a sub-tree (mode == 0o040000)
  • b_name: name bytes of the second entry
  • b_is_tree: whether the second entry is a sub-tree