summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-03-13 19:35:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-03-13 19:35:53 (GMT)
commit3f263099fca47c278e696fbc0f0d5525318eae0a (patch)
treeb78a78ebcf7b864dcb705ab48b398cc79766936b /config.c
parent9d9bfea8f50f17fa52ff4a1161ef1d78b71ea40a (diff)
parent4b340593551217904d794cc0a8db55db89b5b066 (diff)
downloadgit-3f263099fca47c278e696fbc0f0d5525318eae0a.zip
git-3f263099fca47c278e696fbc0f0d5525318eae0a.tar.gz
git-3f263099fca47c278e696fbc0f0d5525318eae0a.tar.bz2
Merge branch 'ms/maint-config-error-at-eol-linecount'
When "git config" diagnoses an error in a configuration file and shows the line number for the offending line, it miscounted if the error was at the end of line. By Martin Stenberg * ms/maint-config-error-at-eol-linecount: config: report errors at the EOL with correct line number Conflicts: t/t1300-repo-config.sh
Diffstat (limited to 'config.c')
-rw-r--r--config.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/config.c b/config.c
index ad03908..68d3294 100644
--- a/config.c
+++ b/config.c
@@ -196,8 +196,10 @@ static char *parse_value(void)
for (;;) {
int c = get_next_char();
if (c == '\n') {
- if (quote)
+ if (quote) {
+ cf->linenr--;
return NULL;
+ }
return cf->value.buf;
}
if (comment)
@@ -287,7 +289,7 @@ static int get_extended_base_var(char *name, int baselen, int c)
{
do {
if (c == '\n')
- return -1;
+ goto error_incomplete_line;
c = get_next_char();
} while (isspace(c));
@@ -299,13 +301,13 @@ static int get_extended_base_var(char *name, int baselen, int c)
for (;;) {
int c = get_next_char();
if (c == '\n')
- return -1;
+ goto error_incomplete_line;
if (c == '"')
break;
if (c == '\\') {
c = get_next_char();
if (c == '\n')
- return -1;
+ goto error_incomplete_line;
}
name[baselen++] = c;
if (baselen > MAXNAME / 2)
@@ -316,6 +318,9 @@ static int get_extended_base_var(char *name, int baselen, int c)
if (get_next_char() != ']')
return -1;
return baselen;
+error_incomplete_line:
+ cf->linenr--;
+ return -1;
}
static int get_base_var(char *name)