@@ -71,7 +71,7 @@ enum class output_format
71
71
SHORT = 2
72
72
};
73
73
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
75
75
{
76
76
const auto & entry_list = sl.get_entry_list (status);
77
77
if (!entry_list.empty ())
@@ -98,6 +98,16 @@ void print_entries(git_status_t status, status_list_wrapper& sl, bool head_selec
98
98
}
99
99
const char * old_path = diff_delta->old_file .path ;
100
100
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
+ }
101
111
if (old_path && new_path && std::strcmp (old_path, new_path))
102
112
{
103
113
std::cout << old_path << " -> " << new_path << std::endl;
@@ -127,8 +137,6 @@ void status_subcommand::run()
127
137
auto sl = status_list_wrapper::status_list (repo);
128
138
auto branch_name = reference_wrapper::get_ref_name (repo);
129
139
130
- // TODO: add branch info
131
-
132
140
output_format of = output_format::DEFAULT;
133
141
if (short_flag)
134
142
{
@@ -162,11 +170,11 @@ void status_subcommand::run()
162
170
{
163
171
std::cout << tobecommited_header << std::endl;
164
172
}
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 );
170
178
if (is_long)
171
179
{
172
180
std::cout << std::endl;
@@ -179,10 +187,10 @@ void status_subcommand::run()
179
187
{
180
188
std::cout << notstagged_header << std::endl;
181
189
}
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 );
186
194
if (is_long)
187
195
{
188
196
std::cout << std::endl;
@@ -195,7 +203,7 @@ void status_subcommand::run()
195
203
{
196
204
std::cout << untracked_header << std::endl;
197
205
}
198
- print_entries (GIT_STATUS_WT_NEW, sl, false , of);
206
+ print_entries (GIT_STATUS_WT_NEW, sl, false , of, false );
199
207
if (is_long)
200
208
{
201
209
std::cout << std::endl;
@@ -208,7 +216,7 @@ void status_subcommand::run()
208
216
{
209
217
std::cout << ignored_header << std::endl;
210
218
}
211
- print_entries (GIT_STATUS_IGNORED, sl, false , of);
219
+ print_entries (GIT_STATUS_IGNORED, sl, false , of, false );
212
220
if (is_long)
213
221
{
214
222
std::cout << std::endl;
0 commit comments