Skip to content

Commit bc40756

Browse files
pcloudsgitster
authored andcommitted
color.c: trim leading spaces in color_parse_mem()
Normally color_parse_mem() is called from config parser which trims the leading spaces already. The new caller in the next patch won't. Let's be tidy and trim leading spaces too (we already trim trailing spaces after a word). Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c2f41bf commit bc40756

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

color.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,15 @@ int color_parse_mem(const char *value, int value_len, char *dst)
207207
struct color fg = { COLOR_UNSPECIFIED };
208208
struct color bg = { COLOR_UNSPECIFIED };
209209

210+
while (len > 0 && isspace(*ptr)) {
211+
ptr++;
212+
len--;
213+
}
214+
210215
if (!len)
211216
return -1;
212217

213-
if (!strncasecmp(value, "reset", len)) {
218+
if (!strncasecmp(ptr, "reset", len)) {
214219
xsnprintf(dst, end - dst, GIT_COLOR_RESET);
215220
return 0;
216221
}

0 commit comments

Comments
 (0)