@@ -61,18 +61,25 @@ const std::map<git_status_t, status_messages> status_msg_map = //TODO : check
61
61
{ GIT_STATUS_CONFLICTED, {" " , " " } },
62
62
};
63
63
64
- void print_entries (git_status_t status, status_list_wrapper& sl, bool head_selector, size_t output_format) // TODO: add different mods
64
+ enum class output_format
65
+ {
66
+ DEFAULT = 0 ,
67
+ LONG = 1 ,
68
+ SHORT = 2
69
+ };
70
+
71
+ void print_entries (git_status_t status, status_list_wrapper& sl, bool head_selector, output_format of) // TODO: add different mods
65
72
{
66
73
const auto & entry_list = sl.get_entry_list (status);
67
74
if (!entry_list.empty ())
68
75
{
69
76
for (auto * entry : entry_list)
70
77
{
71
- if ((output_format <= 1 ))
78
+ if ((of == output_format::DEFAULT) || (of == output_format::LONG ))
72
79
{
73
80
std::cout << status_msg_map.at (status).long_mod << " \t " ;
74
81
}
75
- else if (output_format == 2 )
82
+ else if (of == output_format::SHORT )
76
83
{
77
84
std::cout << status_msg_map.at (status).short_mod ;
78
85
}
@@ -118,14 +125,14 @@ void status_subcommand::run()
118
125
119
126
// TODO: add branch info
120
127
121
- size_t output_format = 0 ;
128
+ output_format of = output_format::DEFAULT ;
122
129
if (short_flag)
123
130
{
124
- output_format = 2 ;
131
+ of = output_format::SHORT ;
125
132
}
126
133
if (long_flag)
127
134
{
128
- output_format = 1 ;
135
+ of = output_format::LONG ;
129
136
}
130
137
// else if (porcelain_format)
131
138
// {
@@ -135,35 +142,35 @@ void status_subcommand::run()
135
142
if (sl.has_tobecommited_header ())
136
143
{
137
144
std::cout << tobecommited_header << std::endl;
138
- print_entries (GIT_STATUS_INDEX_NEW, sl, true , output_format );
139
- print_entries (GIT_STATUS_INDEX_MODIFIED, sl, true , output_format );
140
- print_entries (GIT_STATUS_INDEX_DELETED, sl, true , output_format );
141
- print_entries (GIT_STATUS_INDEX_RENAMED, sl, true , output_format );
142
- print_entries (GIT_STATUS_INDEX_TYPECHANGE, sl, true , output_format );
145
+ print_entries (GIT_STATUS_INDEX_NEW, sl, true , of );
146
+ print_entries (GIT_STATUS_INDEX_MODIFIED, sl, true , of );
147
+ print_entries (GIT_STATUS_INDEX_DELETED, sl, true , of );
148
+ print_entries (GIT_STATUS_INDEX_RENAMED, sl, true , of );
149
+ print_entries (GIT_STATUS_INDEX_TYPECHANGE, sl, true , of );
143
150
std::cout << std::endl;
144
151
}
145
152
146
153
if (sl.has_notstagged_header ())
147
154
{
148
155
std::cout << notstagged_header << std::endl;
149
- print_entries (GIT_STATUS_WT_MODIFIED, sl, false , output_format );
150
- print_entries (GIT_STATUS_WT_DELETED, sl, false , output_format );
151
- print_entries (GIT_STATUS_WT_TYPECHANGE, sl, false , output_format );
152
- print_entries (GIT_STATUS_WT_RENAMED, sl, false , output_format );
156
+ print_entries (GIT_STATUS_WT_MODIFIED, sl, false , of );
157
+ print_entries (GIT_STATUS_WT_DELETED, sl, false , of );
158
+ print_entries (GIT_STATUS_WT_TYPECHANGE, sl, false , of );
159
+ print_entries (GIT_STATUS_WT_RENAMED, sl, false , of );
153
160
std::cout << std::endl;
154
161
}
155
162
156
163
if (sl.has_untracked_header ())
157
164
{
158
165
std::cout << untracked_header << std::endl;
159
- print_entries (GIT_STATUS_WT_NEW, sl, false , output_format );
166
+ print_entries (GIT_STATUS_WT_NEW, sl, false , of );
160
167
std::cout << std::endl;
161
168
}
162
169
163
170
if (sl.has_ignored_header ())
164
171
{
165
172
std::cout << ignored_header << std::endl;
166
- print_entries (GIT_STATUS_IGNORED, sl, false , output_format );
173
+ print_entries (GIT_STATUS_IGNORED, sl, false , of );
167
174
std::cout << std::endl;
168
175
}
169
176
}
0 commit comments