Teach the "@{-1} syntax to "git branch"
[git/jrn.git] / t / t5521-pull-symlink.sh
blob5672b51e2ea8db0e080e95315b292c91480a0000
1 #!/bin/sh
3 test_description='pulling from symlinked subdir'
5 . ./test-lib.sh
7 # The scenario we are building:
9 # trash\ directory/
10 # clone-repo/
11 # subdir/
12 # bar
13 # subdir-link -> clone-repo/subdir/
15 # The working directory is subdir-link.
17 mkdir subdir
18 echo file >subdir/file
19 git add subdir/file
20 git commit -q -m 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/ &&
32 git pull &&
33 test real = $(cat file)
37 # From subdir-link, pulling should work as it does from
38 # clone-repo/subdir/.
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 &&
59 cd subdir-link/ &&
60 git pull &&
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' '
70 cd subdir-link/ &&
71 echo push >file &&
72 git commit -m push ./file &&
73 git push
74 ) &&
75 test push = $(git show HEAD:subdir/file)
78 test_done