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

Re: [RFC] embedded TAB and LF in pathnames

From
Junio C Hamano <junkio@cox.net>
Date
Oct 8, 2005, 09:10 UTC
Message-ID
<7vachks7aq.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20051008064555.GA3831@steel.home>
Alex Riesen <raa.lkml@gmail.com> writes:
          Quote  nongraphic  characters in file names using alphabetic and
          octal backslash sequences like those used in C. This  option  is
          the  same as -Q except that filenames are not surrounded by dou-
          ble-quotes.

If you have a file whose name is 'foo' + LF + 'bar', and if you use backslash convention, your diff would start like this:

    diff --git a/foo\nbar b/foo\nbar
    @@ 1,2 3,4 @@
     context
    -deleted
    ...
which looks quite natural.

I would, however, prefer this kind of funny pathnames to *stand* *out* more than usual, to make it really obvious that there is something really funky going on. In that sense, the above is a bit too innocuous-looking to my taste.

But this "embedded LF and TAB" is a corner case. I would not be using such paths that would trigger the quoting myself anyway, and I do not particularly care as long as the tools do the right thing -- any quoting rule would do, as long as the generating side (git-diff) is consistent with accepting side (git-apply), and as long as there is no new ambiguity introduced.

The backslash proposal is introducing a small ambiguity. You cannot tell if the file had an embedded LF between 'foo' and 'bar' (and generated with your git-diff) or had an embedded backslash between 'foo' and 'nbar' (and generated with existing git-diff). Since we never had a version of git-diff that outputs double-slashes '//' in paths, there is no ambiguity if we use it as a quoting mechanism.

Just as a concrete demonstration, here is how the git-status output and git-diff output would look like for a file 'pqr' in a directory whose name is 'def' + LF + 'ghi' that uses the version of git-diff from the proposed updates branch:

        # Changed but not updated:
        #   (use git-update-index to mark for commit)
        #
        #	modified: def//{LF}//ghi/pqr
        diff --git a/def//{LF}//ghi/pqr b/def//{LF}//ghi/pqr
        index 9ee055c..47dbc3f 100644
        --- a/def//{LF}//ghi/pqr
        +++ b/def//{LF}//ghi/pqr
        @@ -1 +1,2 @@
         Fri Oct  7 23:19:04 PDT 2005
        +foo

I am not married to this quoting syntax -- I think it *is* ugly, but as I said before, I'd prefer to have something ugly here.

I would easily be persuaded otherwise, though. A working patch would probably be the most effective way of persuasion, but a mock output without the code to produce and/or parse it would also be fine as a starting point for discussion.

Previous: Alex RiesenNext: Robert Fitzsimons
Message 5 of 33 in “[RFC] embedded TAB and LF in pathnames”
  1. Junio C HamanoOct 7, 2005
  2. Alex RiesenOct 7, 2005
  3. Junio C HamanoOct 7, 2005
  4. Alex RiesenOct 8, 2005
  5. Junio C HamanoOct 8, 2005
  6. Try URI quoting for embedded TAB and LF in pathnamesRobert Fitzsimons, Oct 8, 2005
  7. Junio C HamanoOct 8, 2005
  8. Junio C HamanoOct 8, 2005
  9. Paul EggertOct 11, 2005
  10. Junio C HamanoOct 11, 2005
  11. Linus TorvaldsOct 11, 2005
  12. Paul EggertOct 11, 2005
  13. Linus TorvaldsOct 11, 2005
  14. Paul EggertOct 11, 2005
  15. Linus TorvaldsOct 11, 2005
  16. Paul EggertOct 12, 2005
  17. Linus TorvaldsOct 12, 2005
  18. Daniel BarkalowOct 12, 2005
  19. Linus TorvaldsOct 12, 2005
  20. H. Peter AnvinOct 12, 2005
  21. Junio C HamanoOct 9, 2005
  22. Junio C HamanoOct 12, 2005
  23. Linus TorvaldsOct 12, 2005
  24. H. Peter AnvinOct 12, 2005
  25. Johannes SchindelinOct 12, 2005
  26. Junio C HamanoOct 12, 2005
  27. Paul EggertOct 14, 2005
  28. Linus TorvaldsOct 14, 2005
  29. Linus TorvaldsOct 12, 2005
  30. Paul EggertOct 14, 2005
  31. Linus TorvaldsOct 14, 2005
  32. H. Peter AnvinOct 14, 2005
  33. Junio C HamanoOct 14, 2005

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.