Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] Remove empty directories when checking out a commit with fewer submodules

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:47:59

Johannes Schindelin [off-list ref] writes:
NAK.  We should not even try to _unlink_ submodule subdirectories; it 
would be _way_ too easy to lose data that way.  Remember, submodules are a 
totally different beast from regular files.  They can contain valuable, 
yet uncommitted data, that is not even meant to be committed.

So you say if the submodule directories are empty, it is safe?  Not so.  
They will never be empty: there is always .git/...
NACK on NAK.

Don't worry, your data will be safe.  The only case rmdir would actually
remove it is (1) you check out superproject that has submodule A, but you
choose not to "submodule init/update" it, because you don't need a
checkout of that part of the tree for your job, and then (2) you switch to
a different version of the superproject that doesn't anymore (or didn't
back then) have that submodule.  In such a use case, you will have only an
empty directory for A in step (1).  The unnecessary empty directory A will
be left behind, even after switching to a version that shouldn't have the
directory there in step (2), if you do not rmdir it.  So the patch is a
strict bugfix (it attempted to unlink, which is a bug; it really meant
"rmdir" and not "rm -rf" which you seem to be worried about).

It is a separate matter to _enhance_ the codepath to actually either (A)
refuse to overwrite (if the version of the superproject you are switching
to in step (2) had a regular file or a directory that is part of the
superproject there, and/or (B) move it away to somewhere safe (recall the
discussion of ".git/modules/$submodule" hierarchy of the superproject?)
automatically when it will disappear.  Such enhancements will help people
who _do_ "submodule init/update" the submodule in step (1) and switch to a
version of the superproject that lacks it in step (2).
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help