From: Frank Lichtenheld <frank@lichtenheld.de>
To: Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <junkio@cox.net>,
Frank Lichtenheld <frank@lichtenheld.de>
Subject: [PATCH] config: Fix --unset for continuation lines
Date: Mon, 11 Feb 2008 01:23:03 +0100 [thread overview]
Message-ID: <1202689383-9450-1-git-send-email-frank@lichtenheld.de> (raw)
find_beginning_of_line didn't take into account that the
previous line might have ended with \ in which case it shouldn't
stop but continue its search.
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
---
config.c | 5 +++++
t/t1300-repo-config.sh | 19 +++++++++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)
My usual "I can't code C" disclaimer applies
diff --git a/config.c b/config.c
index 498259e..1649aae 100644
--- a/config.c
+++ b/config.c
@@ -701,12 +701,17 @@ static ssize_t find_beginning_of_line(const char* contents, size_t size,
size_t equal_offset = size, bracket_offset = size;
ssize_t offset;
+contline:
for (offset = offset_-2; offset > 0
&& contents[offset] != '\n'; offset--)
switch (contents[offset]) {
case '=': equal_offset = offset; break;
case ']': bracket_offset = offset; break;
}
+ if (offset > 0 && contents[offset-1] == '\\') {
+ offset_ = offset;
+ goto contline;
+ }
if (bracket_offset < equal_offset) {
*found_bracket = 1;
offset = bracket_offset+1;
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 66aeb88..5f7c3a5 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -72,6 +72,25 @@ EOF
test_expect_success 'non-match result' 'cmp .git/config expect'
cat > .git/config << EOF
+[alpha]
+bar = foo
+[beta]
+baz = multiple \\
+lines
+EOF
+
+test_expect_success 'unset with cont. lines' \
+ 'git config --unset beta.baz'
+
+cat > expect << EOF
+[alpha]
+bar = foo
+[beta]
+EOF
+
+test_expect_success 'unset with cont. lines is correct' 'cmp .git/config expect'
+
+cat > .git/config << EOF
[beta] ; silly comment # another comment
noIndent= sillyValue ; 'nother silly comment
--
1.5.4
next reply other threads:[~2008-02-11 0:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-11 0:23 Frank Lichtenheld [this message]
2008-02-11 1:14 ` [PATCH] config: Fix --unset for continuation lines Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1202689383-9450-1-git-send-email-frank@lichtenheld.de \
--to=frank@lichtenheld.de \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox