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

git-fast-import doc problem and git-fast-export does not quote filenames correctly

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Sep 4, 2010, 06:17 UTC
Message-ID
<4C81E461.7010704@alum.mit.edu>
According to the git-fast-import manpage:
Show 16 quoted lines
> A `<path>` string must use UNIX-style directory separators (forward
> slash `/`), may contain any byte other than `LF`, and must not
> start with double quote (`"`).
> 
> If an `LF` or double quote must be encoded into `<path>` shell-style
> quoting should be used, e.g. `"path/with\n and \" in it"`.
> 
> The value of `<path>` must be in canonical form. That is it must not:
> 
> * contain an empty directory component (e.g. `foo//bar` is invalid),
> * end with a directory separator (e.g. `foo/` is invalid),
> * start with a directory separator (e.g. `/foo` is invalid),
> * contain the special component `.` or `..` (e.g. `foo/./bar` and
>   `foo/../bar` are invalid).
> 
> It is recommended that `<path>` always be encoded using UTF-8.

The first problem is that the doc seems to allow NUL bytes (which I suspect are not really allowed) or the backslash '\' character (which, if allowed, would logically have to be escaped, too).

The second problem is that "git fast-export" does not do even the specified quoting:

$ git init
Initialized empty Git repository in /home/mhagger/tmp/gitfoo/.git/
$ touch '"path with
 and " in it"'
$ git add -u
$ git commit -am 'Madness'
[master (root-commit) 2472bdb] Madness
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "\"path with\n and \" in it\""
$ git fast-export --all
blob
mark :1
data 0
reset refs/heads/master
commit refs/heads/master
mark :2
author Michael Haggerty <mhagger@michael.localdomain> 1283580642 +0200
committer Michael Haggerty <mhagger@michael.localdomain> 1283580642 +0200
data 8
Madness
M 100644 :1 "path with
 and " in it"

reset refs/heads/master from :2

Michael
Next: Sverre Rabbelier
Message 1 of 3 in “git-fast-import doc problem and git-fast-export does not quote filenames correctly”
  1. Michael HaggertySep 4, 2010
  2. Sverre RabbelierSep 4, 2010
  3. Michael HaggertySep 4, 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.