{"thread":{"id":"33482","subject":"[PATCH] t9903: Don't fail when run from path accessed through symlink","startedAt":"2013-04-11T18:53:22Z","lastAt":"2013-04-11T19:17:49Z","messageCount":2,"participants":["Torstein Hegge","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"213995","messageId":"20130411185322.GF14619@pvv.ntnu.no","threadId":"33482","inReplyTo":null,"subject":"[PATCH] t9903: Don't fail when run from path accessed through symlink","fromName":"Torstein Hegge","fromEmail":"hegge@resisty.net","sentAt":"2013-04-11T18:53:22Z","receivedAt":"2013-04-11T18:53:22Z","isPatch":true,"sender":{"key":"hegge@resisty.net","avatar":"https://avatars.githubusercontent.com/u/26041?v=4"},"body":"When the git directory is accessed through a symlink like\n\n  ln -s /tmp/git /tmp/git-symlink\n  cd /tmp/git-symlink/t\n  make -C .. && ./t9903-bash-prompt.sh\n\n$TRASH_DIRECTORY is /tmp/git-symlink/t/trash directory.t9903-bash-prompt\nand $(pwd -P) is /tmp/git/t/trash directory.t9903-bash-prompt.\n\nWhen __gitdir looks up the path through 'git rev-parse --git-dir', it\nwill return paths similar to $(pwd -P). This behavior is already tested in\nt9903 'gitdir - resulting path avoids symlinks'.\n\nSigned-off-by: Torstein Hegge <hegge@resisty.net>\n---\n t/t9903-bash-prompt.sh |   10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh\nindex 2101d91..e147a8d 100755\n--- a/t/t9903-bash-prompt.sh\n+++ b/t/t9903-bash-prompt.sh\n@@ -59,7 +59,7 @@ test_expect_success 'gitdir - .git directory in cwd' '\n '\n \n test_expect_success 'gitdir - .git directory in parent' '\n-\techo \"$TRASH_DIRECTORY/.git\" > expected &&\n+\techo \"$(pwd -P)/.git\" > expected &&\n \t(\n \t\tcd subdir/subsubdir &&\n \t\t__gitdir > \"$actual\"\n@@ -77,7 +77,7 @@ test_expect_success 'gitdir - cwd is a .git directory' '\n '\n \n test_expect_success 'gitdir - parent is a .git directory' '\n-\techo \"$TRASH_DIRECTORY/.git\" > expected &&\n+\techo \"$(pwd -P)/.git\" > expected &&\n \t(\n \t\tcd .git/refs/heads &&\n \t\t__gitdir > \"$actual\"\n@@ -115,7 +115,7 @@ test_expect_success 'gitdir - non-existing $GIT_DIR' '\n '\n \n test_expect_success 'gitdir - gitfile in cwd' '\n-\techo \"$TRASH_DIRECTORY/otherrepo/.git\" > expected &&\n+\techo \"$(pwd -P)/otherrepo/.git\" > expected &&\n \techo \"gitdir: $TRASH_DIRECTORY/otherrepo/.git\" > subdir/.git &&\n \ttest_when_finished \"rm -f subdir/.git\" &&\n \t(\n@@ -126,7 +126,7 @@ test_expect_success 'gitdir - gitfile in cwd' '\n '\n \n test_expect_success 'gitdir - gitfile in parent' '\n-\techo \"$TRASH_DIRECTORY/otherrepo/.git\" > expected &&\n+\techo \"$(pwd -P)/otherrepo/.git\" > expected &&\n \techo \"gitdir: $TRASH_DIRECTORY/otherrepo/.git\" > subdir/.git &&\n \ttest_when_finished \"rm -f subdir/.git\" &&\n \t(\n@@ -137,7 +137,7 @@ test_expect_success 'gitdir - gitfile in parent' '\n '\n \n test_expect_success SYMLINKS 'gitdir - resulting path avoids symlinks' '\n-\techo \"$TRASH_DIRECTORY/otherrepo/.git\" > expected &&\n+\techo \"$(pwd -P)/otherrepo/.git\" > expected &&\n \tmkdir otherrepo/dir &&\n \ttest_when_finished \"rm -rf otherrepo/dir\" &&\n \tln -s otherrepo/dir link &&\n-- \n1.7.10.4\n"},{"id":"213996","messageId":"20130411191749.GD3177@sigill.intra.peff.net","threadId":"33482","inReplyTo":"20130411185322.GF14619@pvv.ntnu.no","subject":"Re: [PATCH] t9903: Don't fail when run from path accessed through symlink","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-04-11T19:17:49Z","receivedAt":"2013-04-11T19:17:49Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Apr 11, 2013 at 08:53:22PM +0200, Torstein Hegge wrote:\n\n> When the git directory is accessed through a symlink like\n> \n>   ln -s /tmp/git /tmp/git-symlink\n>   cd /tmp/git-symlink/t\n>   make -C .. && ./t9903-bash-prompt.sh\n> \n> $TRASH_DIRECTORY is /tmp/git-symlink/t/trash directory.t9903-bash-prompt\n> and $(pwd -P) is /tmp/git/t/trash directory.t9903-bash-prompt.\n> \n> When __gitdir looks up the path through 'git rev-parse --git-dir', it\n> will return paths similar to $(pwd -P). This behavior is already tested in\n> t9903 'gitdir - resulting path avoids symlinks'.\n\nThanks, this makes sense to me, and is the same solution used in other\nscripts (e.g., t2300), so I don't think we have to worry about any\nportability concerns with \"pwd -P\".\n\n-Peff\n"}]}