@@ -71,7 +71,7 @@ enum class output_format
7171 SHORT = 2
7272};
7373
74- void print_entries (git_status_t status, status_list_wrapper& sl, bool head_selector, output_format of) // TODO: add different mods
74+ void print_entries (git_status_t status, status_list_wrapper& sl, bool head_selector, output_format of, bool add_root ) // TODO: add different mods
7575{
7676 const auto & entry_list = sl.get_entry_list (status);
7777 if (!entry_list.empty ())
@@ -98,6 +98,16 @@ void print_entries(git_status_t status, status_list_wrapper& sl, bool head_selec
9898 }
9999 const char * old_path = diff_delta->old_file .path ;
100100 const char * new_path = diff_delta->new_file .path ;
101+ if (add_root)
102+ {
103+ const size_t first_slash_idx = std::string_view (old_path).find (' /' );
104+ const char * directory;
105+ if (std::string::npos != first_slash_idx)
106+ {
107+ directory = std::string_view (old_path).substr (0 , first_slash_idx).c_str ();
108+ sl.dir_set .insert (directory);
109+ }
110+ }
101111 if (old_path && new_path && std::strcmp (old_path, new_path))
102112 {
103113 std::cout << old_path << " -> " << new_path << std::endl;
@@ -127,8 +137,6 @@ void status_subcommand::run()
127137 auto sl = status_list_wrapper::status_list (repo);
128138 auto branch_name = reference_wrapper::get_ref_name (repo);
129139
130- // TODO: add branch info
131-
132140 output_format of = output_format::DEFAULT;
133141 if (short_flag)
134142 {
@@ -162,11 +170,11 @@ void status_subcommand::run()
162170 {
163171 std::cout << tobecommited_header << std::endl;
164172 }
165- print_entries (GIT_STATUS_INDEX_NEW, sl, true , of);
166- print_entries (GIT_STATUS_INDEX_MODIFIED, sl, true , of);
167- print_entries (GIT_STATUS_INDEX_DELETED, sl, true , of);
168- print_entries (GIT_STATUS_INDEX_RENAMED, sl, true , of);
169- print_entries (GIT_STATUS_INDEX_TYPECHANGE, sl, true , of);
173+ print_entries (GIT_STATUS_INDEX_NEW, sl, true , of, true );
174+ print_entries (GIT_STATUS_INDEX_MODIFIED, sl, true , of, true );
175+ print_entries (GIT_STATUS_INDEX_DELETED, sl, true , of, true );
176+ print_entries (GIT_STATUS_INDEX_RENAMED, sl, true , of, true );
177+ print_entries (GIT_STATUS_INDEX_TYPECHANGE, sl, true , of, true );
170178 if (is_long)
171179 {
172180 std::cout << std::endl;
@@ -179,10 +187,10 @@ void status_subcommand::run()
179187 {
180188 std::cout << notstagged_header << std::endl;
181189 }
182- print_entries (GIT_STATUS_WT_MODIFIED, sl, false , of);
183- print_entries (GIT_STATUS_WT_DELETED, sl, false , of);
184- print_entries (GIT_STATUS_WT_TYPECHANGE, sl, false , of);
185- print_entries (GIT_STATUS_WT_RENAMED, sl, false , of);
190+ print_entries (GIT_STATUS_WT_MODIFIED, sl, false , of, true );
191+ print_entries (GIT_STATUS_WT_DELETED, sl, false , of, true );
192+ print_entries (GIT_STATUS_WT_TYPECHANGE, sl, false , of, true );
193+ print_entries (GIT_STATUS_WT_RENAMED, sl, false , of, true );
186194 if (is_long)
187195 {
188196 std::cout << std::endl;
@@ -195,7 +203,7 @@ void status_subcommand::run()
195203 {
196204 std::cout << untracked_header << std::endl;
197205 }
198- print_entries (GIT_STATUS_WT_NEW, sl, false , of);
206+ print_entries (GIT_STATUS_WT_NEW, sl, false , of, false );
199207 if (is_long)
200208 {
201209 std::cout << std::endl;
@@ -208,7 +216,7 @@ void status_subcommand::run()
208216 {
209217 std::cout << ignored_header << std::endl;
210218 }
211- print_entries (GIT_STATUS_IGNORED, sl, false , of);
219+ print_entries (GIT_STATUS_IGNORED, sl, false , of, false );
212220 if (is_long)
213221 {
214222 std::cout << std::endl;
0 commit comments