3

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!)

2
  • 2
    Point taken. Finding positive proof for it [folder-tracking in SVN] is not easy, mainly because anyone who has tried SVN or looked at a tutorial knows it's possible. Here's an easy trick: go into any SVN repository, create an empty folder and try to add it. If it works, SVN can add empty folders; if it doesn't, it can't. (This is called the 'try it and see' approach, and usually helps you remember stuff better than when someone else just tells you about it ;) ) Commented Oct 6, 2013 at 12:23
  • Hi @eis ... indeed, just to be clear. The whole point - the whole raison d'etre - of this question is that (surprisingly) there is no such reference -- seemingly anywhere -- regarding literally stating clearly the issue of whether or not subversion allows blank folders very surprisingly). the whole point of the question - as mentioned over and over and over was "After I googled for hours I surprisingly found nothing on this, can an expert give an opinion on the issue." Commented Oct 6, 2013 at 13:47

3 Answers 3

6

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.

Sign up to request clarification or add additional context in comments.

4 Comments

A curiosity for you @Von. You have stunningly explained why, indeed, subversion does, in fact, allow empty folders. So: re the question "I need an expert decisively answer: does subversion allow empty folders?" You have utterly provided that answer: "Yes." (Thanks!) However, just as a curiosity: It's somewhat bizarre that you can't find this info anywhere on the web. Since it's such a fundamental point, you'd think there'd be 100s of posts and doco. entries all over the place mentioning, "oh of course it's a basic that svn is OK with empty folders, whereas git has no empty folders." Odd!
@JoeBlow it is mostly because that is the way Revision Control has been done since the dawn of time (mainly RCS, back in 1982). But Linus wanted something fast (youtube.com/watch?v=4XpnKHJAok8&t=10m48s, but wait until 11'52). Content management, and local Content comparison through SHA1 is incredibly faster than any other centralized (ie having to get back to the server) solution.
an excellent point, thanks again Von. Now that you explain it, it's an interesting example of how version control generally has a lot of "assumptions" and so on - just as you say because it "was originally," if you will, a field with a lot of history. {For example, "young people today" as it were are just mystified by these concerns of being able to work locally with no bandwidth.} Cheers.
@JoeBlow yes, but that ability to work locally is not derived from a slow WAN. It stems from the fact that any remote access kills performance. And performance (as well a reliability) was what Linus was after.
3

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.

3 Comments

hey Oli - magnificent thanks for that, but when I stumbled across that while searching (the latter one), it is unclear if it means EMPTY directories. (For example: there are 1000s of references on the web saying "you can add directories to git" -- know what I mean? Thus, let's say that you CAN NOT add empty directories to subversion, then this sentence "Schedule files, directories, or symbolic links in your working copy for addition to the repository." is still totally correct, and indeed the command "svn add" would still exist and work (but you'd get an error after an empty directory).
@JoeBlow: The notion is that a directory is a first-class entity in SVN, unlike in Git. With some more Googling, I'm sure one could find a definitive source that addresses empty directories explicitly. But given that one can trivially set up an SVN repo and confirm this behaviour, I'm not sure it warrants it...
@JoeBlow: I wouldn't class myself as a "source control expert" ;) Merely someone who is quite familiar with using SVN (less so Git...)
-1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.