3 test_description
='pulling from symlinked subdir'
7 if ! test_have_prereq SYMLINKS
9 say
'Symbolic links not supported, skipping tests.'
13 # The scenario we are building:
19 # subdir-link -> clone-repo/subdir/
21 # The working directory is subdir-link.
23 test_expect_success setup
'
25 echo file >subdir/file &&
26 git add subdir/file &&
27 git commit -q -m file &&
28 git clone -q . clone-repo &&
29 ln -s clone-repo/subdir/ subdir-link &&
32 git config receive.denyCurrentBranch warn
34 git config receive.denyCurrentBranch warn
37 # Demonstrate that things work if we just avoid the symlink
39 test_expect_success
'pulling from real subdir' '
41 echo real >subdir/file &&
42 git commit -m real subdir/file &&
43 cd clone-repo/subdir/ &&
45 test real = $(cat file)
49 # From subdir-link, pulling should work as it does from
52 # Instead, the error pull gave was:
54 # fatal: 'origin': unable to chdir or not a git archive
55 # fatal: The remote end hung up unexpectedly
57 # because git would find the .git/config for the "trash directory"
58 # repo, not for the clone-repo repo. The "trash directory" repo
59 # had no entry for origin. Git found the wrong .git because
60 # git rev-parse --show-cdup printed a path relative to
61 # clone-repo/subdir/, not subdir-link/. Git rev-parse --show-cdup
62 # used the correct .git, but when the git pull shell script did
63 # "cd `git rev-parse --show-cdup`", it ended up in the wrong
64 # directory. A POSIX shell's "cd" works a little differently
65 # than chdir() in C; "cd -P" is much closer to chdir().
67 test_expect_success
'pulling from symlinked subdir' '
69 echo link >subdir/file &&
70 git commit -m link subdir/file &&
73 test link = $(cat file)
77 # Prove that the remote end really is a repo, and other commands
78 # work fine in this context. It's just that "git pull" breaks.
80 test_expect_success
'pushing from symlinked subdir' '
84 git commit -m push ./file &&
87 test push = $(git show HEAD:subdir/file)