3 test_description='pulling from symlinked subdir'
7 if ! test_have_prereq SYMLINKS
9 say 'Symbolic links not supported, skipping tests.'
14 # The scenario we are building:
20 # subdir-link -> clone-repo/subdir/
22 # The working directory is subdir-link.
25 echo file >subdir/file
28 git clone -q . clone-repo
29 ln -s clone-repo/subdir/ subdir-link
32 # Demonstrate that things work if we just avoid the symlink
34 test_expect_success 'pulling from real subdir' '
36 echo real >subdir/file &&
37 git commit -m real subdir/file &&
38 cd clone-repo/subdir/ &&
40 test real = $(cat file)
44 # From subdir-link, pulling should work as it does from
47 # Instead, the error pull gave was:
49 # fatal: 'origin': unable to chdir or not a git archive
50 # fatal: The remote end hung up unexpectedly
52 # because git would find the .git/config for the "trash directory"
53 # repo, not for the clone-repo repo. The "trash directory" repo
54 # had no entry for origin. Git found the wrong .git because
55 # git rev-parse --show-cdup printed a path relative to
56 # clone-repo/subdir/, not subdir-link/. Git rev-parse --show-cdup
57 # used the correct .git, but when the git pull shell script did
58 # "cd `git rev-parse --show-cdup`", it ended up in the wrong
59 # directory. A POSIX shell's "cd" works a little differently
60 # than chdir() in C; "cd -P" is much closer to chdir().
62 test_expect_success 'pulling from symlinked subdir' '
64 echo link >subdir/file &&
65 git commit -m link subdir/file &&
68 test link = $(cat file)
72 # Prove that the remote end really is a repo, and other commands
73 # work fine in this context. It's just that "git pull" breaks.
75 test_expect_success 'pushing from symlinked subdir' '
79 git commit -m push ./file &&
82 test push = $(git show HEAD:subdir/file)