@@ -45,16 +45,16 @@ struct status_messages
45
45
const std::map<git_status_t , status_messages> status_msg_map = // TODO : check spaces in short_mod
46
46
{
47
47
{ GIT_STATUS_CURRENT, {" " , " " } },
48
- { GIT_STATUS_INDEX_NEW, {" A " , " \t new file:" } },
49
- { GIT_STATUS_INDEX_MODIFIED, {" M " , " \t modified :" } },
50
- { GIT_STATUS_INDEX_DELETED, {" D " , " \t deleted :" } },
51
- { GIT_STATUS_INDEX_RENAMED, {" R " , " \t renamed :" } },
52
- { GIT_STATUS_INDEX_TYPECHANGE, {" T " , " \t typechange :" } },
48
+ { GIT_STATUS_INDEX_NEW, {" A " , " \t new file:" } },
49
+ { GIT_STATUS_INDEX_MODIFIED, {" M " , " \t modified :" } },
50
+ { GIT_STATUS_INDEX_DELETED, {" D " , " \t deleted :" } },
51
+ { GIT_STATUS_INDEX_RENAMED, {" R " , " \t renamed :" } },
52
+ { GIT_STATUS_INDEX_TYPECHANGE, {" T " , " \t typechange :" } },
53
53
{ GIT_STATUS_WT_NEW, {" ?? " , " " } },
54
- { GIT_STATUS_WT_MODIFIED, {" M " , " \t modified :" } },
55
- { GIT_STATUS_WT_DELETED, {" D " , " \t deleted :" } },
56
- { GIT_STATUS_WT_TYPECHANGE, {" T " , " \t typechange :" } },
57
- { GIT_STATUS_WT_RENAMED, {" R " , " \t renamed :" } },
54
+ { GIT_STATUS_WT_MODIFIED, {" M " , " \t modified :" } },
55
+ { GIT_STATUS_WT_DELETED, {" D " , " \t deleted :" } },
56
+ { GIT_STATUS_WT_TYPECHANGE, {" T " , " \t typechange :" } },
57
+ { GIT_STATUS_WT_RENAMED, {" R " , " \t renamed :" } },
58
58
{ GIT_STATUS_WT_UNREADABLE, {" " , " " } },
59
59
{ GIT_STATUS_IGNORED, {" !! " , " " } },
60
60
{ GIT_STATUS_CONFLICTED, {" " , " " } },
@@ -73,7 +73,7 @@ struct print_entry
73
73
std::string item;
74
74
};
75
75
76
- std::string get_print_status (git_status_t status, output_format of)
76
+ std::string get_print_status (git_status_t status, output_format of) // TODO: add colours, but depends on the status, so needs another parameter
77
77
{
78
78
std::string entry_status;
79
79
if ((of == output_format::DEFAULT) || (of == output_format::LONG))
@@ -100,7 +100,7 @@ void update_tracked_dir_set(const char* old_path, const char* new_path, std::set
100
100
}
101
101
}
102
102
103
- std::string get_print_item (const char * old_path, const char * new_path)
103
+ std::string get_print_item (const char * old_path, const char * new_path) // TODO: add colours, but depends on the status, so needs another parameter
104
104
{
105
105
std::string entry_item;
106
106
if (old_path && new_path && std::strcmp (old_path, new_path))
@@ -139,24 +139,27 @@ std::vector<print_entry> get_entries_to_print(git_status_t status, status_list_w
139
139
return entries_to_print;
140
140
}
141
141
142
- void print_entries (std::vector<print_entry> entries_to_print)
142
+ void print_entries (std::vector<print_entry> entries_to_print, bool is_long, std::string colour )
143
143
{
144
144
for (auto e: entries_to_print)
145
145
{
146
- std::cout << e.status << e.item << std::endl;
146
+ if (is_long)
147
+ std::cout << colour << e.status << e.item << message_colour.at (" colour_close" ) << std::endl;
148
+ else
149
+ std::cout << colour << e.status << message_colour.at (" colour_close" ) << e.item << std::endl;
147
150
}
148
151
}
149
152
150
153
void print_not_tracked (const std::vector<print_entry>& entries_to_print, const std::set<std::string>& tracked_dir_set,
151
- std::set<std::string>& untracked_dir_set)
154
+ std::set<std::string>& untracked_dir_set, bool is_long, std::string colour )
152
155
{
153
156
std::vector<print_entry> not_tracked_entries_to_print{};
154
157
for (auto e: entries_to_print)
155
158
{
156
159
const size_t first_slash_idx = e.item .find (' /' );
157
160
if (std::string::npos != first_slash_idx)
158
161
{
159
- auto directory = e.item .substr (0 , first_slash_idx);
162
+ auto directory = e.item .substr (0 , first_slash_idx) + " / " ;
160
163
if (tracked_dir_set.contains (directory))
161
164
{
162
165
not_tracked_entries_to_print.push_back (e);
@@ -177,7 +180,7 @@ void print_not_tracked(const std::vector<print_entry>& entries_to_print, const s
177
180
not_tracked_entries_to_print.push_back (e);
178
181
}
179
182
}
180
- print_entries (not_tracked_entries_to_print);
183
+ print_entries (not_tracked_entries_to_print, is_long, colour );
181
184
}
182
185
183
186
void status_subcommand::run ()
@@ -220,17 +223,19 @@ void status_subcommand::run()
220
223
std::cout << " ## " << branch_name << std::endl;
221
224
}
222
225
}
226
+
223
227
if (sl.has_tobecommited_header ())
224
228
{
229
+ std::string colour = message_colour.at (" green" );
225
230
if (is_long)
226
231
{
227
232
std::cout << tobecommited_header << std::endl;
228
233
}
229
- print_entries (get_entries_to_print (GIT_STATUS_INDEX_NEW, sl, true , of, &tracked_dir_set));
230
- print_entries (get_entries_to_print (GIT_STATUS_INDEX_MODIFIED, sl, true , of, &tracked_dir_set));
231
- print_entries (get_entries_to_print (GIT_STATUS_INDEX_DELETED, sl, true , of, &tracked_dir_set));
232
- print_entries (get_entries_to_print (GIT_STATUS_INDEX_RENAMED, sl, true , of, &tracked_dir_set));
233
- print_entries (get_entries_to_print (GIT_STATUS_INDEX_TYPECHANGE, sl, true , of, &tracked_dir_set));
234
+ print_entries (get_entries_to_print (GIT_STATUS_INDEX_NEW, sl, true , of, &tracked_dir_set), is_long, colour );
235
+ print_entries (get_entries_to_print (GIT_STATUS_INDEX_MODIFIED, sl, true , of, &tracked_dir_set), is_long, colour );
236
+ print_entries (get_entries_to_print (GIT_STATUS_INDEX_DELETED, sl, true , of, &tracked_dir_set), is_long, colour );
237
+ print_entries (get_entries_to_print (GIT_STATUS_INDEX_RENAMED, sl, true , of, &tracked_dir_set), is_long, colour );
238
+ print_entries (get_entries_to_print (GIT_STATUS_INDEX_TYPECHANGE, sl, true , of, &tracked_dir_set), is_long, colour );
234
239
if (is_long)
235
240
{
236
241
std::cout << std::endl;
@@ -239,44 +244,46 @@ void status_subcommand::run()
239
244
240
245
if (sl.has_notstagged_header ())
241
246
{
247
+ std::string colour = message_colour.at (" red" );
242
248
if (is_long)
243
249
{
244
250
std::cout << notstagged_header << std::endl;
245
251
}
246
- print_entries (get_entries_to_print (GIT_STATUS_WT_MODIFIED, sl, false , of, &tracked_dir_set));
247
- print_entries (get_entries_to_print (GIT_STATUS_WT_DELETED, sl, false , of, &tracked_dir_set));
248
- print_entries (get_entries_to_print (GIT_STATUS_WT_TYPECHANGE, sl, false , of, &tracked_dir_set));
249
- print_entries (get_entries_to_print (GIT_STATUS_WT_RENAMED, sl, false , of, &tracked_dir_set));
252
+ print_entries (get_entries_to_print (GIT_STATUS_WT_MODIFIED, sl, false , of, &tracked_dir_set), is_long, colour );
253
+ print_entries (get_entries_to_print (GIT_STATUS_WT_DELETED, sl, false , of, &tracked_dir_set), is_long, colour );
254
+ print_entries (get_entries_to_print (GIT_STATUS_WT_TYPECHANGE, sl, false , of, &tracked_dir_set), is_long, colour );
255
+ print_entries (get_entries_to_print (GIT_STATUS_WT_RENAMED, sl, false , of, &tracked_dir_set), is_long, colour );
250
256
if (is_long)
251
257
{
252
258
std::cout << std::endl;
253
259
}
254
260
}
255
261
256
-
257
262
if (sl.has_untracked_header ())
258
263
{
264
+ std::string colour = message_colour.at (" red" );
259
265
if (is_long)
260
266
{
261
267
std::cout << untracked_header << std::endl;
262
268
}
263
- print_not_tracked (get_entries_to_print (GIT_STATUS_WT_NEW, sl, false , of), tracked_dir_set, untracked_dir_set);
269
+ print_not_tracked (get_entries_to_print (GIT_STATUS_WT_NEW, sl, false , of), tracked_dir_set, untracked_dir_set, is_long, colour );
264
270
if (is_long)
265
271
{
266
272
std::cout << std::endl;
267
273
}
268
274
}
269
275
270
- if (sl.has_ignored_header ())
271
- {
272
- if (is_long)
273
- {
274
- std::cout << ignored_header << std::endl;
275
- }
276
- print_not_tracked (get_entries_to_print (GIT_STATUS_IGNORED, sl, false , of), tracked_dir_set, untracked_dir_set);
277
- if (is_long)
278
- {
279
- std::cout << std::endl;
280
- }
281
- }
276
+ // if (sl.has_ignored_header())
277
+ // {
278
+ // std::string colour = message_colour.at("red");
279
+ // if (is_long)
280
+ // {
281
+ // std::cout << ignored_header << std::endl;
282
+ // }
283
+ // print_not_tracked(get_entries_to_print(GIT_STATUS_IGNORED, sl, false, of), tracked_dir_set, untracked_dir_set, is_long, colour);
284
+ // if (is_long)
285
+ // {
286
+ // std::cout << std::endl;
287
+ // }
288
+ // }
282
289
}
0 commit comments