mirror of
https://github.com/git/git.git
synced 2024-11-25 19:04:18 +08:00
889c6f0e4d
There are many instances where the treatment of symbolic links in the object model and the algorithms are tested, but where it is not necessary to actually have a symbolic link in the worktree. Make adjustments to the tests and remove the SYMLINKS prerequisite when appropriate in trivial cases, where "trivial" means: - merely a replacement of 'ln -s a b && git add b' by test_ln_s_add is needed; - a test for symbolic link on the file system can be split off (and remains protected by SYMLINKS); - existing code is equivalent to test_ln_s_add. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
55 lines
1.1 KiB
Bash
Executable File
55 lines
1.1 KiB
Bash
Executable File
#!/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 '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 &&
|
|
git add -A &&
|
|
test_ln_s_add foo a/b &&
|
|
git commit -m "dir to symlink"
|
|
'
|
|
|
|
test_expect_success '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_expect_success SYMLINKS 'the symlink remained' '
|
|
|
|
test -h a/b
|
|
'
|
|
|
|
test_done
|