summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-02-08 09:31:51 +0000
committerPatrick Steinhardt <ps@pks.im>2018-02-08 17:13:53 +0000
commit5340ca774cbe702eb0115e74b559884003c61232 (patch)
tree51d770d53772a4a54b7d315c32cd80e9aaa7f4ce
parentf7225946edeae35f48e3d402e2e0c94ea07f9666 (diff)
downloadlibgit2-5340ca774cbe702eb0115e74b559884003c61232.tar.gz
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.
-rw-r--r--src/config_parse.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/config_parse.c b/src/config_parse.c
index 586bba8ed..2b9669c2b 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;