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()
25
25
26
26
if (m_list_flag || m_branch_name.empty ())
27
27
{
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);
41
29
}
42
30
else if (m_deletion_flag)
43
31
{
@@ -49,6 +37,26 @@ void branch_subcommand::run()
49
37
}
50
38
}
51
39
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
+
52
60
void branch_subcommand::run_deletion (repository_wrapper& repo)
53
61
{
54
62
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
16
16
17
17
private:
18
18
19
+ void run_list (const repository_wrapper& repo);
19
20
void run_deletion (repository_wrapper& repo);
20
21
void run_creation (repository_wrapper& repo);
21
22
Original file line number Diff line number Diff line change 4
4
5
5
void throwIfError (int exitCode)
6
6
{
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);
9
10
}
10
11
}
11
12
You can’t perform that action at this time.
0 commit comments