66
77#include " status_subcommand.hpp"
88#include " ../wrapper/status_wrapper.hpp"
9+ #include " ../wrapper/refs_wrapper.hpp"
10+
911
1012status_subcommand::status_subcommand (const libgit2_object&, CLI::App& app)
1113{
@@ -22,6 +24,7 @@ status_subcommand::status_subcommand(const libgit2_object&, CLI::App& app)
2224 // This is similar to the short output, but will remain stable across Git versions and regardless of user configuration.
2325 // See below for details. The version parameter is used to specify the format version. This is optional and defaults
2426 // to the original version v1 format.");
27+ sub->add_flag (" -b,--branch" , branch_flag, " Show the branch and tracking info even in short-format." );
2528
2629 sub->callback ([this ]() { this ->run (); });
2730};
@@ -122,6 +125,7 @@ void status_subcommand::run()
122125 auto bare = false ;
123126 auto repo = repository_wrapper::init (directory, bare);
124127 auto sl = status_list_wrapper::status_list (repo);
128+ auto branch_name = reference_wrapper::get_ref_name (repo);
125129
126130 // TODO: add branch info
127131
@@ -141,6 +145,17 @@ void status_subcommand::run()
141145
142146 bool is_long;
143147 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+ }
144159 if (sl.has_tobecommited_header ())
145160 {
146161 if (is_long)
0 commit comments