]> git.ipfire.org Git - thirdparty/git.git/blobdiff - color.c
test-path-utils: offer to run a protectNTFS/protectHFS benchmark
[thirdparty/git.git] / color.c
diff --git a/color.c b/color.c
index 1b95e6b2a7bb1601fa5862de8989775e197c7b41..9a9261ac164f503e2a9240806f4f44bedf9b8192 100644 (file)
--- a/color.c
+++ b/color.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "config.h"
 #include "color.h"
 
 static int git_use_color_default = GIT_COLOR_AUTO;
@@ -207,7 +208,17 @@ int color_parse_mem(const char *value, int value_len, char *dst)
        struct color fg = { COLOR_UNSPECIFIED };
        struct color bg = { COLOR_UNSPECIFIED };
 
-       if (!strncasecmp(value, "reset", len)) {
+       while (len > 0 && isspace(*ptr)) {
+               ptr++;
+               len--;
+       }
+
+       if (!len) {
+               dst[0] = '\0';
+               return 0;
+       }
+
+       if (!strncasecmp(ptr, "reset", len)) {
                xsnprintf(dst, end - dst, GIT_COLOR_RESET);
                return 0;
        }
@@ -327,6 +338,13 @@ static int check_auto_color(void)
 
 int want_color(int var)
 {
+       /*
+        * NEEDSWORK: This function is sometimes used from multiple threads, and
+        * we end up using want_auto racily. That "should not matter" since
+        * we always write the same value, but it's still wrong. This function
+        * is listed in .tsan-suppressions for the time being.
+        */
+
        static int want_auto = -1;
 
        if (var < 0)