{"thread":{"id":"36369","subject":"Handling empty directories in Git","startedAt":"2014-04-08T14:47:22Z","lastAt":"2014-04-11T12:34:10Z","messageCount":9,"participants":["Olivier LE ROY","Andrew Keller","Matthieu Moy","David Kastrup","Øyvind A. Holm"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"238534","messageId":"1396968442.95061.YahooMailNeo@web120806.mail.ne1.yahoo.com","threadId":"36369","inReplyTo":null,"subject":"Handling empty directories in Git","fromName":"Olivier LE ROY","fromEmail":"olivier_le_roy@yahoo.com","sentAt":"2014-04-08T14:47:22Z","receivedAt":"2014-04-08T14:47:22Z","isPatch":false,"sender":{"key":"olivier_le_roy@yahoo.com","avatar":null},"body":"Hello, \n\nI have a project under SVN with contains empty directories.\n\nI would like to move this project on a Git server, still handling empty directories.\n\nThe solution: put a .gitignore file in each empty directory to have them recognized by the Git database cannot work, because some scripts in my projects test the actual emptiness of the directories.\n\nIs there any expert able to tell me: this cannot be done in Git, or this can be done by the following trick, or why there is no valuable reason to maintain empty directories under version control?\n\nRegards,\n\nOlivier LE ROY\nFrance\n"},{"id":"238539","messageId":"3FBDE5D3-1DC6-420C-866B-036D0CB17BA2@kellerfarm.com","threadId":"36369","inReplyTo":"1396968442.95061.YahooMailNeo@web120806.mail.ne1.yahoo.com","subject":"Re: Handling empty directories in Git","fromName":"Andrew Keller","fromEmail":"andrew@kellerfarm.com","sentAt":"2014-04-08T17:02:51Z","receivedAt":"2014-04-08T17:02:51Z","isPatch":false,"sender":{"key":"andrew@kellerfarm.com","avatar":"https://avatars.githubusercontent.com/u/304204?v=4"},"body":"On Apr 8, 2014, at 10:47 AM, Olivier LE ROY <olivier_le_roy@yahoo.com> wrote:\n\n> Hello, \n> \n> I have a project under SVN with contains empty directories.\n> \n> I would like to move this project on a Git server, still handling empty directories.\n> \n> The solution: put a .gitignore file in each empty directory to have them recognized by the Git database cannot work, because some scripts in my projects test the actual emptiness of the directories.\n> \n> Is there any expert able to tell me: this cannot be done in Git, or this can be done by the following trick, or why there is no valuable reason to maintain empty directories under version control?\n\nGit is designed to track files.  The existence of folders is secondary to the notion that files have a relative path inside the repository, which is perceived by the user as folders.\n\nWhy can't your scripts create the folders on demand?  Or, could your scripts interpret a missing folder as an empty folder?\n\nThanks,\nAndrew Keller\n"},{"id":"238540","messageId":"vpqob0blpna.fsf@anie.imag.fr","threadId":"36369","inReplyTo":"1396968442.95061.YahooMailNeo@web120806.mail.ne1.yahoo.com","subject":"Re: Handling empty directories in Git","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2014-04-08T17:03:37Z","receivedAt":"2014-04-08T17:03:37Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Olivier LE ROY <olivier_le_roy@yahoo.com> writes:\n\n> The solution: put a .gitignore file in each empty directory to have them recognized by the Git database cannot work, because some scripts in my projects test the actual emptiness of the directories.\n\nAnother option is to have a post-checkout hook that does the mkdir for\nyou. Or do that in the build system if your use case is to store\nuntracked generated files in the directory.\n\n> Is there any expert able to tell me: this cannot be done in Git, or\n> this can be done by the following trick,\n\nhttps://git.wiki.kernel.org/index.php/Git_FAQ#Can_I_add_empty_directories.3F\n\nShort answer: it cannot be done.\n\n> or why there is no valuable reason to maintain empty directories under\n> version control?\n\nThe reason would be closer to \"there is a valuable reason, but not\nvaluable enough to change Git to do it\". It's actually not so easy to\ntrack directories properly. Storing them in the Git repository is\nactually possible (actually, an empty tree is a special case of this,\nand is obviously supported), but defining and implementing a decent\nbehavior for each Git command wrt this is not trivial.\n\nDavid Kastrup gave it a try a few years ago. I don't remember exactly\nwhat made him give up, but it was never completed and merged.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"238543","messageId":"AE92C2A5-4EFE-454C-8D61-804AEE72D955@kellerfarm.com","threadId":"36369","inReplyTo":"3FBDE5D3-1DC6-420C-866B-036D0CB17BA2@kellerfarm.com","subject":"Re: Handling empty directories in Git","fromName":"Andrew Keller","fromEmail":"andrew@kellerfarm.com","sentAt":"2014-04-08T17:20:02Z","receivedAt":"2014-04-08T17:20:02Z","isPatch":false,"sender":{"key":"andrew@kellerfarm.com","avatar":"https://avatars.githubusercontent.com/u/304204?v=4"},"body":"On Apr 8, 2014, at 1:02 PM, Andrew Keller <andrew@kellerfarm.com> wrote:\n\n> On Apr 8, 2014, at 10:47 AM, Olivier LE ROY <olivier_le_roy@yahoo.com> wrote:\n> \n>> Hello, \n>> \n>> I have a project under SVN with contains empty directories.\n>> \n>> I would like to move this project on a Git server, still handling empty directories.\n>> \n>> The solution: put a .gitignore file in each empty directory to have them recognized by the Git database cannot work, because some scripts in my projects test the actual emptiness of the directories.\n>> \n>> Is there any expert able to tell me: this cannot be done in Git, or this can be done by the following trick, or why there is no valuable reason to maintain empty directories under version control?\n> \n> Git is designed to track files.  The existence of folders is secondary to the notion that files have a relative path inside the repository, which is perceived by the user as folders.\n\nTo clarify: That's Git's \"personality\" from the point of view of the front end, and is not the same as how data is actually stored.\n\nThanks,\nAndrew Keller\n"},{"id":"238544","messageId":"87zjjvg1v1.fsf@fencepost.gnu.org","threadId":"36369","inReplyTo":"vpqob0blpna.fsf@anie.imag.fr","subject":"Re: Handling empty directories in Git","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2014-04-08T17:36:18Z","receivedAt":"2014-04-08T17:36:18Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> The reason would be closer to \"there is a valuable reason, but not\n> valuable enough to change Git to do it\". It's actually not so easy to\n> track directories properly. Storing them in the Git repository is\n> actually possible (actually, an empty tree is a special case of this,\n> and is obviously supported), but defining and implementing a decent\n> behavior for each Git command wrt this is not trivial.\n>\n> David Kastrup gave it a try a few years ago. I don't remember exactly\n> what made him give up, but it was never completed and merged.\n\nOh, most likely what afflicts most of my unfinished projects.  I lost\nfocus at some point of time.  I don't remember any fundamentally\nunsolvable problems, but then I don't remember much at all.  There were\nsome annoyances with sorting order (either regarding the sorting of xxx/\nor . or ./ or whatever) and some other stuff.\n\nIf anybody wants to take a look at the direction of unfinished stuff,\nI can see whether there are some old backups with git repos in my\npossession.  But I really have no idea how much of the design might have\nended up in actual comments or code, and how much on some scraps of\npaper or half-committed memory, and how much of that might have been\ninvalidated by other scraps of paper and half-committed memory.\n\nSo there is not likely to be more than food for thought recoverable.\n\nI'm amused that you remember me being involved with that.  I think\nI myself had forgotten all about it until recently.  I don't even\nrecollect what made me remember again: looking at some old repo/commit\nor searching in some old mailing list archive.\n\n-- \nDavid Kastrup\n"},{"id":"238545","messageId":"1396979249.39960.YahooMailNeo@web120805.mail.ne1.yahoo.com","threadId":"36369","inReplyTo":"3FBDE5D3-1DC6-420C-866B-036D0CB17BA2@kellerfarm.com","subject":"Re: Handling empty directories in Git","fromName":"Olivier LE ROY","fromEmail":"olivier_le_roy@yahoo.com","sentAt":"2014-04-08T17:47:29Z","receivedAt":"2014-04-08T17:47:29Z","isPatch":false,"sender":{"key":"olivier_le_roy@yahoo.com","avatar":null},"body":"\n\nHello Andrew,\n\nyes that is possible to have scripts create the missing directories.\n\nThe reason I asked this is people at my work want to avoid the hassle of having to create a script for that. They want to checkout seamlessly as they used to do with subversion.\n\nI guess it is similar as programming in Java and programming in plain old C.\n\n\nOlivier LE ROY \n\n________________________________\nDe : Andrew Keller <andrew@kellerfarm.com>\nÀ : Olivier LE ROY <olivier_le_roy@yahoo.com> \nCc : \"git@vger.kernel.org\" <git@vger.kernel.org> \nEnvoyé le : Mardi 8 avril 2014 17h02\nObjet : Re: Handling empty directories in Git\n\n\nOn Apr 8, 2014, at 10:47 AM, Olivier LE ROY <olivier_le_roy@yahoo.com> wrote:\n\n\n> Hello, \n> \n> I have a project under SVN with contains empty directories.\n> \n> I would like to move this project on a Git server, still handling empty directories.\n> \n> The solution: put a .gitignore file in each empty directory to have them recognized by the Git database cannot work, because some scripts in my projects test the actual emptiness of the directories.\n> \n> Is there any expert able to tell me: this cannot be done in Git, or this can be done by the following trick, or why there is no valuable reason to maintain empty directories under version control?\n\nGit is designed to track files.  The existence of folders is secondary to the notion that files have a relative path inside the repository, which is perceived by the user as folders.\n\nWhy can't your scripts create the folders on demand?  Or, could your scripts interpret a missing folder as an empty folder?\n\nThanks,\nAndrew Keller\n"},{"id":"238546","messageId":"1396980369.49724.YahooMailNeo@web120801.mail.ne1.yahoo.com","threadId":"36369","inReplyTo":"vpqob0blpna.fsf@anie.imag.fr","subject":"Re: Handling empty directories in Git","fromName":"Olivier LE ROY","fromEmail":"olivier_le_roy@yahoo.com","sentAt":"2014-04-08T18:06:09Z","receivedAt":"2014-04-08T18:06:09Z","isPatch":false,"sender":{"key":"olivier_le_roy@yahoo.com","avatar":null},"body":"Hi Mattieu,\n\nthanks for this answer. It is clear enough.\n\nOlivier LE ROY\n\n\n\n\n----- Mail original -----\nDe : Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>\nÀ : Olivier LE ROY <olivier_le_roy@yahoo.com>\nCc : \"git@vger.kernel.org\" <git@vger.kernel.org>\nEnvoyé le : Mardi 8 avril 2014 17h03\nObjet : Re: Handling empty directories in Git\n\nOlivier LE ROY <olivier_le_roy@yahoo.com> writes:\n\n> The solution: put a .gitignore file in each empty directory to have them recognized by the Git database cannot work, because some scripts in my projects test the actual emptiness of the directories.\n\nAnother option is to have a post-checkout hook that does the mkdir for\nyou. Or do that in the build system if your use case is to store\nuntracked generated files in the directory.\n\n> Is there any expert able to tell me: this cannot be done in Git, or\n> this can be done by the following trick,\n\nhttps://git.wiki.kernel.org/index.php/Git_FAQ#Can_I_add_empty_directories.3F\n\nShort answer: it cannot be done.\n\n\n> or why there is no valuable reason to maintain empty directories under\n> version control?\n\nThe reason would be closer to \"there is a valuable reason, but not\nvaluable enough to change Git to do it\". It's actually not so easy to\ntrack directories properly. Storing them in the Git repository is\nactually possible (actually, an empty tree is a special case of this,\nand is obviously supported), but defining and implementing a decent\nbehavior for each Git command wrt this is not trivial.\n\nDavid Kastrup gave it a try a few years ago. I don't remember exactly\nwhat made him give up, but it was never completed and merged.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"238550","messageId":"1396982365.73812.YahooMailNeo@web120805.mail.ne1.yahoo.com","threadId":"36369","inReplyTo":"87zjjvg1v1.fsf@fencepost.gnu.org","subject":"Re: Handling empty directories in Git","fromName":"Olivier LE ROY","fromEmail":"olivier_le_roy@yahoo.com","sentAt":"2014-04-08T18:39:25Z","receivedAt":"2014-04-08T18:39:25Z","isPatch":false,"sender":{"key":"olivier_le_roy@yahoo.com","avatar":null},"body":"Hi David,\n\nthanks for the whole story. We understand why the empty directories handling was never completed, and how it could be, if one developer submited patches for that.\n\nRegards,\n\nOlivier LE ROY\n\n\n\n----- Mail original -----\nDe : David Kastrup <dak@gnu.org>\nÀ : Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>\nCc : Olivier LE ROY <olivier_le_roy@yahoo.com>; \"git@vger.kernel.org\" <git@vger.kernel.org>\nEnvoyé le : Mardi 8 avril 2014 17h36\nObjet : Re: Handling empty directories in Git\n\nMatthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> The reason would be closer to \"there is a valuable reason, but not\n> valuable enough to change Git to do it\". It's actually not so easy to\n> track directories properly. Storing them in the Git repository is\n> actually possible (actually, an empty tree is a special case of this,\n> and is obviously supported), but defining and implementing a decent\n> behavior for each Git command wrt this is not trivial.\n>\n> David Kastrup gave it a try a few years ago. I don't remember exactly\n> what made him give up, but it was never completed and merged.\n\nOh, most likely what afflicts most of my unfinished projects.  I lost\nfocus at some point of time.  I don't remember any fundamentally\nunsolvable problems, but then I don't remember much at all.  There were\nsome annoyances with sorting order (either regarding the sorting of xxx/\nor . or ./ or whatever) and some other stuff.\n\nIf anybody wants to take a look at the direction of unfinished stuff,\nI can see whether there are some old backups with git repos in my\npossession.  But I really have no idea how much of the design might have\nended up in actual comments or code, and how much on some scraps of\npaper or half-committed memory, and how much of that might have been\ninvalidated by other scraps of paper and half-committed memory.\n\nSo there is not likely to be more than food for thought recoverable.\n\nI'm amused that you remember me being involved with that.  I think\nI myself had forgotten all about it until recently.  I don't even\nrecollect what made me remember again: looking at some old repo/commit\nor searching in some old mailing list archive.\n\n\n-- \nDavid Kastrup\n"},{"id":"238684","messageId":"CAA787rmfWqjkBe0cT4-aXD0uPi-pWhjK0K0g2Vm8V0bJ7TLoMg@mail.gmail.com","threadId":"36369","inReplyTo":"1396968442.95061.YahooMailNeo@web120806.mail.ne1.yahoo.com","subject":"Re: Handling empty directories in Git","fromName":"Øyvind A. Holm","fromEmail":"sunny@sunbase.org","sentAt":"2014-04-11T12:34:10Z","receivedAt":"2014-04-11T12:34:10Z","isPatch":false,"sender":{"key":"sunny@sunbase.org","avatar":"https://avatars.githubusercontent.com/u/113445?v=4"},"body":"On 8 April 2014 16:47, Olivier LE ROY <olivier_le_roy@yahoo.com> wrote:\n> Hello,\n>\n> I have a project under SVN with contains empty directories.\n>\n> I would like to move this project on a Git server, still handling empty directories.\n>\n> The solution: put a .gitignore file in each empty directory to have them recognized by the Git database cannot work, because some scripts in my projects test the actual emptiness of the directories.\n>\n> Is there any expert able to tell me: this cannot be done in Git, or this can be done by the following trick, or why there is no valuable reason to maintain empty directories under version control?\n\nGit doesn't support storage of empty directories, but there are ways\naround it. As you say, you could place empty files in every directory,\nbut I've never liked this concept. Instead, I use a couple of scripts\nto store/restore empty directories:\n\nhttps://gist.github.com/sunny256/419015\n\nThis creates a file called \".emptydirs\" at the top of the repo, and it\ncan easily be implemented into scripts and build processes.\n\nGreetings,\nØyvind\n"}]}