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

From: Jakub Narebski <[email-masked]>
Date: Sun, 22 Jul 2007 03:16:47 +0200

David Kastrup wrote:

> Linus Torvalds <[email-masked]> writes:
> 
>> On Sat, 21 Jul 2007, David Kastrup wrote:

>>> Linus, a directory is simply non-existent inside of git.
>>
>> You need to learn git first.
>>
>> A directory doesn't exist IN THE INDEX (until my patches). But you
>> need to learn about the object database and the SHA1's. That's the
>> real meat of git, and it sure as hell knows about directories.
> 
> I have written up a complete explanation about the underlying concept
> in a separate thread, maybe it would make sense reading that before
> investing too much time meddling over details that don't fit the large
> picture.  The point is that the object database and the SHA1 values
> track _trees_, not _directories_.  And a _tree_ is just a hashing
> mechanism in the repository for files.  Its existence is solely
> dependent on the existence of its contents.  The only synchronization
> with directories is that when a tree becomes empty, git attempts to do
> an rmdir on the corresponding directory.  And of course, if git needs
> to check out a file, it creates the necessary parent directories.
> 
> Now since the physical _contents_ of a directory are already tracked
> in _trees_ by git, the only missing part is the _existence_ of the
> directory itself: a directory must exist as long as there is a tree
> (and thus content) connected with it, but the reverse does not hold:
> without a tree, the directory can still exist.  Which we can represent
> by a repository entry named "." without content (the content is
> already catered for by the _tree_).  This must _not_ be represented by
> a _tree_ node since there is no content, and a tree without content by
> _definition_ does not exist.
> 
> I must be really bad at explaining things, or I am losing a fight
> against preconceptions fixed beyond my imagination.

I don't understand you, or you don't understand git. "Tree" object
in object database (in repository) represents a directory in the
working area. There was never any problem with having empty trees
in object database, or having links to empty directory in the superdir.
We don't have to change anything about object database.

The problems with git problems with empty directories stems from the
fact that index didn't have directories. Index is flattened version
of root tree, and before subproject support it contained _only_ info
about blobs (file contents). At least till Linus patch...
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git