Skip to content

Commit d685503

Browse files
committed
fix log colour
1 parent 7d2526f commit d685503

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/subcommand/log_subcommand.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <git2/types.h>
55
#include <string_view>
66

7+
#include <termcolor/termcolor.hpp>
8+
79
#include "log_subcommand.hpp"
810
#include "../wrapper/repository_wrapper.hpp"
911
#include "../wrapper/commit_wrapper.hpp"
@@ -54,7 +56,8 @@ void print_commit(const commit_wrapper& commit, std::string m_format_flag)
5456
signature_wrapper author = signature_wrapper::get_commit_author(commit);
5557
signature_wrapper committer = signature_wrapper::get_commit_committer(commit);
5658

57-
std::cout << message_colour.at("yellow") << "commit " << buf << message_colour.at("colour_close") << std::endl;
59+
stream_colour_fn colour = termcolor::yellow;
60+
std::cout << colour << "commit " << buf << termcolor::reset << std::endl;
5861
if (m_format_flag=="fuller")
5962
{
6063
std::cout << "Author:\t " << author.name() << " " << author.email() << std::endl;

src/subcommand/status_subcommand.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,7 @@ std::vector<print_entry> get_entries_to_print(git_status_t status, status_list_w
140140
return entries_to_print;
141141
}
142142

143-
using str_colour_fn = std::ostream& (*)(std::ostream&);
144-
145-
void print_entries(std::vector<print_entry> entries_to_print, bool is_long, str_colour_fn colour)
143+
void print_entries(std::vector<print_entry> entries_to_print, bool is_long, stream_colour_fn colour)
146144
{
147145
for (auto e: entries_to_print)
148146
{
@@ -158,7 +156,7 @@ void print_entries(std::vector<print_entry> entries_to_print, bool is_long, str_
158156
}
159157

160158
void print_not_tracked(const std::vector<print_entry>& entries_to_print, const std::set<std::string>& tracked_dir_set,
161-
std::set<std::string>& untracked_dir_set, bool is_long, str_colour_fn colour)
159+
std::set<std::string>& untracked_dir_set, bool is_long, stream_colour_fn colour)
162160
{
163161
std::vector<print_entry> not_tracked_entries_to_print{};
164162
for (auto e: entries_to_print)
@@ -233,7 +231,7 @@ void status_subcommand::run()
233231

234232
if (sl.has_tobecommited_header())
235233
{
236-
str_colour_fn colour = termcolor::green;
234+
stream_colour_fn colour = termcolor::green;
237235
if (is_long)
238236
{
239237
std::cout << tobecommited_header;
@@ -251,7 +249,7 @@ void status_subcommand::run()
251249

252250
if (sl.has_notstagged_header())
253251
{
254-
str_colour_fn colour = termcolor::red;
252+
stream_colour_fn colour = termcolor::red;
255253
if (is_long)
256254
{
257255
std::cout << notstagged_header;
@@ -268,7 +266,7 @@ void status_subcommand::run()
268266

269267
if (sl.has_untracked_header())
270268
{
271-
str_colour_fn colour = termcolor::red;
269+
stream_colour_fn colour = termcolor::red;
272270
if (is_long)
273271
{
274272
std::cout << untracked_header;
@@ -282,7 +280,7 @@ void status_subcommand::run()
282280

283281
// if (sl.has_ignored_header())
284282
// {
285-
// str_colour_fn colour = termcolor::red;
283+
// stream_colour_fn colour = termcolor::red;
286284
// if (is_long)
287285
// {
288286
// std::cout << ignored_header;

src/utils/common.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class libgit2_object : private noncopyable_nonmovable
2929

3030
std::string get_current_git_path();
3131

32+
using stream_colour_fn = std::ostream& (*)(std::ostream&);
33+
3234
class git_strarray_wrapper
3335
{
3436
public:

0 commit comments

Comments
 (0)