git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git-config: case insensitivity for subsections

From
Alex Vandiver <alex@chmrr.net>
Date
Aug 29, 2011, 16:47 UTC
Message-ID
<1314636466.17526.16.camel@umgah.localdomain>
In-Reply-To
<20110829155819.GA756@sigill.intra.peff.net>
On Mon, 2011-08-29 at 11:58 -0400, Jeff King wrote:
Show 11 quoted lines
> Isn't his config somewhat broken?  It looks like this:
> 
>   last = "!f(){ since="$1"; shift; git lg --since=\"last $since\" "$@"; }; f"
> 
> Those interior double-quotes should all be backslash-escaped. I didn't
> check, but git should interpret this as:
> 
>   !f(){ since=$1; shift; git lg --since="last $since" $@; }; f
> 
> which is probably not quite what he wanted (the quotes around $1 were
> actually superfluous, but the ones around $@ are important).

Yes, those should be escaped to do what he probably intends. Nonetheless, certainly a parsing bug.

Show 12 quoted lines
> That being said, I think it is intentional that the value is not just "a
> single double-quoted chunk" but rather could consist of several quoted
> (or unquoted) chunks concatenated together. What does your parser think
> of:
> 
>   [foo]
>     bar = "foo"bar"baz"
> 
> It should be:
> 
>   $ git config foo.bar
>   foobarbaz
And with the below patch to config-gitlike, it does -- thanks for the
bug report.
 - Alex
--------8<-----------
From 433dcc2f739c8906c65329a899b45424c146535c Mon Sep 17 00:00:00 2001
From: Alex Vandiver <alexmv@bestpractical.com>
Date: Mon, 29 Aug 2011 12:04:37 -0400
Subject: [PATCH] Allow quoted strings to adjoin directly to unquoted strings
This resolves a bug wherein:
    [foo]
        bar = "foo"bar"baz"
...was incorrectly parsed as << foo.bar=foobar"baz" >> and not the
correct << foo.bar=foobarbaz >>.  Make the fall-through value not
consume quotes when consuming a token, as it should be instead parsed as
the start of a quoted-value.  This bug was only evident when the quoted
value abutted the unquoted value with no separating space.
---
 lib/Config/GitLike.pm |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/Config/GitLike.pm b/lib/Config/GitLike.pm
index c19911e..8a7195b 100644
--- a/lib/Config/GitLike.pm
+++ b/lib/Config/GitLike.pm
@@ -333,7 +333,7 @@ sub parse_content {
                     $value .= $v;
                 }
                 # valid value (no escape codes)
-                elsif ($c =~ s/\A([^\t \\\n]+)//im) {
+                elsif ($c =~ s/\A([^\t \\\n"]+)//im) {
                     $value .= $1;
                 # unparseable
                 }
-- 
1.7.4.1
Previous: Jeff King
Message 9 of 9 in “git-config: case insensitivity for subsections”
  1. milkiAug 18, 2011
  2. Jeff KingAug 25, 2011
  3. Junio C HamanoAug 25, 2011
  4. Jeff KingAug 25, 2011
  5. milkiAug 25, 2011
  6. Alex VandiverAug 29, 2011
  7. milkiAug 29, 2011
  8. Jeff KingAug 29, 2011
  9. Alex VandiverAug 29, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.