]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t1400-update-ref.sh
files_transaction_commit(): clean up empty directories
[thirdparty/git.git] / t / t1400-update-ref.sh
index d4fb9770600df75d3162ffbc6c567b1ae152fccd..97d87936ff77d08cf4b3d4ef01d21b7fc73c090f 100755 (executable)
@@ -191,6 +191,33 @@ test_expect_success \
         git update-ref HEAD'" $A &&
         test $A"' = $(cat .git/'"$m"')'
 
+test_expect_success "empty directory removal" '
+       git branch d1/d2/r1 HEAD &&
+       git branch d1/r2 HEAD &&
+       test -f .git/refs/heads/d1/d2/r1 &&
+       test -f .git/logs/refs/heads/d1/d2/r1 &&
+       git branch -d d1/d2/r1 &&
+       ! test -e .git/refs/heads/d1/d2 &&
+       ! test -e .git/logs/refs/heads/d1/d2 &&
+       test -f .git/refs/heads/d1/r2 &&
+       test -f .git/logs/refs/heads/d1/r2
+'
+
+test_expect_success "symref empty directory removal" '
+       git branch e1/e2/r1 HEAD &&
+       git branch e1/r2 HEAD &&
+       git checkout e1/e2/r1 &&
+       test_when_finished "git checkout master" &&
+       test -f .git/refs/heads/e1/e2/r1 &&
+       test -f .git/logs/refs/heads/e1/e2/r1 &&
+       git update-ref -d HEAD &&
+       ! test -e .git/refs/heads/e1/e2 &&
+       ! test -e .git/logs/refs/heads/e1/e2 &&
+       test -f .git/refs/heads/e1/r2 &&
+       test -f .git/logs/refs/heads/e1/r2 &&
+       test -f .git/logs/HEAD
+'
+
 cat >expect <<EOF
 $Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000      Initial Creation
 $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000      Switch