Skip to content

Commit 758df17

Browse files
MarkLodatogitster
authored andcommitted
Add GIT_COLOR_BOLD_* and GIT_COLOR_BG_*
Add GIT_COLOR_BOLD_* macros to set both bold and the color in one sequence. This saves two characters of output ("ESC [ m", minus ";") and makes the code more readable. Add the remaining GIT_COLOR_BG_* macros to make the list complete. The white and black colors are not included since they look bad on most terminals. Signed-off-by: Mark Lodato <lodatom@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent dc05d73 commit 758df17

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

builtin-grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
871871
opt.regflags = REG_NEWLINE;
872872
opt.max_depth = -1;
873873

874-
strcpy(opt.color_match, GIT_COLOR_RED GIT_COLOR_BOLD);
874+
strcpy(opt.color_match, GIT_COLOR_BOLD_RED);
875875
opt.color = -1;
876876
git_config(grep_config, &opt);
877877
if (opt.color == -1)

color.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,18 @@
1818
#define GIT_COLOR_BLUE "\033[34m"
1919
#define GIT_COLOR_MAGENTA "\033[35m"
2020
#define GIT_COLOR_CYAN "\033[36m"
21+
#define GIT_COLOR_BOLD_RED "\033[1;31m"
22+
#define GIT_COLOR_BOLD_GREEN "\033[1;32m"
23+
#define GIT_COLOR_BOLD_YELLOW "\033[1;33m"
24+
#define GIT_COLOR_BOLD_BLUE "\033[1;34m"
25+
#define GIT_COLOR_BOLD_MAGENTA "\033[1;35m"
26+
#define GIT_COLOR_BOLD_CYAN "\033[1;36m"
2127
#define GIT_COLOR_BG_RED "\033[41m"
28+
#define GIT_COLOR_BG_GREEN "\033[42m"
29+
#define GIT_COLOR_BG_YELLOW "\033[43m"
30+
#define GIT_COLOR_BG_BLUE "\033[44m"
31+
#define GIT_COLOR_BG_MAGENTA "\033[45m"
32+
#define GIT_COLOR_BG_CYAN "\033[46m"
2233

2334
/*
2435
* This variable stores the value of color.ui

graph.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ static char column_colors[][COLOR_MAXLEN] = {
8080
GIT_COLOR_BLUE,
8181
GIT_COLOR_MAGENTA,
8282
GIT_COLOR_CYAN,
83-
GIT_COLOR_BOLD GIT_COLOR_RED,
84-
GIT_COLOR_BOLD GIT_COLOR_GREEN,
85-
GIT_COLOR_BOLD GIT_COLOR_YELLOW,
86-
GIT_COLOR_BOLD GIT_COLOR_BLUE,
87-
GIT_COLOR_BOLD GIT_COLOR_MAGENTA,
88-
GIT_COLOR_BOLD GIT_COLOR_CYAN,
83+
GIT_COLOR_BOLD_RED,
84+
GIT_COLOR_BOLD_GREEN,
85+
GIT_COLOR_BOLD_YELLOW,
86+
GIT_COLOR_BOLD_BLUE,
87+
GIT_COLOR_BOLD_MAGENTA,
88+
GIT_COLOR_BOLD_CYAN,
8989
};
9090

9191
#define COLUMN_COLORS_MAX (ARRAY_SIZE(column_colors))

0 commit comments

Comments
 (0)