Skip to content

Commit b83bd03

Browse files
committed
config: don't write invalid column
When we don't specify a particular column, don't write it in the error message. (column "0" is unhelpful.)
1 parent 42dd38d commit b83bd03

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/config_parse.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ const char *git_config_escaped = "\n\t\b\"\\";
1717
static void set_parse_error(git_config_parser *reader, int col, const char *error_str)
1818
{
1919
const char *file = reader->file ? reader->file->path : "in-memory";
20-
git_error_set(GIT_ERROR_CONFIG, "failed to parse config file: %s (in %s:%"PRIuZ", column %d)",
21-
error_str, file, reader->ctx.line_num, col);
20+
21+
if (col)
22+
git_error_set(GIT_ERROR_CONFIG,
23+
"failed to parse config file: %s (in %s:%"PRIuZ", column %d)",
24+
error_str, file, reader->ctx.line_num, col);
25+
else
26+
git_error_set(GIT_ERROR_CONFIG,
27+
"failed to parse config file: %s (in %s:%"PRIuZ")",
28+
error_str, file, reader->ctx.line_num);
2229
}
2330

2431

0 commit comments

Comments
 (0)