Marcel M. Cary | 08fc060 | 2008-12-15 09:34:37 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='pulling from symlinked subdir' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
Marcel M. Cary | 08fc060 | 2008-12-15 09:34:37 -0800 | [diff] [blame] | 7 | # The scenario we are building: |
| 8 | # |
| 9 | # trash\ directory/ |
| 10 | # clone-repo/ |
| 11 | # subdir/ |
| 12 | # bar |
| 13 | # subdir-link -> clone-repo/subdir/ |
| 14 | # |
| 15 | # The working directory is subdir-link. |
| 16 | |
Ævar Arnfjörð Bjarmason | 41be8ea | 2010-07-28 10:34:55 +0000 | [diff] [blame] | 17 | test_expect_success SYMLINKS setup ' |
Junio C Hamano | acd2a45 | 2009-02-11 02:28:03 -0800 | [diff] [blame] | 18 | mkdir subdir && |
| 19 | echo file >subdir/file && |
| 20 | git add subdir/file && |
| 21 | git commit -q -m file && |
| 22 | git clone -q . clone-repo && |
| 23 | ln -s clone-repo/subdir/ subdir-link && |
| 24 | ( |
| 25 | cd clone-repo && |
| 26 | git config receive.denyCurrentBranch warn |
| 27 | ) && |
| 28 | git config receive.denyCurrentBranch warn |
| 29 | ' |
Marcel M. Cary | 08fc060 | 2008-12-15 09:34:37 -0800 | [diff] [blame] | 30 | |
| 31 | # Demonstrate that things work if we just avoid the symlink |
| 32 | # |
Ævar Arnfjörð Bjarmason | 41be8ea | 2010-07-28 10:34:55 +0000 | [diff] [blame] | 33 | test_expect_success SYMLINKS 'pulling from real subdir' ' |
Marcel M. Cary | 08fc060 | 2008-12-15 09:34:37 -0800 | [diff] [blame] | 34 | ( |
| 35 | echo real >subdir/file && |
| 36 | git commit -m real subdir/file && |
| 37 | cd clone-repo/subdir/ && |
| 38 | git pull && |
| 39 | test real = $(cat file) |
| 40 | ) |
| 41 | ' |
| 42 | |
| 43 | # From subdir-link, pulling should work as it does from |
| 44 | # clone-repo/subdir/. |
| 45 | # |
| 46 | # Instead, the error pull gave was: |
| 47 | # |
| 48 | # fatal: 'origin': unable to chdir or not a git archive |
| 49 | # fatal: The remote end hung up unexpectedly |
| 50 | # |
| 51 | # because git would find the .git/config for the "trash directory" |
| 52 | # repo, not for the clone-repo repo. The "trash directory" repo |
| 53 | # had no entry for origin. Git found the wrong .git because |
| 54 | # git rev-parse --show-cdup printed a path relative to |
| 55 | # clone-repo/subdir/, not subdir-link/. Git rev-parse --show-cdup |
| 56 | # used the correct .git, but when the git pull shell script did |
Elia Pinto | 91852b5 | 2016-01-04 10:10:42 +0100 | [diff] [blame] | 57 | # "cd $(git rev-parse --show-cdup)", it ended up in the wrong |
Marcel M. Cary | 08fc060 | 2008-12-15 09:34:37 -0800 | [diff] [blame] | 58 | # directory. A POSIX shell's "cd" works a little differently |
| 59 | # than chdir() in C; "cd -P" is much closer to chdir(). |
| 60 | # |
Ævar Arnfjörð Bjarmason | 41be8ea | 2010-07-28 10:34:55 +0000 | [diff] [blame] | 61 | test_expect_success SYMLINKS 'pulling from symlinked subdir' ' |
Marcel M. Cary | 08fc060 | 2008-12-15 09:34:37 -0800 | [diff] [blame] | 62 | ( |
| 63 | echo link >subdir/file && |
| 64 | git commit -m link subdir/file && |
| 65 | cd subdir-link/ && |
| 66 | git pull && |
| 67 | test link = $(cat file) |
| 68 | ) |
| 69 | ' |
| 70 | |
| 71 | # Prove that the remote end really is a repo, and other commands |
| 72 | # work fine in this context. It's just that "git pull" breaks. |
| 73 | # |
Ævar Arnfjörð Bjarmason | 41be8ea | 2010-07-28 10:34:55 +0000 | [diff] [blame] | 74 | test_expect_success SYMLINKS 'pushing from symlinked subdir' ' |
Marcel M. Cary | 08fc060 | 2008-12-15 09:34:37 -0800 | [diff] [blame] | 75 | ( |
| 76 | cd subdir-link/ && |
| 77 | echo push >file && |
| 78 | git commit -m push ./file && |
| 79 | git push |
| 80 | ) && |
| 81 | test push = $(git show HEAD:subdir/file) |
| 82 | ' |
| 83 | |
| 84 | test_done |