From: Alex Vandiver Date: Sun, 26 Jul 2009 16:18:22 GMT Subject: [PATCH] Make git config fail on variables with no section, as documented Message-ID: <1248625102-472-1-git-send-email-alex@chmrr.net> In-Reply-To: <1248474081-sup-2762@utwig> Documentation/config.txt claims: Each variable must belong to some section, which means that there must be a section header before the first setting of a variable. However, the parsing code did not enforce this. This change makes it a syntax error to defined a variable before the first section header. Signed-off-by: Alex Vandiver --- config.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/config.c b/config.c index 1b3823d..447ad00 100644 --- a/config.c +++ b/config.c @@ -248,6 +248,8 @@ static int git_parse_file(config_fn_t fn, void *data) } if (!isalpha(c)) break; + if (baselen == 0) + break; var[baselen] = tolower(c); if (get_value(fn, data, var, baselen+1) < 0) break; -- 1.6.3.3.473.gb74fc4.dirty