{"thread":{"id":"24966","subject":"git-fast-import doc problem and git-fast-export does not quote filenames correctly","startedAt":"2010-09-04T06:17:05Z","lastAt":"2010-09-04T19:48:58Z","messageCount":3,"participants":["Michael Haggerty","Sverre Rabbelier"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"149821","messageId":"4C81E461.7010704@alum.mit.edu","threadId":"24966","inReplyTo":null,"subject":"git-fast-import doc problem and git-fast-export does not quote filenames correctly","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2010-09-04T06:17:05Z","receivedAt":"2010-09-04T06:17:05Z","isPatch":false,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"According to the git-fast-import manpage:\n\n> A `<path>` string must use UNIX-style directory separators (forward\n> slash `/`), may contain any byte other than `LF`, and must not\n> start with double quote (`\"`).\n> \n> If an `LF` or double quote must be encoded into `<path>` shell-style\n> quoting should be used, e.g. `\"path/with\\n and \\\" in it\"`.\n> \n> The value of `<path>` must be in canonical form. That is it must not:\n> \n> * contain an empty directory component (e.g. `foo//bar` is invalid),\n> * end with a directory separator (e.g. `foo/` is invalid),\n> * start with a directory separator (e.g. `/foo` is invalid),\n> * contain the special component `.` or `..` (e.g. `foo/./bar` and\n>   `foo/../bar` are invalid).\n> \n> It is recommended that `<path>` always be encoded using UTF-8.\n\nThe first problem is that the doc seems to allow NUL bytes (which I\nsuspect are not really allowed) or the backslash '\\' character (which,\nif allowed, would logically have to be escaped, too).\n\nThe second problem is that \"git fast-export\" does not do even the\nspecified quoting:\n\n$ git init\nInitialized empty Git repository in /home/mhagger/tmp/gitfoo/.git/\n$ touch '\"path with\n and \" in it\"'\n$ git add -u\n$ git commit -am 'Madness'\n[master (root-commit) 2472bdb] Madness\n 0 files changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 \"\\\"path with\\n and \\\" in it\\\"\"\n$ git fast-export --all\nblob\nmark :1\ndata 0\n\nreset refs/heads/master\ncommit refs/heads/master\nmark :2\nauthor Michael Haggerty <mhagger@michael.localdomain> 1283580642 +0200\ncommitter Michael Haggerty <mhagger@michael.localdomain> 1283580642 +0200\ndata 8\nMadness\nM 100644 :1 \"path with\n and \" in it\"\n\nreset refs/heads/master\nfrom :2\n\nMichael\n"},{"id":"149855","messageId":"AANLkTimsVQ=mg2EUhUEO5ZWQMZoA72B=p2+1ZA=1qBtn@mail.gmail.com","threadId":"24966","inReplyTo":"4C81E461.7010704@alum.mit.edu","subject":"Re: git-fast-import doc problem and git-fast-export does not quote filenames correctly","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-09-04T16:48:50Z","receivedAt":"2010-09-04T16:48:50Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"On Sat, Sep 4, 2010 at 01:17, Michael Haggerty <mhagger@alum.mit.edu> wrote:\n> The first problem is that the doc seems to allow NUL bytes (which I\n> suspect are not really allowed)\n\nFast import keeps reading until it finds a '\\n' and stores data in a\nstrbuf, so I don't see why 'NUL' would not be allowed.\n\n> or the backslash '\\' character (which,\n> if allowed, would logically have to be escaped, too).\n\nBackslashes are allowed, and it seems they need to be escaped as\nusual. Perhaps Shawn can confirm that this should just be updated in\nthe docs.\n\n> The second problem is that \"git fast-export\" does not do even the\n> specified quoting:\n\nThat's a bug with fast-export then :)\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"149861","messageId":"4C82A2AA.3010408@alum.mit.edu","threadId":"24966","inReplyTo":"AANLkTimsVQ=mg2EUhUEO5ZWQMZoA72B=p2+1ZA=1qBtn@mail.gmail.com","subject":"Re: git-fast-import doc problem and git-fast-export does not quote filenames correctly","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2010-09-04T19:48:58Z","receivedAt":"2010-09-04T19:48:58Z","isPatch":false,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"Sverre Rabbelier wrote:\n> On Sat, Sep 4, 2010 at 01:17, Michael Haggerty <mhagger@alum.mit.edu> wrote:\n>> The first problem is that the doc seems to allow NUL bytes (which I\n>> suspect are not really allowed)\n> \n> Fast import keeps reading until it finds a '\\n' and stores data in a\n> strbuf, so I don't see why 'NUL' would not be allowed.\n\nI guess I just found it hard to believe that git, with all of its\nscripts, would really be able to handle NUL characters in filenames.\nMoreover, even if git allows it, I think NUL is prohibited in posix\nfilenames, so it would be pretty pointless.\n\nIn the end, I asked this question to help figure out what filenames\n\"cvs2git\" should allow through to git.  A NUL character could only get\ninto a CVS filename if the user writes some strange code to transform\nthe filename, so I guess I don't mind letting it through to git if there\nis some chance that git can handle it.\n\n> [...] Backslashes are allowed, and it seems they need to be escaped as\n> usual. Perhaps Shawn can confirm that this should just be updated in\n> the docs.\n\nThanks for the info!  Assuming that Shawn doesn't contradict you, I will\nlet any characters through and quote characters as you suggest.\n\nMichael\n"}]}