@matheusbsbs / matheus-bagliano / commits / dd6c1360b2
Fork 0

git-sh-setup: Fix scripts whose PWD is a symlink to a work-dir on OS X

On Mac OS X and possibly BSDs, /bin/pwd reads PWD from the environment if available and shows the logical path by default rather than the physical one. Unset PWD before running /bin/pwd in both cd_to_toplevel and its test. Still use the external /bin/pwd because in my Bash on Linux, the builtin pwd prints the same result whether or not PWD is set. Signed-off-by: Marcel M. Cary <marcel@oak.homeunix.org> Tested-by: Wincent Colaiuta <win@wincent.com> (on Mac OS X 10.5.5) Tested-by: Marcel Koeppen <git-dev@marzelpan.de> (on Mac OS X 10.5.6) Signed-off-by: Junio C Hamano <gitster@pobox.com>

Marcel M. Cary committed Dec 30, 2008 at 07:10 UTC dd6c1360b22ee89cb179e2a1fface98ecbeb7b3e
2 files changed +3 -3
git-sh-setup.sh
+1 -1
@@ -96,7 +96,7 @@ cd_to_toplevel () {
96 ..|../*|*/..|*/../*)
97 # Interpret $cdup relative to the physical, not logical, cwd.
98 # Probably /bin/pwd is more portable than passing -P to cd or pwd.
99 - phys="$(/bin/pwd)/$cdup"
99 + phys="$(unset PWD; /bin/pwd)/$cdup"
100 ;;
101 *)
102 # There's no "..", so no need to make things absolute.
t/t2300-cd-to-toplevel.sh
+2 -2
@@ -10,12 +10,12 @@ test_cd_to_toplevel () {
10 cd '"'$1'"' &&
11 . git-sh-setup &&
12 cd_to_toplevel &&
13 - [ "$(/bin/pwd)" = "$TOPLEVEL" ]
13 + [ "$(unset PWD; /bin/pwd)" = "$TOPLEVEL" ]
14 )
15 '
16 }
17
18 -TOPLEVEL="$(/bin/pwd)/repo"
18 +TOPLEVEL="$(unset PWD; /bin/pwd)/repo"
19 mkdir -p repo/sub/dir
20 mv .git repo/
21 SUBDIRECTORY_OK=1