{"thread":{"id":"12018","subject":"[PATCH] config: Fix --unset for continuation lines","startedAt":"2008-02-11T00:23:03Z","lastAt":"2008-02-11T01:14:45Z","messageCount":2,"participants":["Frank Lichtenheld","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"68301","messageId":"1202689383-9450-1-git-send-email-frank@lichtenheld.de","threadId":"12018","inReplyTo":null,"subject":"[PATCH] config: Fix --unset for continuation lines","fromName":"Frank Lichtenheld","fromEmail":"frank@lichtenheld.de","sentAt":"2008-02-11T00:23:03Z","receivedAt":"2008-02-11T00:23:03Z","isPatch":true,"sender":{"key":"frank@lichtenheld.de","avatar":"https://gravatar.com/avatar/b9f1d4b120e138f157c9e480d0818197c474628923786adb98f30017cdb99c3c?d=mp&s=160"},"body":"find_beginning_of_line didn't take into account that the\nprevious line might have ended with \\ in which case it shouldn't\nstop but continue its search.\n\nSigned-off-by: Frank Lichtenheld <frank@lichtenheld.de>\n---\n config.c               |    5 +++++\n t/t1300-repo-config.sh |   19 +++++++++++++++++++\n 2 files changed, 24 insertions(+), 0 deletions(-)\n\n My usual \"I can't code C\" disclaimer applies\n\ndiff --git a/config.c b/config.c\nindex 498259e..1649aae 100644\n--- a/config.c\n+++ b/config.c\n@@ -701,12 +701,17 @@ static ssize_t find_beginning_of_line(const char* contents, size_t size,\n \tsize_t equal_offset = size, bracket_offset = size;\n \tssize_t offset;\n \n+contline:\n \tfor (offset = offset_-2; offset > 0\n \t\t\t&& contents[offset] != '\\n'; offset--)\n \t\tswitch (contents[offset]) {\n \t\t\tcase '=': equal_offset = offset; break;\n \t\t\tcase ']': bracket_offset = offset; break;\n \t\t}\n+\tif (offset > 0 && contents[offset-1] == '\\\\') {\n+\t\toffset_ = offset;\n+\t\tgoto contline;\n+\t}\n \tif (bracket_offset < equal_offset) {\n \t\t*found_bracket = 1;\n \t\toffset = bracket_offset+1;\ndiff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh\nindex 66aeb88..5f7c3a5 100755\n--- a/t/t1300-repo-config.sh\n+++ b/t/t1300-repo-config.sh\n@@ -72,6 +72,25 @@ EOF\n test_expect_success 'non-match result' 'cmp .git/config expect'\n \n cat > .git/config << EOF\n+[alpha]\n+bar = foo\n+[beta]\n+baz = multiple \\\\\n+lines\n+EOF\n+\n+test_expect_success 'unset with cont. lines' \\\n+\t'git config --unset beta.baz'\n+\n+cat > expect << EOF\n+[alpha]\n+bar = foo\n+[beta]\n+EOF\n+\n+test_expect_success 'unset with cont. lines is correct' 'cmp .git/config expect'\n+\n+cat > .git/config << EOF\n [beta] ; silly comment # another comment\n noIndent= sillyValue ; 'nother silly comment\n \n-- \n1.5.4\n"},{"id":"68303","messageId":"alpine.LSU.1.00.0802110114220.3870@racer.site","threadId":"12018","inReplyTo":"1202689383-9450-1-git-send-email-frank@lichtenheld.de","subject":"Re: [PATCH] config: Fix --unset for continuation lines","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-11T01:14:45Z","receivedAt":"2008-02-11T01:14:45Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 11 Feb 2008, Frank Lichtenheld wrote:\n\n> find_beginning_of_line didn't take into account that the previous line \n> might have ended with \\ in which case it shouldn't stop but continue its \n> search.\n\nGood catch.\n\nAcked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n"}]}