color.c: trim leading spaces in color_parse_mem()
[gitweb.git] / color.c
diff --git a/color.c b/color.c
index 81c26767239f9e028057c1843f57b77640db6c26..7bb4a96f8c1dfb0b5769829a133cd8a86d8beee6 100644 (file)
--- a/color.c
+++ b/color.c
@@ -207,7 +207,15 @@ 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)
+               return -1;
+
+       if (!strncasecmp(ptr, "reset", len)) {
                xsnprintf(dst, end - dst, GIT_COLOR_RESET);
                return 0;
        }