do not enter '.git' by default in tree mode

This commit is contained in:
root committed 2026-10-18 21:44:04 +02:00
1 parent e5746c38bb
commit 4d21f9e67d
3 files changed
+20 -2

No files matched your search

+2 -1
View File
@@ -36,13 +36,14 @@ typedef struct {
bool show_all; bool show_all;
bool show_almost_all; bool show_almost_all;
bool case_sensitive_sorting; bool case_sensitive_sorting;
size_t depth;
bool no_colour; bool no_colour;
bool group_directories; bool group_directories;
bool display_help; bool display_help;
bool long_view; bool long_view;
bool reverse_order; bool reverse_order;
bool tree_view; bool tree_view;
bool show_git_dir;
size_t depth;
permission_mode_t permission_mode; permission_mode_t permission_mode;
sorting_mode_t sorting_mode; sorting_mode_t sorting_mode;
time_mode_t time_mode; time_mode_t time_mode;
+13
View File
@@ -14,6 +14,7 @@
#define KEY_CASE_SENSITIVE ( ( int )'c' ) #define KEY_CASE_SENSITIVE ( ( int )'c' )
#define KEY_DEPTH ( ( int )'d' ) #define KEY_DEPTH ( ( int )'d' )
#define KEY_GROUP_DIRECTORIES ( ( int )'g' ) #define KEY_GROUP_DIRECTORIES ( ( int )'g' )
#define KEY_SHOW_GIT_DIR ( ( int )'G' )
#define KEY_HELP ( ( int )'h' ) #define KEY_HELP ( ( int )'h' )
#define KEY_LONG_VIEW ( ( int )'l' ) #define KEY_LONG_VIEW ( ( int )'l' )
#define KEY_PERMISSIONS ( ( int )'p' ) #define KEY_PERMISSIONS ( ( int )'p' )
@@ -87,6 +88,14 @@ static struct argp_option options[] =
.doc = "group directories at the top", .doc = "group directories at the top",
.group = 0 .group = 0
}, },
{
.name = "show-git-directory",
.key = KEY_SHOW_GIT_DIR,
.arg = NULL,
.flags = 0,
.doc = "do not ignore '.git' directory",
.group = 0
},
{ {
.name = "help", .name = "help",
.key = KEY_HELP, .key = KEY_HELP,
@@ -175,6 +184,7 @@ void initialise_args( arguments_t* arguments )
arguments->depth = MAX_TREE_DEPTH; arguments->depth = MAX_TREE_DEPTH;
arguments->no_colour = false; arguments->no_colour = false;
arguments->group_directories = false; arguments->group_directories = false;
arguments->show_git_dir = false;
arguments->display_help = false; arguments->display_help = false;
arguments->long_view = false; arguments->long_view = false;
arguments->reverse_order = false; arguments->reverse_order = false;
@@ -237,6 +247,9 @@ static error_t arg_parser( int key, char* arg, struct argp_state* state )
case KEY_GROUP_DIRECTORIES: case KEY_GROUP_DIRECTORIES:
arguments->group_directories = true; arguments->group_directories = true;
break; break;
case KEY_SHOW_GIT_DIR:
arguments->show_git_dir = true;
break;
case KEY_HELP: case KEY_HELP:
arguments->display_help = true; arguments->display_help = true;
break; break;
+5 -1
View File
@@ -310,9 +310,13 @@ int handle_directory(
display_entry( entry, args ); display_entry( entry, args );
bool enter_git_dir = args->show_git_dir || strncmp( ".git", entry->name, 5 );
if ( args->tree_view if ( args->tree_view
&& recursion_level < args->depth && recursion_level < args->depth
&& entry->type == type_directory ) && entry->type == type_directory
&& enter_git_dir
)
{ {
DIR* subdirectory = opendir(entry->name); DIR* subdirectory = opendir(entry->name);
if ( !subdirectory ) if ( !subdirectory )