Quiet make: do not leave Windows behind
[git/platforms.git] / t / t5521-pull-symlink.sh
blob88583bfc9f49ef999d7b1bc88d07b612c9dfaaec
1 #!/bin/sh
3 test_description='pulling from symlinked subdir'
5 . ./test-lib.sh
7 if test "$no_symlinks"; then
8 say "symbolic links not supported - skipping tests"
9 test_done
12 # The scenario we are building:
14 # trash\ directory/
15 # clone-repo/
16 # subdir/
17 # bar
18 # subdir-link -> clone-repo/subdir/
20 # The working directory is subdir-link.
22 mkdir subdir
23 echo file >subdir/file
24 git add subdir/file
25 git commit -q -m file
26 git clone -q . clone-repo
27 ln -s clone-repo/subdir/ subdir-link
30 # Demonstrate that things work if we just avoid the symlink
32 test_expect_success 'pulling from real subdir' '
34 echo real >subdir/file &&
35 git commit -m real subdir/file &&
36 cd clone-repo/subdir/ &&
37 git pull &&
38 test real = $(cat file)
42 # From subdir-link, pulling should work as it does from
43 # clone-repo/subdir/.
45 # Instead, the error pull gave was:
47 # fatal: 'origin': unable to chdir or not a git archive
48 # fatal: The remote end hung up unexpectedly
50 # because git would find the .git/config for the "trash directory"
51 # repo, not for the clone-repo repo. The "trash directory" repo
52 # had no entry for origin. Git found the wrong .git because
53 # git rev-parse --show-cdup printed a path relative to
54 # clone-repo/subdir/, not subdir-link/. Git rev-parse --show-cdup
55 # used the correct .git, but when the git pull shell script did
56 # "cd `git rev-parse --show-cdup`", it ended up in the wrong
57 # directory. A POSIX shell's "cd" works a little differently
58 # than chdir() in C; "cd -P" is much closer to chdir().
60 test_expect_success 'pulling from symlinked subdir' '
62 echo link >subdir/file &&
63 git commit -m link subdir/file &&
64 cd subdir-link/ &&
65 git pull &&
66 test link = $(cat file)
70 # Prove that the remote end really is a repo, and other commands
71 # work fine in this context. It's just that "git pull" breaks.
73 test_expect_success 'pushing from symlinked subdir' '
75 cd subdir-link/ &&
76 echo push >file &&
77 git commit -m push ./file &&
78 git push
79 ) &&
80 test push = $(git show HEAD:subdir/file)
83 test_done