1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-31 14:27:54 +01:00
git/t/t2000-checkout-cache-clash.sh
Junio C Hamano da02ca508b check_path(): allow symlinked directories to checkout-index --prefix
Merlyn noticed that Documentation/install-doc-quick.sh no longer correctly
removes old installed documents when the target directory has a leading
path that is a symlink.  It turns out that "checkout-index --prefix" was
broken by recent b6986d8 (git-checkout: be careful about untracked
symlinks, 2009-07-29).

I suspect has_symlink_leading_path() could learn the third parameter
(prefix that is allowed to be symlinked directories) to allow us to retire
a similar function has_dirs_only_path().

Another avenue of fixing this I considered was to get rid of base_dir and
base_dir_len from "struct checkout", and instead make "git checkout-index"
when run with --prefix mkdir the leading path and chdir in there.  It
might be the best longer term solution to this issue, as the base_dir
feature is used only by that rather obscure codepath as far as I know.

But at least this patch should fix this breakage.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-18 03:32:45 -07:00

60 lines
1.4 KiB
Bash
Executable file

#!/bin/sh
#
# Copyright (c) 2005 Junio C Hamano
#
test_description='git checkout-index test.
This test registers the following filesystem structure in the
cache:
path0 - a file
path1/file1 - a file in a directory
And then tries to checkout in a work tree that has the following:
path0/file0 - a file in a directory
path1 - a file
The git checkout-index command should fail when attempting to checkout
path0, finding it is occupied by a directory, and path1/file1, finding
path1 is occupied by a non-directory. With "-f" flag, it should remove
the conflicting paths and succeed.
'
. ./test-lib.sh
date >path0
mkdir path1
date >path1/file1
test_expect_success \
'git update-index --add various paths.' \
'git update-index --add path0 path1/file1'
rm -fr path0 path1
mkdir path0
date >path0/file0
date >path1
test_expect_success \
'git checkout-index without -f should fail on conflicting work tree.' \
'test_must_fail git checkout-index -a'
test_expect_success \
'git checkout-index with -f should succeed.' \
'git checkout-index -f -a'
test_expect_success \
'git checkout-index conflicting paths.' \
'test -f path0 && test -d path1 && test -f path1/file1'
test_expect_success SYMLINKS 'checkout-index -f twice with --prefix' '
mkdir -p tar/get &&
ln -s tar/get there &&
echo first &&
git checkout-index -a -f --prefix=there/ &&
echo second &&
git checkout-index -a -f --prefix=there/
'
test_done