Fattie
Fattie

Reputation: 12336

Is it correct that Subversion, but not Git, allows empty folders?

A vast amount of Googling, has, surprisingly, found no definitive reference stating that Subversion does 'allow empty folders'.

Extensive testing seems to show that Git does not allow empty folders, whereas, subversion does allow empty folders.

Can anyone provide a definitive answer or reference: if it is true that git does NOT allow empty folders.

Can anyone provide a definitive answer or reference: if it is true that Subversion does allow empty folders. (The Subversion book for example, actually says nothing, whatsoever, on the topic of empty folders, even though it would seem to be a major issue!)

Upvotes: 3

Views: 679

Answers (3)

jthill
jthill

Reputation: 60393

By the way, if you want empty folders created in your checkouts, you can cheese submodules to get them:

j8=00000001
git update-index --add --cacheinfo 160000,$j8$j8$j8$j8$j8,path/to/emptydir

where the j8 shenanigans is just an easy way of getting the right number of digits.The only important part is 40-digit id that isn't all zeros. Checkout creates an empty subdirectory to prep the location for it getting filled in by submodule cloning or however you're managing it.

Upvotes: -1

VonC
VonC

Reputation: 1326736

As I explained in this answer:

  • SVN is a REVISION system (it store files and directories as part of a revision, that is a "a state of the filesystem tree" (with files and directories), in order to compute deltas.
    (That means that, yes, empty directories are allowed, as they are needed for computing a delta against future revision).

revision in svn

  • Git is at its core a content tracker (originally built for managing the hundred of patches Linus Torvalds had to merge into his Linux tree).
    It only tracks content, as snapshots, in order to compare SHA1 representing said content (which is a very fast way of checking if two contents are identical or not).

git snapshot

Since an empty directory has no content, it isn't part of the snapshot.
Note that this is an implementation issue, not a fundamental git storage design problem.
See also the "Git Book" for more.

Upvotes: 6

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272657

From the Git Wiki:

Currently the design of the Git index (staging area) only permits files to be listed, and nobody competent enough to make the change to allow empty directories has cared enough about this situation to remedy it.

From the Subversion book:

svn add

Schedule files, directories, or symbolic links in your working copy for addition to the repository.

Upvotes: 3

Related Questions