6
6
7
7
#include " status_subcommand.hpp"
8
8
#include " ../wrapper/status_wrapper.hpp"
9
+ #include " ../wrapper/refs_wrapper.hpp"
10
+
9
11
10
12
status_subcommand::status_subcommand (const libgit2_object&, CLI::App& app)
11
13
{
@@ -22,6 +24,7 @@ status_subcommand::status_subcommand(const libgit2_object&, CLI::App& app)
22
24
// This is similar to the short output, but will remain stable across Git versions and regardless of user configuration.
23
25
// See below for details. The version parameter is used to specify the format version. This is optional and defaults
24
26
// to the original version v1 format.");
27
+ sub->add_flag (" -b,--branch" , branch_flag, " Show the branch and tracking info even in short-format." );
25
28
26
29
sub->callback ([this ]() { this ->run (); });
27
30
};
@@ -122,6 +125,7 @@ void status_subcommand::run()
122
125
auto bare = false ;
123
126
auto repo = repository_wrapper::init (directory, bare);
124
127
auto sl = status_list_wrapper::status_list (repo);
128
+ auto branch_name = reference_wrapper::get_ref_name (repo);
125
129
126
130
// TODO: add branch info
127
131
@@ -141,6 +145,17 @@ void status_subcommand::run()
141
145
142
146
bool is_long;
143
147
is_long = ((of == output_format::DEFAULT) || (of == output_format::LONG));
148
+ if (is_long)
149
+ {
150
+ std::cout << " On branch " << branch_name << std::endl;
151
+ }
152
+ else
153
+ {
154
+ if (branch_flag)
155
+ {
156
+ std::cout << " ## " << branch_name << std::endl;
157
+ }
158
+ }
144
159
if (sl.has_tobecommited_header ())
145
160
{
146
161
if (is_long)
0 commit comments