summaryrefslogtreecommitdiff
path: root/t/t2021-checkout-overwrite.sh
diff options
context:
space:
mode:
authorJohannes Sixt <j6t@kdbg.org>2011-02-05 19:18:44 +0100
committerJunio C Hamano <gitster@pobox.com>2011-02-15 10:40:43 -0800
commit2fe26b775cfa298a0b4bc3c53011ca6da7c6c298 (patch)
tree42e20e5e0e80d26bc0e647f95c692cd2cfa773d2 /t/t2021-checkout-overwrite.sh
parent7ed863a85a6ce2c4ac4476848310b8f917ab41f9 (diff)
downloadgit-2fe26b775cfa298a0b4bc3c53011ca6da7c6c298.tar.gz
Demonstrate breakage: checkout overwrites untracked symlink with directory
This adds tests where an untracked file and an untracked symlink are in the way where a directory should be created by 'git checkout'. Commit b1735b1a (do not overwrite files in leading path, 2010-12-14) fixed the case where a file is in the way, but the untracked symlink is still removed silently. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t2021-checkout-overwrite.sh')
-rwxr-xr-xt/t2021-checkout-overwrite.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/t/t2021-checkout-overwrite.sh b/t/t2021-checkout-overwrite.sh
new file mode 100755
index 0000000000..27db2ad529
--- /dev/null
+++ b/t/t2021-checkout-overwrite.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+test_description='checkout must not overwrite an untracked objects'
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+
+ mkdir -p a/b/c &&
+ >a/b/c/d &&
+ git add -A &&
+ git commit -m base &&
+ git tag start
+'
+
+test_expect_success 'create a commit where dir a/b changed to file' '
+
+ git checkout -b file &&
+ rm -rf a/b &&
+ >a/b &&
+ git add -A &&
+ git commit -m "dir to file"
+'
+
+test_expect_success 'checkout commit with dir must not remove untracked a/b' '
+
+ git rm --cached a/b &&
+ git commit -m "un-track the file" &&
+ test_must_fail git checkout start &&
+ test -f a/b
+'
+
+test_expect_success SYMLINKS 'create a commit where dir a/b changed to symlink' '
+
+ rm -rf a/b && # cleanup if previous test failed
+ git checkout -f -b symlink start &&
+ rm -rf a/b &&
+ ln -s foo a/b &&
+ git add -A &&
+ git commit -m "dir to symlink"
+'
+
+test_expect_failure SYMLINKS 'checkout commit with dir must not remove untracked a/b' '
+
+ git rm --cached a/b &&
+ git commit -m "un-track the symlink" &&
+ test_must_fail git checkout start &&
+ test -h a/b
+'
+
+test_done