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

Re: git silently ignores include directive with single quotes

From
Jeff King <peff@peff.net>
Date
Sep 8, 2018, 21:22 UTC
Message-ID
<20180908212256.GB31560@sigill.intra.peff.net>
In-Reply-To
<ca2b192e-1722-092e-2c54-d79d21a66ba2@stason.org>
On Sat, Sep 08, 2018 at 11:58:47AM -0700, Stas Bekman wrote:
> This doesn’t:
> 
> [include]
>         path = '../.gitconfig'

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
That would allow things like:
  [diff "foo"]
  textconv = some_shell_hackery 'with quotes' | foo
to continue working, but make:
  [some]
  path = 'this has "double quotes" in it!'

do what the user probably intended. It would be a regression for anybody who literally has a value that starts with a single-quote, but that seems like it would be pretty rare. Or I dunno, maybe people do it on Windows to try to protect path-names that get interpreted by the shell.

Show 6 quoted lines
> The original problem cropped up due to using:
> 
>  git config --local include.path '../.gitconfig'
> 
> which on linux stripped the single quotes, but on some windows git bash
> emulation it kept them.

That sounds like a bug in git bash, if it is not treating single quotes in the usual shell way. But I'd also expect such a bug to cause loads of problems in all of the shell scripts. Are you sure it wasn't cmd.exe or some other interpreter?

-Peff
Previous: Jeff KingNext: Stas Bekman
Message 28 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.