Merge branch 'jc/maint-clean-nested-worktree-in-subdir'

"git clean -d -f" (not "-d -f -f") is supposed to protect nested working
trees of independent git repositories that exist in the current project
working tree from getting removed, but the protection applied only to such
working trees that are at the top-level of the current project by mistake.

* jc/maint-clean-nested-worktree-in-subdir:
  clean: preserve nested git worktree in subdirectories
This commit is contained in:
Junio C Hamano
2012-04-16 12:40:22 -07:00
2 changed files with 43 additions and 11 deletions

View File

@@ -399,8 +399,8 @@ test_expect_success SANITY 'removal failure' '
'
test_expect_success 'nested git work tree' '
rm -fr foo bar &&
mkdir foo bar &&
rm -fr foo bar baz &&
mkdir -p foo bar baz/boo &&
(
cd foo &&
git init &&
@@ -412,15 +412,24 @@ test_expect_success 'nested git work tree' '
cd bar &&
>goodbye.people
) &&
(
cd baz/boo &&
git init &&
>deeper.world
git add . &&
git commit -a -m deeply.nested
) &&
git clean -f -d &&
test -f foo/.git/index &&
test -f foo/hello.world &&
test -f baz/boo/.git/index &&
test -f baz/boo/deeper.world &&
! test -d bar
'
test_expect_success 'force removal of nested git work tree' '
rm -fr foo bar &&
mkdir foo bar &&
rm -fr foo bar baz &&
mkdir -p foo bar baz/boo &&
(
cd foo &&
git init &&
@@ -432,9 +441,17 @@ test_expect_success 'force removal of nested git work tree' '
cd bar &&
>goodbye.people
) &&
(
cd baz/boo &&
git init &&
>deeper.world
git add . &&
git commit -a -m deeply.nested
) &&
git clean -f -f -d &&
! test -d foo &&
! test -d bar
! test -d bar &&
! test -d baz
'
test_expect_success 'git clean -e' '