{"thread":{"id":"16924","subject":"[PATCH rfc v2] git-sh-setup: Fix scripts whose PWD is a symlink to a work-dir on OS X","startedAt":"2008-12-30T15:10:24Z","lastAt":"2009-01-06T08:18:29Z","messageCount":8,"participants":["Marcel M. Cary","Marcel Koeppen","Junio C Hamano","Wincent Colaiuta"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"98976","messageId":"1230649824-1893-1-git-send-email-marcel@oak.homeunix.org","threadId":"16924","inReplyTo":"CC0158BE-219B-4E09-9B3B-A2D1B66132AC@silverinsanity.com","subject":"[PATCH rfc v2] git-sh-setup: Fix scripts whose PWD is a symlink to a work-dir on OS X","fromName":"Marcel M. Cary","fromEmail":"marcel@oak.homeunix.org","sentAt":"2008-12-30T15:10:24Z","receivedAt":"2008-12-30T15:10:24Z","isPatch":true,"sender":{"key":"marcel@oak.homeunix.org","avatar":"https://gravatar.com/avatar/2bb524e4f383167b7e256bb93256c88353748d9873c34cde0fd461f1165baa0f?d=mp&s=160"},"body":"On Mac OS X and possibly BSDs, /bin/pwd reads PWD from the environment\nif available and shows the logical path by default rather than the\nphysical one.\n\nUnset PWD before running /bin/pwd in both cd_to_toplevel and its\ntest.\n\nStill use the external /bin/pwd because in my Bash on Linux,\nthe builtin pwd prints the same result whether or not PWD is set.\n---\n\nBrian Gernhardt wrote:\n> I didn't pay attention to this at the time, but I just tried to build a\n> new version of git and noticed this...\n>\n>> +        ..|../*|*/..|*/../*)\n>> +            # Interpret $cdup relative to the physical, not logical,\n>> cwd.\n>> +            # Probably /bin/pwd is more portable than passing -P to\n>> cd or pwd.\n>> +            phys=\"$(/bin/pwd)/$cdup\"\n>> +            ;;\n>\n> This is a non-portable construct.  Notably, on OS X (and possibly some\n> BSDs) /bin/pwd does not give the physical path, but $(/bin/pwd -P)\n> does.\n\nOuch!\n\nJunio C Hamano wrote:\n> Having said that, I think it would probably be better to bite the\n> bullet and start using \"cd -P\" soon after 1.6.1 goes final, and at the\n> same time existing places that use \"cd `pwd`\" as a workaround if there\n> are some.\n\nPerhaps it's time to start using \"cd -P\" with the recent release of\n1.6.1.  But maybe it's also worth finding a fix that doesn't rely on it\nfor any maintenance release of 1.6 that might happen?\n\nBrian Gernhardt wrote:\n> We may have to build this string ourselves with a --show-cd-absolute\n> for portability.\n\nSome options I considered:\n\n(1) We could implement --show-cd-absolute in the short term, with the\nexpectation of removing it we switch to \"cd -P\".  Not sure it would\nreally work to try to remove a switch, even if it were undocumented, or\ndocumented as deprecated.\n\n(2) We could check the output of /bin/pwd for \"..\" and if they are still\npresent, add the \"-P\".  But I suppose there's no guarantee \"-P\" would\nwork, and I shy away from additional analysis of the path because I\ndon't want to miss an edge case.\n\n(3) We could unset PWD before running /bin/pwd.  (Note that in my Bash,\nthe pwd *builtin* prints the same result whether or not I unset PWD\nfirst.)  I suppose it's possible some /bin/pwd dies when PWD is unset or\nsomething, but that seems unlikely.\n\nFrom\nhttp://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man1/pwd.1.html\n> The -L option does not work unless the PWD environment variable is\n> exported by the shell.\n\nI like option 3 best.  Any thoughts?\n\n\nI sent the first rev of this patch to just Brian.  It didn't have\neither of the unit test changes.  He said it fixed all but t2300.3,\nwhere cd_to_toplevel doesn't actually \"cd\", so I made the same change\nto the unit test itself.  Can someone with OS X try running the test\nsuite with v2 of this patch?  I don't have OS X readily available.\n\nMarcel\n\n\n git-sh-setup.sh           |    2 +-\n t/t2300-cd-to-toplevel.sh |    4 ++--\n 2 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex f07d96b..2142308 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -96,7 +96,7 @@ cd_to_toplevel () {\n \t\t..|../*|*/..|*/../*)\n \t\t\t# Interpret $cdup relative to the physical, not logical, cwd.\n \t\t\t# Probably /bin/pwd is more portable than passing -P to cd or pwd.\n-\t\t\tphys=\"$(/bin/pwd)/$cdup\"\n+\t\t\tphys=\"$(unset PWD; /bin/pwd)/$cdup\"\n \t\t\t;;\n \t\t*)\n \t\t\t# There's no \"..\", so no need to make things absolute.\ndiff --git a/t/t2300-cd-to-toplevel.sh b/t/t2300-cd-to-toplevel.sh\nindex beddb4e..e42cbfe 100755\n--- a/t/t2300-cd-to-toplevel.sh\n+++ b/t/t2300-cd-to-toplevel.sh\n@@ -10,12 +10,12 @@ test_cd_to_toplevel () {\n \t\t\tcd '\"'$1'\"' &&\n \t\t\t. git-sh-setup &&\n \t\t\tcd_to_toplevel &&\n-\t\t\t[ \"$(/bin/pwd)\" = \"$TOPLEVEL\" ]\n+\t\t\t[ \"$(unset PWD; /bin/pwd)\" = \"$TOPLEVEL\" ]\n \t\t)\n \t'\n }\n \n-TOPLEVEL=\"$(/bin/pwd)/repo\"\n+TOPLEVEL=\"$(unset PWD; /bin/pwd)/repo\"\n mkdir -p repo/sub/dir\n mv .git repo/\n SUBDIRECTORY_OK=1\n-- \n1.6.0.3\n"},{"id":"99226","messageId":"AC726FD4-AE7F-4EC0-82E5-62C6D03C4E5A@marzelpan.de","threadId":"16924","inReplyTo":"1230649824-1893-1-git-send-email-marcel@oak.homeunix.org","subject":"Re: [PATCH rfc v2] git-sh-setup: Fix scripts whose PWD is a symlink to a work-dir on OS X","fromName":"Marcel Koeppen","fromEmail":"git-dev@marzelpan.de","sentAt":"2009-01-02T22:53:59Z","receivedAt":"2009-01-02T22:53:59Z","isPatch":true,"sender":{"key":"git-dev@marzelpan.de","avatar":"https://gravatar.com/avatar/73c4b29dc13b236d868ba2f40a10262caaf43c0e37d48c459ca07bf3176fa1ba?d=mp&s=160"},"body":"Hi,\n\nAm 30.12.2008 um 16:10 schrieb Marcel M. Cary:\n\n> I sent the first rev of this patch to just Brian.  It didn't have\n> either of the unit test changes.  He said it fixed all but t2300.3,\n> where cd_to_toplevel doesn't actually \"cd\", so I made the same change\n> to the unit test itself.  Can someone with OS X try running the test\n> suite with v2 of this patch?  I don't have OS X readily available.\n\nthe patch fixes t2300-cd-to-toplevel and t5521-pull-symlink for me.\n\n\tMarcel\n\n[I don't know why my replies get lost, so I dropped all individual  \nrecipients on this third try...]\n"},{"id":"99266","messageId":"7v8wps59ss.fsf@gitster.siamese.dyndns.org","threadId":"16924","inReplyTo":"1230649824-1893-1-git-send-email-marcel@oak.homeunix.org","subject":"Re: [PATCH rfc v2] git-sh-setup: Fix scripts whose PWD is a symlink to a work-dir on OS X","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-03T22:01:07Z","receivedAt":"2009-01-03T22:01:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Marcel M. Cary\" <marcel@oak.homeunix.org> writes:\n\n> I sent the first rev of this patch to just Brian.  It didn't have\n> either of the unit test changes.  He said it fixed all but t2300.3,\n> where cd_to_toplevel doesn't actually \"cd\", so I made the same change\n> to the unit test itself.  Can someone with OS X try running the test\n> suite with v2 of this patch?  I don't have OS X readily available.\n\nI think I saw a success report on the list.  Care to resend it with\nSign-off (by you) and\n\n\tTested-by: tester <test@er.xz> (on PLATFORM)\n\nlines as you see necessary for application?\n\nThanks.\n"},{"id":"99304","messageId":"D9F420FC-12C5-4262-833B-0820D8C80AC9@wincent.com","threadId":"16924","inReplyTo":"7v8wps59ss.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH rfc v2] git-sh-setup: Fix scripts whose PWD is a symlink to a work-dir on OS X","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2009-01-04T13:58:30Z","receivedAt":"2009-01-04T13:58:30Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 3/1/2009, a las 23:01, Junio C Hamano escribió:\n\n> \"Marcel M. Cary\" <marcel@oak.homeunix.org> writes:\n>\n>> I sent the first rev of this patch to just Brian.  It didn't have\n>> either of the unit test changes.  He said it fixed all but t2300.3,\n>> where cd_to_toplevel doesn't actually \"cd\", so I made the same change\n>> to the unit test itself.  Can someone with OS X try running the test\n>> suite with v2 of this patch?  I don't have OS X readily available.\n>\n> I think I saw a success report on the list.  Care to resend it with\n> Sign-off (by you) and\n>\n> \tTested-by: tester <test@er.xz> (on PLATFORM)\n>\n> lines as you see necessary for application?\n>\n> Thanks.\n\nI also tested it and can confirm that it fixes the failures on Mac OS  \nX 10.5.5. So feel free to add:\n\nTested-by: Wincent Colaiuta <win@wincent.com> (on Mac OS X 10.5.5)\n\nCheers,\nWincent\n"},{"id":"99320","messageId":"8C7E36D0-C037-427D-B6E2-4050CC767CD0@marzelpan.de","threadId":"16924","inReplyTo":"7v8wps59ss.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH rfc v2] git-sh-setup: Fix scripts whose PWD is a symlink to a work-dir on OS X","fromName":"Marcel Koeppen","fromEmail":"git-dev@marzelpan.de","sentAt":"2009-01-04T18:49:03Z","receivedAt":"2009-01-04T18:49:03Z","isPatch":true,"sender":{"key":"git-dev@marzelpan.de","avatar":"https://gravatar.com/avatar/73c4b29dc13b236d868ba2f40a10262caaf43c0e37d48c459ca07bf3176fa1ba?d=mp&s=160"},"body":"\nAm 03.01.2009 um 23:01 schrieb Junio C Hamano:\n\n> \"Marcel M. Cary\" <marcel@oak.homeunix.org> writes:\n>\n>> I sent the first rev of this patch to just Brian.  It didn't have\n>> either of the unit test changes.  He said it fixed all but t2300.3,\n>> where cd_to_toplevel doesn't actually \"cd\", so I made the same change\n>> to the unit test itself.  Can someone with OS X try running the test\n>> suite with v2 of this patch?  I don't have OS X readily available.\n>\n> I think I saw a success report on the list.  Care to resend it with\n> Sign-off (by you) and\n>\n> \tTested-by: tester <test@er.xz> (on PLATFORM)\n>\n> lines as you see necessary for application?\n>\n> Thanks.\n\n\nHi,\n\nplease add\n\nTested-by: Marcel Koeppen <git-dev@marzelpan.de> (on Mac OS X 10.5.6)\n\n\tMarcel\n"},{"id":"99327","messageId":"1231104445-12531-1-git-send-email-marcel@oak.homeunix.org","threadId":"16924","inReplyTo":"AC726FD4-AE7F-4EC0-82E5-62C6D03C4E5A@marzelpan.de","subject":"[PATCH v2 tested] git-sh-setup: Fix scripts whose PWD is a symlink to a work-dir on OS X","fromName":"Marcel M. Cary","fromEmail":"marcel@oak.homeunix.org","sentAt":"2009-01-04T21:27:25Z","receivedAt":"2009-01-04T21:27:25Z","isPatch":true,"sender":{"key":"marcel@oak.homeunix.org","avatar":"https://gravatar.com/avatar/2bb524e4f383167b7e256bb93256c88353748d9873c34cde0fd461f1165baa0f?d=mp&s=160"},"body":"On Mac OS X and possibly BSDs, /bin/pwd reads PWD from the environment\nif available and shows the logical path by default rather than the\nphysical one.\n\nUnset PWD before running /bin/pwd in both cd_to_toplevel and its\ntest.\n\nStill use the external /bin/pwd because in my Bash on Linux,\nthe builtin pwd prints the same result whether or not PWD is set.\n\nSigned-off-by: Marcel M. Cary <marcel@oak.homeunix.org>\nTested-by: Marcel Koeppen <git-dev@marzelpan.de>\n---\n\nJunio C Hamano wrote:\n> I think I saw a success report on the list.  Care to resend it with\n> Sign-off (by you) and\n> \n>         Tested-by: tester <test@er.xz> (on PLATFORM)\n> \n> lines as you see necessary for application?\n\nSame as before but with S-o-b/T-b lines.\n\nMarcel Koeppen wrote:\n> [I don't know why my replies get lost, so I dropped all individual\n> recipients on this third try...]\n\nI noticed that Brian Gernhardt's message also didn't make it to the\nlist, even though it was addressed to the list.  I'm not sure why.\n\n\n git-sh-setup.sh           |    2 +-\n t/t2300-cd-to-toplevel.sh |    4 ++--\n 2 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex f07d96b..2142308 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -96,7 +96,7 @@ cd_to_toplevel () {\n \t\t..|../*|*/..|*/../*)\n \t\t\t# Interpret $cdup relative to the physical, not logical, cwd.\n \t\t\t# Probably /bin/pwd is more portable than passing -P to cd or pwd.\n-\t\t\tphys=\"$(/bin/pwd)/$cdup\"\n+\t\t\tphys=\"$(unset PWD; /bin/pwd)/$cdup\"\n \t\t\t;;\n \t\t*)\n \t\t\t# There's no \"..\", so no need to make things absolute.\ndiff --git a/t/t2300-cd-to-toplevel.sh b/t/t2300-cd-to-toplevel.sh\nindex beddb4e..e42cbfe 100755\n--- a/t/t2300-cd-to-toplevel.sh\n+++ b/t/t2300-cd-to-toplevel.sh\n@@ -10,12 +10,12 @@ test_cd_to_toplevel () {\n \t\t\tcd '\"'$1'\"' &&\n \t\t\t. git-sh-setup &&\n \t\t\tcd_to_toplevel &&\n-\t\t\t[ \"$(/bin/pwd)\" = \"$TOPLEVEL\" ]\n+\t\t\t[ \"$(unset PWD; /bin/pwd)\" = \"$TOPLEVEL\" ]\n \t\t)\n \t'\n }\n \n-TOPLEVEL=\"$(/bin/pwd)/repo\"\n+TOPLEVEL=\"$(unset PWD; /bin/pwd)/repo\"\n mkdir -p repo/sub/dir\n mv .git repo/\n SUBDIRECTORY_OK=1\n-- \n1.6.1\n"},{"id":"99328","messageId":"1231105649-12998-1-git-send-email-marcel@oak.homeunix.org","threadId":"16924","inReplyTo":"8C7E36D0-C037-427D-B6E2-4050CC767CD0@marzelpan.de","subject":"[PATCH v2 tested-v2] git-sh-setup: Fix scripts whose PWD is a symlink to a work-dir on OS X","fromName":"Marcel M. Cary","fromEmail":"marcel@oak.homeunix.org","sentAt":"2009-01-04T21:47:29Z","receivedAt":"2009-01-04T21:47:29Z","isPatch":true,"sender":{"key":"marcel@oak.homeunix.org","avatar":"https://gravatar.com/avatar/2bb524e4f383167b7e256bb93256c88353748d9873c34cde0fd461f1165baa0f?d=mp&s=160"},"body":"On Mac OS X and possibly BSDs, /bin/pwd reads PWD from the environment\nif available and shows the logical path by default rather than the\nphysical one.\n\nUnset PWD before running /bin/pwd in both cd_to_toplevel and its\ntest.\n\nStill use the external /bin/pwd because in my Bash on Linux,\nthe builtin pwd prints the same result whether or not PWD is set.\n\nSigned-off-by: Marcel M. Cary <marcel@oak.homeunix.org>\nTested-by: Marcel Koeppen <git-dev@marzelpan.de> (on Mac OS X 10.5.6)\n---\n\n> please add\n> \n> Tested-by: Marcel Koeppen <git-dev@marzelpan.de> (on Mac OS X 10.5.6)\n\nNow with the OS, in detail.\n\n\n git-sh-setup.sh           |    2 +-\n t/t2300-cd-to-toplevel.sh |    4 ++--\n 2 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex f07d96b..2142308 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -96,7 +96,7 @@ cd_to_toplevel () {\n \t\t..|../*|*/..|*/../*)\n \t\t\t# Interpret $cdup relative to the physical, not logical, cwd.\n \t\t\t# Probably /bin/pwd is more portable than passing -P to cd or pwd.\n-\t\t\tphys=\"$(/bin/pwd)/$cdup\"\n+\t\t\tphys=\"$(unset PWD; /bin/pwd)/$cdup\"\n \t\t\t;;\n \t\t*)\n \t\t\t# There's no \"..\", so no need to make things absolute.\ndiff --git a/t/t2300-cd-to-toplevel.sh b/t/t2300-cd-to-toplevel.sh\nindex beddb4e..e42cbfe 100755\n--- a/t/t2300-cd-to-toplevel.sh\n+++ b/t/t2300-cd-to-toplevel.sh\n@@ -10,12 +10,12 @@ test_cd_to_toplevel () {\n \t\t\tcd '\"'$1'\"' &&\n \t\t\t. git-sh-setup &&\n \t\t\tcd_to_toplevel &&\n-\t\t\t[ \"$(/bin/pwd)\" = \"$TOPLEVEL\" ]\n+\t\t\t[ \"$(unset PWD; /bin/pwd)\" = \"$TOPLEVEL\" ]\n \t\t)\n \t'\n }\n \n-TOPLEVEL=\"$(/bin/pwd)/repo\"\n+TOPLEVEL=\"$(unset PWD; /bin/pwd)/repo\"\n mkdir -p repo/sub/dir\n mv .git repo/\n SUBDIRECTORY_OK=1\n-- \n1.6.1\n"},{"id":"99437","messageId":"7v63ksluei.fsf@gitster.siamese.dyndns.org","threadId":"16924","inReplyTo":"1231105649-12998-1-git-send-email-marcel@oak.homeunix.org","subject":"Re: [PATCH v2 tested-v2] git-sh-setup: Fix scripts whose PWD is a symlink to a work-dir on OS X","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-06T08:18:29Z","receivedAt":"2009-01-06T08:18:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks; queued.\n"}]}