diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-04-01 13:21:34 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-04-01 13:21:34 -0700 |
| commit | 521df686e5a5d445e03280f48df966b77e23f160 (patch) | |
| tree | fbd8b5eb9ef2b57c660aaa6ad9b8e799ec1530d0 /config.c | |
| parent | a031815a7df317a4387151b1f4af1c85834458b1 (diff) | |
| parent | e6895c3f971dc4d60f7a9fac6ef41a6593a37ba9 (diff) | |
| download | git-521df686e5a5d445e03280f48df966b77e23f160.tar.gz | |
Merge branch 'ds/config-internal-whitespace-fix'
"git config" corrupted literal HT characters written in the
configuration file as part of a value, which has been corrected.
* ds/config-internal-whitespace-fix:
config.txt: describe handling of whitespace further
t1300: add more tests for whitespace and inline comments
config: really keep value-internal whitespace verbatim
config: minor addition of whitespace
Diffstat (limited to 'config.c')
| -rw-r--r-- | config.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -817,7 +817,8 @@ static int get_next_char(struct config_source *cs) static char *parse_value(struct config_source *cs) { - int quote = 0, comment = 0, space = 0; + int quote = 0, comment = 0; + size_t trim_len = 0; strbuf_reset(&cs->value); for (;;) { @@ -827,13 +828,17 @@ static char *parse_value(struct config_source *cs) cs->linenr--; return NULL; } + if (trim_len) + strbuf_setlen(&cs->value, trim_len); return cs->value.buf; } if (comment) continue; if (isspace(c) && !quote) { + if (!trim_len) + trim_len = cs->value.len; if (cs->value.len) - space++; + strbuf_addch(&cs->value, c); continue; } if (!quote) { @@ -842,8 +847,8 @@ static char *parse_value(struct config_source *cs) continue; } } - for (; space; space--) - strbuf_addch(&cs->value, ' '); + if (trim_len) + trim_len = 0; if (c == '\\') { c = get_next_char(cs); switch (c) { @@ -869,7 +874,7 @@ static char *parse_value(struct config_source *cs) continue; } if (c == '"') { - quote = 1-quote; + quote = 1 - quote; continue; } strbuf_addch(&cs->value, c); |
