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

Filename quoting / parsing problem

From
AGAndreas Gruenbacher <agruen@suse.de>
Date
Jan 1, 2010, 17:44 UTC
Message-ID
<201001011844.23571.agruen@suse.de>
Git quotes file names as documented in the git-diff manual page:
  TAB, LF, double quote and backslash characters in pathnames are represented
  as \t, \n, \" and \\, respectively.  If there is need for such substitution
  then the whole pathname is put in double quotes.

Spaces in file names currently do not trigger quoting. (And \r triggers quoting even though the man page doesn't say so). When there are no "---" and "+++" lines, this can lead to a parsing problem: only the "diff --git" line contains the file names, sometimes with insufficient quoting. The following examples show the problem:

Parseable:
    diff --git "a/foo \r" "b/foo \r"
    new file mode 100644
    index 0000000..257cc56
    --- /dev/null
    +++ "b/foo \r"
    @@ -0,0 +1 @@
   +foo
Parseable:
    diff --git a/bar  b/bar 
    new file mode 100644
    index 0000000..5716ca5
    --- /dev/null
    +++ b/bar 
    @@ -0,0 +1 @@
    +bar
Not parseable:
    diff --git a/baz  b/baz 
    new file mode 100644
    index 0000000..e69de29

Could this please be changed so that filenames with spaces are also quoted, at least in the "diff --git" line, and possibly also in the "---" and "+++" lines? Alternatively, how about a new extended header with the file name in this particular case?

Thanks, Andreas

Next: Junio C Hamano
Message 1 of 10 in “Filename quoting / parsing problem”
  1. Andreas GruenbacherJan 1, 2010
  2. Junio C HamanoJan 1, 2010
  3. Junio C HamanoJan 1, 2010
  4. Andreas GruenbacherJan 2, 2010
  5. Junio C HamanoJan 2, 2010
  6. Andreas GruenbacherJan 2, 2010
  7. Andreas GruenbacherJan 6, 2010
  8. Junio C HamanoJan 6, 2010
  9. Junio C HamanoJan 6, 2010
  10. Andreas SchwabJan 6, 2010

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.