Commit 5340ca774cbe702eb0115e74b559884003c61232

Patrick Steinhardt 2018-02-08T09:31:51

config_parse: add comment to clarify logic getting next character Upon each line, the configuration parser tries to get either the first non-whitespace character or the first whitespace character, in case there is no non-whitespace character. The logic handling this looks rather odd and doesn't immediately convey this meaning, so add a comment to clarify what happens.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/config_parse.c b/src/config_parse.c
index 586bba8..2b9669c 100644
--- a/src/config_parse.c
+++ b/src/config_parse.c
@@ -475,6 +475,11 @@ int git_config_parse(
 		size_t line_len = parser->ctx.line_len;
 		char c;
 
+		/*
+		 * Get either first non-whitespace character or, if that does
+		 * not exist, the first whitespace character. This is required
+		 * to preserve whitespaces when writing back the file.
+		 */
 		if (git_parse_peek(&c, ctx, GIT_PARSE_PEEK_SKIP_WHITESPACE) < 0 &&
 		    git_parse_peek(&c, ctx, 0) < 0)
 			continue;