Skip to content

Commit e7821d7

Browse files
j6tgitster
authored andcommitted
Add a notice that only certain functions can print color escape codes
We emulate color escape codes on Windows by overriding printf, fprintf, and fputs. Warn developers that these are the only functions that can be used to print them. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c8e1c3d commit e7821d7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

color.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
/* "\033[1;38;5;2xx;48;5;2xxm\0" is 23 bytes */
55
#define COLOR_MAXLEN 24
66

7+
/*
8+
* IMPORTANT: Due to the way these color codes are emulated on Windows,
9+
* write them only using printf(), fprintf(), and fputs(). In particular,
10+
* do not use puts() or write().
11+
*/
712
#define GIT_COLOR_NORMAL ""
813
#define GIT_COLOR_RESET "\033[m"
914
#define GIT_COLOR_BOLD "\033[1m"

0 commit comments

Comments
 (0)