diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-04-01 16:19:03 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-04-01 16:19:03 -0700 |
commit | 46a1f0728c6b5a886424e74c8bcacedf355eb918 (patch) | |
tree | 4b3e2bf7d605858408c17e0774248a0f9af227ec /t | |
parent | Merge "checkout ambiguous ref bugfix" into maint (diff) | |
parent | do not overwrite untracked symlinks (diff) | |
download | tgif-46a1f0728c6b5a886424e74c8bcacedf355eb918.tar.xz |
Merge branch 'js/checkout-untracked-symlink' into maint
* js/checkout-untracked-symlink:
do not overwrite untracked symlinks
Demonstrate breakage: checkout overwrites untracked symlink with directory
Diffstat (limited to 't')
-rwxr-xr-x | t/t2021-checkout-overwrite.sh | 50 | ||||
-rwxr-xr-x | t/t6035-merge-dir-to-symlink.sh | 14 |
2 files changed, 61 insertions, 3 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 diff --git a/t/t6035-merge-dir-to-symlink.sh b/t/t6035-merge-dir-to-symlink.sh index 92e02d5d77..2599ae50eb 100755 --- a/t/t6035-merge-dir-to-symlink.sh +++ b/t/t6035-merge-dir-to-symlink.sh @@ -17,13 +17,21 @@ test_expect_success SYMLINKS 'create a commit where dir a/b changed to symlink' git commit -m "dir to symlink" ' -test_expect_success SYMLINKS 'keep a/b-2/c/d across checkout' ' +test_expect_success SYMLINKS 'checkout does not clobber untracked symlink' ' git checkout HEAD^0 && git reset --hard master && git rm --cached a/b && git commit -m "untracked symlink remains" && - git checkout start^0 && - test -f a/b-2/c/d + test_must_fail git checkout start^0 +' + +test_expect_success SYMLINKS 'a/b-2/c/d is kept when clobbering symlink b' ' + git checkout HEAD^0 && + git reset --hard master && + git rm --cached a/b && + git commit -m "untracked symlink remains" && + git checkout -f start^0 && + test -f a/b-2/c/d ' test_expect_success SYMLINKS 'checkout should not have deleted a/b-2/c/d' ' |