aboutsummaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2010-01-11 02:59:54 +0000
committerJunio C Hamano <gitster@pobox.com>2010-01-11 19:50:51 -0800
commitc5e558a80ad27774b9984258a31fbf46a1d7c152 (patch)
tree52f49eeac0af719a6cfd5312f3a6903808663461 /unpack-trees.c
parent902f235378cb2b2f6dd5dd664b9630c95321f0ae (diff)
downloadgit-c5e558a80ad27774b9984258a31fbf46a1d7c152.tar.gz
git-c5e558a80ad27774b9984258a31fbf46a1d7c152.tar.xz
Remove empty directories when checking out a commit with fewer submodules
Change the unlink_entry function to use rmdir to remove submodule directories. Currently we try to use unlink, which will never succeed. Of course rmdir will only succeed for empty (i.e. not checked out) submodule directories. Behaviour if a submodule is checked out stays essentially the same: print a warning message and keep the submodule directory. Signed-off-by: Peter Collingbourne <peter@pcc.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index dd5999c35..b69847d6c 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -61,8 +61,16 @@ static void unlink_entry(struct cache_entry *ce)
{
if (has_symlink_or_noent_leading_path(ce->name, ce_namelen(ce)))
return;
- if (unlink_or_warn(ce->name))
- return;
+ if (S_ISGITLINK(ce->ce_mode)) {
+ if (rmdir(ce->name)) {
+ warning("unable to rmdir %s: %s",
+ ce->name, strerror(errno));
+ return;
+ }
+ }
+ else
+ if (unlink_or_warn(ce->name))
+ return;
schedule_dir_for_removal(ce->name, ce_namelen(ce));
}