{"thread":{"id":"4025","subject":"[PATCH] repo-config: trim white-space before comment","startedAt":"2006-05-02T14:58:37Z","lastAt":"2006-05-02T14:58:37Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"19369","messageId":"Pine.LNX.4.63.0605021655220.8118@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4025","inReplyTo":null,"subject":"[PATCH] repo-config: trim white-space before comment","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-05-02T14:58:37Z","receivedAt":"2006-05-02T14:58:37Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nEarlier, calling\n\n\tgit-repo-config core.hello\n\non a .git/config like this:\n\n\t[core]\n\t\thello = world ; a comment\n\nwould yield \"world \" (i.e. with a trailing space).\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n\tI wrote:\n\t> Strange thing I realized: A value is white-space-trimmed at the end\n\t> only if the line does not end with a comment. This fact is accounted\n\t> for in the new tests.\n\n\tIt actually was a buglet in parse_value(), so it was not only \n\trepo-config which was affected.\n\n\tObviously, this patch comes on top of the --get-regexp patch, but\n\tfeel free to apply without that.\n\n config.c               |   12 ++++++------\n t/t1300-repo-config.sh |    8 ++++++--\n 2 files changed, 12 insertions(+), 8 deletions(-)\n\nbb874fdd7a55b7adc229ee9eb1b59e5852b41594\ndiff --git a/config.c b/config.c\nindex 4e1f0c2..253c48a 100644\n--- a/config.c\n+++ b/config.c\n@@ -60,6 +60,12 @@ static char *parse_value(void)\n \t\t\tspace = 1;\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!quote) {\n+\t\t\tif (c == ';' || c == '#') {\n+\t\t\t\tcomment = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t}\n \t\tif (space) {\n \t\t\tif (len)\n \t\t\t\tvalue[len++] = ' ';\n@@ -93,12 +99,6 @@ static char *parse_value(void)\n \t\t\tquote = 1-quote;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!quote) {\n-\t\t\tif (c == ';' || c == '#') {\n-\t\t\t\tcomment = 1;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\t\t}\n \t\tvalue[len++] = c;\n \t}\n }\ndiff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh\nindex 52e8e33..e3ab661 100755\n--- a/t/t1300-repo-config.sh\n+++ b/t/t1300-repo-config.sh\n@@ -247,8 +247,12 @@ EOF\n \n test_expect_success 'hierarchical section value' 'cmp .git/config expect'\n \n+value=\"$(git-repo-config beta.noindent)\"\n+\n+test_expect_success 'trim before comment' \"test \\\"$value\\\" = sillyValue\"\n+\n cat > expect << EOF\n-beta.noindent=sillyValue \n+beta.noindent=sillyValue\n nextsection.nonewline=wow2 for me\n 123456.a123=987\n 1.2.3.alpha=beta\n@@ -258,7 +262,7 @@ test_expect_success 'working --list' \\\n \t'git-repo-config --list > output && cmp output expect'\n \n cat > expect << EOF\n-beta.noindent sillyValue \n+beta.noindent sillyValue\n nextsection.nonewline wow2 for me\n EOF\n \n-- \n1.3.1.g259f\n"}]}