Merge branch 'pc/uninteresting-submodule-disappear-upon-switch-branches'
* pc/uninteresting-submodule-disappear-upon-switch-branches: Remove empty directories when checking out a commit with fewer submodules
This commit is contained in:
commit
26b9f5cc99
@ -299,6 +299,15 @@ test_expect_success 'ls-files gracefully handles trailing slash' '
|
|||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'moving to a commit without submodule does not leave empty dir' '
|
||||||
|
rm -rf init &&
|
||||||
|
mkdir init &&
|
||||||
|
git reset --hard &&
|
||||||
|
git checkout initial &&
|
||||||
|
test ! -d init &&
|
||||||
|
git checkout second
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule <invalid-path> warns' '
|
test_expect_success 'submodule <invalid-path> warns' '
|
||||||
|
|
||||||
git submodule no-such-submodule 2> output.err &&
|
git submodule no-such-submodule 2> output.err &&
|
||||||
|
@ -67,8 +67,16 @@ static void unlink_entry(struct cache_entry *ce)
|
|||||||
{
|
{
|
||||||
if (has_symlink_or_noent_leading_path(ce->name, ce_namelen(ce)))
|
if (has_symlink_or_noent_leading_path(ce->name, ce_namelen(ce)))
|
||||||
return;
|
return;
|
||||||
if (unlink_or_warn(ce->name))
|
if (S_ISGITLINK(ce->ce_mode)) {
|
||||||
return;
|
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));
|
schedule_dir_for_removal(ce->name, ce_namelen(ce));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user