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

Re: git silently ignores include directive with single quotes

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Sep 10, 2018, 17:14 UTC
Message-ID
<20180910171422.GA26356@aiede.svl.corp.google.com>
In-Reply-To
<xmqqr2i1thbs.fsf@gitster-ct.c.googlers.com>
Hi,
Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
Show 19 quoted lines
>> So I think it's been covered elsewhere that single quotes aren't a thing
>> in git's config format. I will say that this was actually a minor
>> surprise to me, after a decade of working with the format. ;)
>>
>> I don't know if it's worth changing now or not It would be
>> backwards-incompatible, but I wonder if we could do it in a sane way.
>> E.g., with a rule like:
>>
>>   - if the first non-whitespace character of the value is a
>>     single-quote, assume the value is quoted and apply normal shell
>>     rules (i.e., no backslash escapes until the ending single-quote)
>>
>>   - otherwise, single-quotes are not special at all
>
> At least the rule would not force those with ' in the middle of
> their family names to surround the user.name with extra double
> quotes, and it would probably be a good and safe practical solution.
> Being safe "by magic" tend to become hard to explain, but in this
> case the magic part is probably still simple enough.
Given that today,
	git config foo.bar "'baz'"
produces
	[foo]
		bar = 'baz'

I don't think this would be safe to do. Since the underlying problem is that the latter syntax is confusing, I wonder if we can do the following:

 1. Treat single-quote as worth quoting in config.c::write_pair (line
    2516).  This would already help with the original issue, since the
    config would say
	[foo]
		bar = \'baz\'
    allowing a quick diagnosis.
 2. (optional) Warn if a value is surrounded in single-quotes,
    encouraging using backslash to disambiguate.
 3. (optional) Error out if a value is surrounded in single-quotes,
    encouraging using double-quote or backslash, depending on the
    user's intention.
 4. (optional) Start treating wrapping single-quotes specially
    somehow.

I think step 1 is a good idea, but I'm not convinced about any of the later steps.

I also agree with the comments upthread about wanting a way to do a '[include] path' that errors out if the file doesn't exist, and maybe even starting a transition to repurpose standard [include] path to do that.

Thanks, Jonathan

Previous: Junio C HamanoNext: Junio C Hamano
Message 32 of 37 in “git silently ignores include directive with single quotes”
  1. Stas BekmanSep 8, 2018
  2. Martin ÅgrenSep 8, 2018
  3. Stas BekmanSep 8, 2018
  4. Stas BekmanSep 8, 2018
  5. Ævar Arnfjörð BjarmasonSep 8, 2018
  6. Stas BekmanSep 8, 2018
  7. Ævar Arnfjörð BjarmasonSep 8, 2018
  8. Stas BekmanSep 8, 2018
  9. Paul SmithSep 9, 2018
  10. Stas BekmanSep 9, 2018
  11. Ævar Arnfjörð BjarmasonSep 8, 2018
  12. Stas BekmanSep 8, 2018
  13. Ævar Arnfjörð BjarmasonSep 8, 2018
  14. Jeff KingSep 8, 2018
  15. Ramsay JonesSep 8, 2018
  16. Jeff KingSep 9, 2018
  17. Junio C HamanoSep 11, 2018
  18. Jeff KingSep 11, 2018
  19. Stas BekmanSep 23, 2018
  20. Ævar Arnfjörð BjarmasonSep 24, 2018
  21. Stas BekmanSep 24, 2018
  22. 0/1 Re: git silently ignores include directive with single quotesPhilip Oakley, Sep 24, 2018
  23. Stas BekmanSep 24, 2018
  24. 1/1 config doc: highlight the name=value syntaxPhilip Oakley, Sep 24, 2018
  25. Junio C HamanoSep 25, 2018
  26. Ævar Arnfjörð BjarmasonSep 8, 2018
  27. Jeff KingSep 9, 2018
  28. Jeff KingSep 8, 2018
  29. Stas BekmanSep 8, 2018
  30. Jeff KingSep 9, 2018
  31. Junio C HamanoSep 10, 2018
  32. Jonathan NiederSep 10, 2018
  33. Junio C HamanoSep 10, 2018
  34. Jonathan NiederSep 10, 2018
  35. Junio C HamanoSep 10, 2018
  36. Stas BekmanSep 10, 2018
  37. Junio C HamanoSep 10, 2018

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.