Merge branch 'jn/parse-date-basic'
[git/gitweb.git] / t / t5522-pull-symlink.sh
blob298200fa4cafc61b5f16f9337314a2b887593a36
1 #!/bin/sh
3 test_description='pulling from symlinked subdir'
5 . ./test-lib.sh
7 if ! test_have_prereq SYMLINKS
8 then
9 skip_all='Symbolic links not supported, skipping tests.'
10 test_done
13 # The scenario we are building:
15 # trash\ directory/
16 # clone-repo/
17 # subdir/
18 # bar
19 # subdir-link -> clone-repo/subdir/
21 # The working directory is subdir-link.
23 test_expect_success setup '
24 mkdir subdir &&
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 &&
31 cd clone-repo &&
32 git config receive.denyCurrentBranch warn
33 ) &&
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/ &&
44 git pull &&
45 test real = $(cat file)
49 # From subdir-link, pulling should work as it does from
50 # clone-repo/subdir/.
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 &&
71 cd subdir-link/ &&
72 git pull &&
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' '
82 cd subdir-link/ &&
83 echo push >file &&
84 git commit -m push ./file &&
85 git push
86 ) &&
87 test push = $(git show HEAD:subdir/file)
90 test_done