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

Re: [RFC PATCH] Re: Empty directories...

From
David Kastrup <dak@gnu.org>
Date
Jul 20, 2007, 10:11 UTC
Message-ID
<86k5svwfj4.fsf@lola.quinscape.zz>
In-Reply-To
<46A08006.4020500@fs.ei.tum.de>
Simon 'corecode' Schubert <corecode@fs.ei.tum.de> writes:
Show 13 quoted lines
> David Kastrup wrote:
>>> Otherwise you could have two very different trees that encode the
>>> same *content* (just with different ways of getting there -
>>> depending on whether you have a history with empty trees or not),
>>> and that's very much against the philosophy of git, and breaks some
>>> fundamental rules (like the fact that "same content == same SHA1").
>>
>> No, the content is _different_.  One tree contains a tracked
>> directory, the other does not.  That means that the trees behave
>> _differently_ when you manipulate them, and that means that they are
>> _not_ the same tree.
>
> You are mistaking things.

No, I am redefining them, or rather the view on them. Subtle difference.

> Like the executable bit on a file is not content, the fact that a
> directory should be kept despite being empty is also an *attribute*
> of the directory.  This is meta-data, not actual data (content).

We need to track it, anyway. So there is little point in not using the existing infrastructure for handling named entities.

> So no matter how elegant tracking the "." entry might be (and I
> think it is, because it covers a lot of corner cases already), it
> puts the information at the wrong place.

I don't see that the place is wrong: after all, that is where Unix places "." too, and for good reason. I was arguing for _separating_ the concept of "directory" and "tree" in the repository. The tree is a container entity defined exclusively by its contents (which determine its hash). That is how git already does things. There is _no_ connection with the physical existence of a directory: in the work directory, git creates and deletes directories as a _side-effect_ of storing and removing trees. But git itself does not track directories as a physical entity at _all_. If you had a flat filesystem allowing slashes in filenames, git would get along better than it does now, without ever creating or removing a directory. Trees are just a convenient selection and pattern matching mechanism for files as far as git is concerned. The correspondence to physical directories in the work directory is a nuisance rather than an asset as far as git is concerned.

In a recent thread here, tags with slashes were supported by essentially doing

    mkdir -p "`dirname $TAG`"
    touch $TAG

where directory creation is just a side effect of supporting slashes. And that, if you look closely, is git's current relation with directories altogether. The directories in the work file system are created by git just as a side effect for representing slashes, which in turn facilitate a certain manner of pattern matching.

And "." seems perfectly well suited to bring across the point that there actually is _physical_ existence associated with a directory, existence that remains when the rest of the tree is gone and _makes_ a difference to what the tree is, because it has a _different_ representation in the work file system.

Storing it as an _attribute_ of the tree is a bad idea, since then the simple rule "a tree without contents is empty" needs an exception. And a tree stops becoming just a container of its contents and all sort of new exceptions creep up.

There are some systems where the difference between directory as a file and directory as a structuring method are more apparent than under Unix (some utilities like rsync differentiate between A/B and A/B/ to bring across that difference).

Here is an example for some Emacs function concerned with the concept:
    directory-file-name is a built-in function in `C source code'.
    (directory-file-name DIRECTORY)
    Returns the file name of the directory named DIRECTORY.
    This is the name of the file that holds the data for the directory DIRECTORY.
    This operation exists because a directory is also a file, but its name as
    a directory is different from its name as a file.
    In Unix-syntax, this function just removes the final slash.
    On VMS, given a VMS-syntax directory name such as "[X.Y]",
    it returns a file name such as "[X]Y.DIR.1".
    [back]
> That's sad, because otherwise it would be really elegant.

If something is not elegant because of the angle of view, change the view. And it is not like the different angle has no predecessors or no consistency.

-- 
David Kastrup
Previous: Simon 'corecode' SchubertNext: Junio C Hamano
Message 121 of 137 in “Empty directories...”
  1. David KastrupJul 18, 2007
  2. Johannes SchindelinJul 18, 2007
  3. David KastrupJul 18, 2007
  4. Johannes SchindelinJul 18, 2007
  5. Linus TorvaldsJul 18, 2007
  6. Linus TorvaldsJul 18, 2007
  7. David KastrupJul 18, 2007
  8. Linus TorvaldsJul 18, 2007
  9. Matthieu MoyJul 18, 2007
  10. Linus TorvaldsJul 18, 2007
  11. David KastrupJul 18, 2007
  12. Linus TorvaldsJul 18, 2007
  13. David KastrupJul 18, 2007
  14. Re: Empty directories...Linus Torvalds, Jul 18, 2007
  15. Linus TorvaldsJul 18, 2007
  16. David KastrupJul 18, 2007
  17. Linus TorvaldsJul 19, 2007
  18. Junio C HamanoJul 19, 2007
  19. Shawn O. PearceJul 19, 2007
  20. David KastrupJul 19, 2007
  21. Geoff RussellJul 19, 2007
  22. Shawn O. PearceJul 19, 2007
  23. Matthieu MoyJul 19, 2007
  24. Tomash BrechkoJul 19, 2007
  25. David KastrupJul 19, 2007
  26. Tomash BrechkoJul 19, 2007
  27. David KastrupJul 19, 2007
  28. NixJul 23, 2007
  29. David KastrupJul 23, 2007
  30. NixJul 23, 2007
  31. NixJul 23, 2007
  32. Jakub NarebskiJul 23, 2007
  33. NixJul 25, 2007
  34. David KastrupJul 23, 2007
  35. Linus TorvaldsJul 23, 2007
  36. NixJul 23, 2007
  37. Linus TorvaldsJul 23, 2007
  38. David KastrupJul 19, 2007
  39. David KastrupJul 19, 2007
  40. Johannes SchindelinJul 19, 2007
  41. David KastrupJul 19, 2007
  42. Brian GernhardtJul 19, 2007
  43. Johannes SchindelinJul 19, 2007
  44. Brian GernhardtJul 19, 2007
  45. Johannes SchindelinJul 19, 2007
  46. David KastrupJul 19, 2007
  47. Brian GernhardtJul 19, 2007
  48. Johannes SchindelinJul 19, 2007
  49. David KastrupJul 19, 2007
  50. Matthieu MoyJul 19, 2007
  51. David KastrupJul 19, 2007
  52. David KastrupJul 19, 2007
  53. David KastrupJul 19, 2007
  54. David KastrupJul 21, 2007
  55. Linus TorvaldsJul 21, 2007
  56. Linus TorvaldsJul 21, 2007
  57. David KastrupJul 21, 2007
  58. Linus TorvaldsJul 21, 2007
  59. David KastrupJul 21, 2007
  60. Simon 'corecode' SchubertJul 21, 2007
  61. David KastrupJul 21, 2007
  62. Linus TorvaldsJul 21, 2007
  63. David KastrupJul 22, 2007
  64. Linus TorvaldsJul 22, 2007
  65. David KastrupJul 22, 2007
  66. Linus TorvaldsJul 22, 2007
  67. David KastrupJul 22, 2007
  68. Linus TorvaldsJul 22, 2007
  69. David KastrupJul 22, 2007
  70. david@lang.hmJul 22, 2007
  71. David KastrupJul 22, 2007
  72. Linus TorvaldsJul 22, 2007
  73. David KastrupJul 22, 2007
  74. Linus TorvaldsJul 22, 2007
  75. Linus TorvaldsJul 22, 2007
  76. David KastrupJul 22, 2007
  77. Jakub NarebskiJul 22, 2007
  78. David KastrupJul 22, 2007
  79. Jakub NarebskiJul 22, 2007
  80. David KastrupJul 22, 2007
  81. Jakub NarebskiJul 22, 2007
  82. David KastrupJul 22, 2007
  83. David KastrupJul 23, 2007
  84. David KastrupJul 23, 2007
  85. David KastrupJul 22, 2007
  86. Brian GernhardtJul 22, 2007
  87. David KastrupJul 28, 2007
  88. David KastrupJul 18, 2007
  89. Matthieu MoyJul 18, 2007
  90. David KastrupJul 18, 2007
  91. Shawn O. PearceJul 18, 2007
  92. Junio C HamanoJul 18, 2007
  93. David KastrupJul 18, 2007
  94. Wincent ColaiutaJul 18, 2007
  95. Junio C HamanoJul 18, 2007
  96. Johan HerlandJul 20, 2007
  97. David KastrupJul 20, 2007
  98. Johan HerlandJul 20, 2007
  99. David KastrupJul 20, 2007
  100. Johan HerlandJul 20, 2007
  101. David KastrupJul 22, 2007
  102. Robin RosenbergJul 26, 2007
  103. David KastrupJul 27, 2007
  104. Johannes SchindelinJul 18, 2007
  105. Matthieu MoyJul 18, 2007
  106. David KastrupJul 18, 2007
  107. Junio C HamanoJul 18, 2007
  108. Brian GernhardtJul 19, 2007
  109. David KastrupJul 19, 2007
  110. Brian GernhardtJul 19, 2007
  111. Junio C HamanoJul 20, 2007
  112. Linus TorvaldsJul 20, 2007
  113. Linus TorvaldsJul 20, 2007
  114. Junio C HamanoJul 20, 2007
  115. Linus TorvaldsJul 20, 2007
  116. David KastrupJul 20, 2007
  117. David KastrupJul 20, 2007
  118. Linus TorvaldsJul 20, 2007
  119. David KastrupJul 20, 2007
  120. Simon 'corecode' SchubertJul 20, 2007
  121. David KastrupJul 20, 2007
  122. Junio C HamanoJul 20, 2007
  123. David KastrupJul 20, 2007
  124. Linus TorvaldsJul 20, 2007
  125. Johan HerlandJul 20, 2007
  126. Linus TorvaldsJul 20, 2007
  127. Julian PhillipsJul 20, 2007
  128. Linus TorvaldsJul 21, 2007
  129. David KastrupJul 21, 2007
  130. David KastrupJul 21, 2007
  131. David KastrupJul 20, 2007
  132. Olivier GalibertJul 20, 2007
  133. Johan HerlandJul 20, 2007
  134. David KastrupJul 20, 2007
  135. David KastrupJul 21, 2007
  136. David KastrupJul 22, 2007
  137. NixJul 24, 2007

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.