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

Re: git silently ignores include directive with single quotes

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 10, 2018, 19:17 UTC
Message-ID
<xmqq1sa1tb4p.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180910183557.GD26356@aiede.svl.corp.google.com>
Jonathan Nieder <jrnieder@gmail.com> writes:
Show 10 quoted lines
> Updated proposal:
>
>   1. Treat strings starting or ending with single-quote as worth
>      quoting in config.c::write_pair (line 3269).  This would already
>      help with the original issue, since the config would say
>
> 	[foo]
> 		bar = "'baz'"
>
>      allowing a quick diagnosis.

This does not change anything essential from Git's point of view since the previous round.

But I changed my mind anyway ;-) Earlier I said "if we do not intend to make sq special, we shouldn't do #1", and it still is a good direction to go.

But making sq special does not have to be making sq a character that quotes. A character (or a character sequence) that is *not* quoting can still be special---for example, we can say certain character or a character sequence *must* be quoted, and make sq such a character.

That is, even if we stop at your step 3. or step 2., and did not go to step 4. (which I think is a bad idea for little gain), we are already treating sq as a special character, and step 1. above is a reasonable way to start the transition to that better world.

The reason why it is a better world that have "must be quoted, even though they are not quoting characters themselves" is solely because that would avoid confusion for those who are not familiar with the file format, even when we stop at step #2. In addition to a single quote a the beginning of the value, I think two or more SP deserve to be such a "must be quoted" sequence, i.e. instead of producing this result, which we see with today's Git:

	$ git config a.test0 "'foo"
	$ git config a.test1 "foo  bar" ;# two spaces
	$ grep -A2 '\[a\]' config
	[a]
		test0 = 'foo
		test1 = foo  bar
we'd produce
	$ grep -A2 '\[a\]' config
	[a]
		test0 = "'foo"
		test1 = "foo  bar"

but we can still interpret what we have historically written the same way.

I do not know if step #3 is a good idea, and I do not think step #2 is particularly a good stopping point. Step #1 is probably slightly a better stopping point if the aim is to avoid user confusion than step #2.

Show 15 quoted lines
>   2. (optional) Warn if a value is surrounded in single-quotes,
>      encouraging using surrounding double-quotes to disambiguate.
>
>   3. (optional) Error out if a value is surrounded in single-quotes,
>      encouraging replacing with or surrounding with double-quote,
>      depending on the user's intention.
>
>   4. (optional) Start treating wrapping single-quotes specially
>      somehow.
>
> As before, I think step 1 is a good idea, but I'm not convinced about
> any of the later steps.
>
> Thanks,
> Jonathan
Previous: Jonathan NiederNext: Stas Bekman
Message 35 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.