@@ -289,8 +289,6 @@ pub fn visualize_tree(tree_id: gix::Id<'_>) -> termtree::Tree<String> {
289289 visualize_tree ( tree_id. object ( ) . unwrap ( ) . peel_to_tree ( ) . unwrap ( ) . id ( ) , None ) . unwrap ( )
290290}
291291
292- const FILETYPE_MASK : u32 = 0o170000 ;
293-
294292/// Visualize a tree on disk with mode information.
295293/// For convenience, skip `.git` and don't display the root.
296294///
@@ -306,20 +304,11 @@ const FILETYPE_MASK: u32 = 0o170000;
306304pub fn visualize_disk_tree_skip_dot_git ( root : & Path ) -> anyhow:: Result < termtree:: Tree < String > > {
307305 use std:: os:: unix:: fs:: MetadataExt ;
308306 fn normalize_mode ( mode : u32 ) -> u32 {
309- let normalize_permission_bits = |mode : u32 | if mode & 0o100 == 0 { 0o644 } else { 0o755 } ;
310-
311- match mode & FILETYPE_MASK {
312- // File types Git cares about
313- directory @ 0o40000 => directory | normalize_permission_bits ( mode) ,
314- symlink @ 0o120000 => symlink | normalize_permission_bits ( mode) ,
315- regular_file @ 0o100000 => regular_file | normalize_permission_bits ( mode) ,
316-
317- // File types Git does not care about. These may still appear in the worktree.
318- // Note: Add more file types here if needed (e.g. socket, block device, etc)
319- fifo @ 0o10000 => fifo | normalize_permission_bits ( mode) ,
320-
321- _ => panic ! ( "Unhandled file mode {mode}" ) ,
322- }
307+ let filetype_bits = 0o170000 & mode;
308+ // Git only cares about the permission bits for regular files, but we normalize everything the same way for the
309+ // sake of simplicity.
310+ let normalized_permission_bits = if mode & 0o100 == 0 { 0o644 } else { 0o755 } ;
311+ filetype_bits | normalized_permission_bits
323312 }
324313
325314 fn label ( p : & Path , md : & std:: fs:: Metadata ) -> String {
0 commit comments