3 test_description
='pulling from symlinked subdir'
7 # The scenario we are building:
13 # subdir-link -> clone-repo/subdir/
15 # The working directory is subdir-link.
18 echo file >subdir
/file
21 git clone
-q . clone-repo
22 ln -s clone-repo
/subdir
/ subdir-link
25 # Demonstrate that things work if we just avoid the symlink
27 test_expect_success
'pulling from real subdir' '
29 echo real >subdir/file &&
30 git commit -m real subdir/file &&
31 cd clone-repo/subdir/ &&
33 test real = $(cat file)
37 # From subdir-link, pulling should work as it does from
40 # Instead, the error pull gave was:
42 # fatal: 'origin': unable to chdir or not a git archive
43 # fatal: The remote end hung up unexpectedly
45 # because git would find the .git/config for the "trash directory"
46 # repo, not for the clone-repo repo. The "trash directory" repo
47 # had no entry for origin. Git found the wrong .git because
48 # git rev-parse --show-cdup printed a path relative to
49 # clone-repo/subdir/, not subdir-link/. Git rev-parse --show-cdup
50 # used the correct .git, but when the git pull shell script did
51 # "cd `git rev-parse --show-cdup`", it ended up in the wrong
52 # directory. A POSIX shell's "cd" works a little differently
53 # than chdir() in C; "cd -P" is much closer to chdir().
55 test_expect_success
'pulling from symlinked subdir' '
57 echo link >subdir/file &&
58 git commit -m link subdir/file &&
61 test link = $(cat file)
65 # Prove that the remote end really is a repo, and other commands
66 # work fine in this context. It's just that "git pull" breaks.
68 test_expect_success
'pushing from symlinked subdir' '
72 git commit -m push ./file &&
75 test push = $(git show HEAD:subdir/file)