Commit b83bd0379034eb16afae8753af41c0c7e25680b3

Edward Thomson 2019-05-16T08:57:10

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.)

diff --git a/src/config_parse.c b/src/config_parse.c
index fde2ea0..6b162cb 100644
--- a/src/config_parse.c
+++ b/src/config_parse.c
@@ -17,8 +17,15 @@ const char *git_config_escaped = "\n\t\b\"\\";
 static void set_parse_error(git_config_parser *reader, int col, const char *error_str)
 {
 	const char *file = reader->file ? reader->file->path : "in-memory";
-	git_error_set(GIT_ERROR_CONFIG, "failed to parse config file: %s (in %s:%"PRIuZ", column %d)",
-		error_str, file, reader->ctx.line_num, col);
+
+	if (col)
+		git_error_set(GIT_ERROR_CONFIG,
+		              "failed to parse config file: %s (in %s:%"PRIuZ", column %d)",
+		              error_str, file, reader->ctx.line_num, col);
+	else
+		git_error_set(GIT_ERROR_CONFIG,
+		              "failed to parse config file: %s (in %s:%"PRIuZ")",
+		              error_str, file, reader->ctx.line_num);
 }