File tree Expand file tree Collapse file tree 3 files changed +25
-15
lines changed Expand file tree Collapse file tree 3 files changed +25
-15
lines changed Original file line number Diff line number Diff line change @@ -25,19 +25,7 @@ void branch_subcommand::run()
2525
2626 if (m_list_flag || m_branch_name.empty ())
2727 {
28- auto head_name = repo.head ().short_name ();
29- std::cout << " * " << head_name << std::endl;
30- git_branch_t type = m_all_flag ? GIT_BRANCH_ALL : (m_remote_flag ? GIT_BRANCH_REMOTE : GIT_BRANCH_LOCAL);
31- auto iter = repo.iterate_branches (type);
32- auto br = iter.next ();
33- while (br)
34- {
35- if (br->name () != head_name)
36- {
37- std::cout << " " << br->name () << std::endl;
38- }
39- br = iter.next ();
40- }
28+ run_list (repo);
4129 }
4230 else if (m_deletion_flag)
4331 {
@@ -49,6 +37,26 @@ void branch_subcommand::run()
4937 }
5038}
5139
40+ void branch_subcommand::run_list (const repository_wrapper& repo)
41+ {
42+ auto head_name = repo.head ().short_name ();
43+ git_branch_t type = m_all_flag ? GIT_BRANCH_ALL : (m_remote_flag ? GIT_BRANCH_REMOTE : GIT_BRANCH_LOCAL);
44+ auto iter = repo.iterate_branches (type);
45+ auto br = iter.next ();
46+ while (br)
47+ {
48+ if (br->name () != head_name)
49+ {
50+ std::cout << " " << br->name () << std::endl;
51+ }
52+ else
53+ {
54+ std::cout << " * " << br->name () << std::endl;
55+ }
56+ br = iter.next ();
57+ }
58+ }
59+
5260void branch_subcommand::run_deletion (repository_wrapper& repo)
5361{
5462 auto branch = repo.find_branch (m_branch_name);
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ class branch_subcommand
1616
1717private:
1818
19+ void run_list (const repository_wrapper& repo);
1920 void run_deletion (repository_wrapper& repo);
2021 void run_creation (repository_wrapper& repo);
2122
Original file line number Diff line number Diff line change 44
55void throwIfError (int exitCode)
66{
7- if (exitCode < 0 ) {
8- throw GitException (git_error_last ()->message , exitCode);
7+ if (exitCode < 0 )
8+ {
9+ throw GitException (" error: " + std::string (git_error_last ()->message ), exitCode);
910 }
1011}
1112
You can’t perform that action at this time.
0 commit comments