* Handling empty directories in Git
@ 2014-04-08 14:47 Olivier LE ROY
2014-04-08 17:02 ` Andrew Keller
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Olivier LE ROY @ 2014-04-08 14:47 UTC (permalink / raw)
To: git@vger.kernel.org
Hello,
I have a project under SVN with contains empty directories.
I would like to move this project on a Git server, still handling empty directories.
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.
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?
Regards,
Olivier LE ROY
France
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: Handling empty directories in Git
2014-04-08 14:47 Handling empty directories in Git Olivier LE ROY
@ 2014-04-08 17:02 ` Andrew Keller
2014-04-08 17:20 ` Andrew Keller
2014-04-08 17:47 ` Olivier LE ROY
2014-04-08 17:03 ` Matthieu Moy
2014-04-11 12:34 ` Øyvind A. Holm
2 siblings, 2 replies; 9+ messages in thread
From: Andrew Keller @ 2014-04-08 17:02 UTC (permalink / raw)
To: Olivier LE ROY; +Cc: git@vger.kernel.org
On Apr 8, 2014, at 10:47 AM, Olivier LE ROY <olivier_le_roy@yahoo.com> wrote:
> Hello,
>
> I have a project under SVN with contains empty directories.
>
> I would like to move this project on a Git server, still handling empty directories.
>
> 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.
>
> 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?
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.
Why can't your scripts create the folders on demand? Or, could your scripts interpret a missing folder as an empty folder?
Thanks,
Andrew Keller
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Handling empty directories in Git
2014-04-08 17:02 ` Andrew Keller
@ 2014-04-08 17:20 ` Andrew Keller
2014-04-08 17:47 ` Olivier LE ROY
1 sibling, 0 replies; 9+ messages in thread
From: Andrew Keller @ 2014-04-08 17:20 UTC (permalink / raw)
To: Olivier LE ROY; +Cc: git@vger.kernel.org
On Apr 8, 2014, at 1:02 PM, Andrew Keller <andrew@kellerfarm.com> wrote:
> On Apr 8, 2014, at 10:47 AM, Olivier LE ROY <olivier_le_roy@yahoo.com> wrote:
>
>> Hello,
>>
>> I have a project under SVN with contains empty directories.
>>
>> I would like to move this project on a Git server, still handling empty directories.
>>
>> 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.
>>
>> 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?
>
> 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.
To 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.
Thanks,
Andrew Keller
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Handling empty directories in Git
2014-04-08 17:02 ` Andrew Keller
2014-04-08 17:20 ` Andrew Keller
@ 2014-04-08 17:47 ` Olivier LE ROY
1 sibling, 0 replies; 9+ messages in thread
From: Olivier LE ROY @ 2014-04-08 17:47 UTC (permalink / raw)
To: Andrew Keller; +Cc: git@vger.kernel.org
Hello Andrew,
yes that is possible to have scripts create the missing directories.
The 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.
I guess it is similar as programming in Java and programming in plain old C.
Olivier LE ROY
________________________________
De : Andrew Keller <andrew@kellerfarm.com>
À : Olivier LE ROY <olivier_le_roy@yahoo.com>
Cc : "git@vger.kernel.org" <git@vger.kernel.org>
Envoyé le : Mardi 8 avril 2014 17h02
Objet : Re: Handling empty directories in Git
On Apr 8, 2014, at 10:47 AM, Olivier LE ROY <olivier_le_roy@yahoo.com> wrote:
> Hello,
>
> I have a project under SVN with contains empty directories.
>
> I would like to move this project on a Git server, still handling empty directories.
>
> 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.
>
> 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?
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.
Why can't your scripts create the folders on demand? Or, could your scripts interpret a missing folder as an empty folder?
Thanks,
Andrew Keller
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Handling empty directories in Git
2014-04-08 14:47 Handling empty directories in Git Olivier LE ROY
2014-04-08 17:02 ` Andrew Keller
@ 2014-04-08 17:03 ` Matthieu Moy
2014-04-08 17:36 ` David Kastrup
2014-04-08 18:06 ` Olivier LE ROY
2014-04-11 12:34 ` Øyvind A. Holm
2 siblings, 2 replies; 9+ messages in thread
From: Matthieu Moy @ 2014-04-08 17:03 UTC (permalink / raw)
To: Olivier LE ROY; +Cc: git@vger.kernel.org
Olivier LE ROY <olivier_le_roy@yahoo.com> writes:
> 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.
Another option is to have a post-checkout hook that does the mkdir for
you. Or do that in the build system if your use case is to store
untracked generated files in the directory.
> Is there any expert able to tell me: this cannot be done in Git, or
> this can be done by the following trick,
https://git.wiki.kernel.org/index.php/Git_FAQ#Can_I_add_empty_directories.3F
Short answer: it cannot be done.
> or why there is no valuable reason to maintain empty directories under
> version control?
The reason would be closer to "there is a valuable reason, but not
valuable enough to change Git to do it". It's actually not so easy to
track directories properly. Storing them in the Git repository is
actually possible (actually, an empty tree is a special case of this,
and is obviously supported), but defining and implementing a decent
behavior for each Git command wrt this is not trivial.
David Kastrup gave it a try a few years ago. I don't remember exactly
what made him give up, but it was never completed and merged.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Handling empty directories in Git
2014-04-08 17:03 ` Matthieu Moy
@ 2014-04-08 17:36 ` David Kastrup
2014-04-08 18:39 ` Olivier LE ROY
2014-04-08 18:06 ` Olivier LE ROY
1 sibling, 1 reply; 9+ messages in thread
From: David Kastrup @ 2014-04-08 17:36 UTC (permalink / raw)
To: Matthieu Moy; +Cc: Olivier LE ROY, git@vger.kernel.org
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
> The reason would be closer to "there is a valuable reason, but not
> valuable enough to change Git to do it". It's actually not so easy to
> track directories properly. Storing them in the Git repository is
> actually possible (actually, an empty tree is a special case of this,
> and is obviously supported), but defining and implementing a decent
> behavior for each Git command wrt this is not trivial.
>
> David Kastrup gave it a try a few years ago. I don't remember exactly
> what made him give up, but it was never completed and merged.
Oh, most likely what afflicts most of my unfinished projects. I lost
focus at some point of time. I don't remember any fundamentally
unsolvable problems, but then I don't remember much at all. There were
some annoyances with sorting order (either regarding the sorting of xxx/
or . or ./ or whatever) and some other stuff.
If anybody wants to take a look at the direction of unfinished stuff,
I can see whether there are some old backups with git repos in my
possession. But I really have no idea how much of the design might have
ended up in actual comments or code, and how much on some scraps of
paper or half-committed memory, and how much of that might have been
invalidated by other scraps of paper and half-committed memory.
So there is not likely to be more than food for thought recoverable.
I'm amused that you remember me being involved with that. I think
I myself had forgotten all about it until recently. I don't even
recollect what made me remember again: looking at some old repo/commit
or searching in some old mailing list archive.
--
David Kastrup
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Handling empty directories in Git
2014-04-08 17:36 ` David Kastrup
@ 2014-04-08 18:39 ` Olivier LE ROY
0 siblings, 0 replies; 9+ messages in thread
From: Olivier LE ROY @ 2014-04-08 18:39 UTC (permalink / raw)
To: David Kastrup, Matthieu Moy; +Cc: git@vger.kernel.org
Hi David,
thanks 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.
Regards,
Olivier LE ROY
----- Mail original -----
De : David Kastrup <dak@gnu.org>
À : Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Cc : Olivier LE ROY <olivier_le_roy@yahoo.com>; "git@vger.kernel.org" <git@vger.kernel.org>
Envoyé le : Mardi 8 avril 2014 17h36
Objet : Re: Handling empty directories in Git
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
> The reason would be closer to "there is a valuable reason, but not
> valuable enough to change Git to do it". It's actually not so easy to
> track directories properly. Storing them in the Git repository is
> actually possible (actually, an empty tree is a special case of this,
> and is obviously supported), but defining and implementing a decent
> behavior for each Git command wrt this is not trivial.
>
> David Kastrup gave it a try a few years ago. I don't remember exactly
> what made him give up, but it was never completed and merged.
Oh, most likely what afflicts most of my unfinished projects. I lost
focus at some point of time. I don't remember any fundamentally
unsolvable problems, but then I don't remember much at all. There were
some annoyances with sorting order (either regarding the sorting of xxx/
or . or ./ or whatever) and some other stuff.
If anybody wants to take a look at the direction of unfinished stuff,
I can see whether there are some old backups with git repos in my
possession. But I really have no idea how much of the design might have
ended up in actual comments or code, and how much on some scraps of
paper or half-committed memory, and how much of that might have been
invalidated by other scraps of paper and half-committed memory.
So there is not likely to be more than food for thought recoverable.
I'm amused that you remember me being involved with that. I think
I myself had forgotten all about it until recently. I don't even
recollect what made me remember again: looking at some old repo/commit
or searching in some old mailing list archive.
--
David Kastrup
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Handling empty directories in Git
2014-04-08 17:03 ` Matthieu Moy
2014-04-08 17:36 ` David Kastrup
@ 2014-04-08 18:06 ` Olivier LE ROY
1 sibling, 0 replies; 9+ messages in thread
From: Olivier LE ROY @ 2014-04-08 18:06 UTC (permalink / raw)
To: Matthieu Moy; +Cc: git@vger.kernel.org
Hi Mattieu,
thanks for this answer. It is clear enough.
Olivier LE ROY
----- Mail original -----
De : Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
À : Olivier LE ROY <olivier_le_roy@yahoo.com>
Cc : "git@vger.kernel.org" <git@vger.kernel.org>
Envoyé le : Mardi 8 avril 2014 17h03
Objet : Re: Handling empty directories in Git
Olivier LE ROY <olivier_le_roy@yahoo.com> writes:
> 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.
Another option is to have a post-checkout hook that does the mkdir for
you. Or do that in the build system if your use case is to store
untracked generated files in the directory.
> Is there any expert able to tell me: this cannot be done in Git, or
> this can be done by the following trick,
https://git.wiki.kernel.org/index.php/Git_FAQ#Can_I_add_empty_directories.3F
Short answer: it cannot be done.
> or why there is no valuable reason to maintain empty directories under
> version control?
The reason would be closer to "there is a valuable reason, but not
valuable enough to change Git to do it". It's actually not so easy to
track directories properly. Storing them in the Git repository is
actually possible (actually, an empty tree is a special case of this,
and is obviously supported), but defining and implementing a decent
behavior for each Git command wrt this is not trivial.
David Kastrup gave it a try a few years ago. I don't remember exactly
what made him give up, but it was never completed and merged.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Handling empty directories in Git
2014-04-08 14:47 Handling empty directories in Git Olivier LE ROY
2014-04-08 17:02 ` Andrew Keller
2014-04-08 17:03 ` Matthieu Moy
@ 2014-04-11 12:34 ` Øyvind A. Holm
2 siblings, 0 replies; 9+ messages in thread
From: Øyvind A. Holm @ 2014-04-11 12:34 UTC (permalink / raw)
To: Olivier LE ROY; +Cc: git@vger.kernel.org
On 8 April 2014 16:47, Olivier LE ROY <olivier_le_roy@yahoo.com> wrote:
> Hello,
>
> I have a project under SVN with contains empty directories.
>
> I would like to move this project on a Git server, still handling empty directories.
>
> 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.
>
> 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?
Git doesn't support storage of empty directories, but there are ways
around it. As you say, you could place empty files in every directory,
but I've never liked this concept. Instead, I use a couple of scripts
to store/restore empty directories:
https://gist.github.com/sunny256/419015
This creates a file called ".emptydirs" at the top of the repo, and it
can easily be implemented into scripts and build processes.
Greetings,
Øyvind
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-04-11 12:34 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-08 14:47 Handling empty directories in Git Olivier LE ROY
2014-04-08 17:02 ` Andrew Keller
2014-04-08 17:20 ` Andrew Keller
2014-04-08 17:47 ` Olivier LE ROY
2014-04-08 17:03 ` Matthieu Moy
2014-04-08 17:36 ` David Kastrup
2014-04-08 18:39 ` Olivier LE ROY
2014-04-08 18:06 ` Olivier LE ROY
2014-04-11 12:34 ` Øyvind A. Holm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.