git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] t9903: Don't fail when run from path accessed through symlink
@ 2013-04-11 18:53 Torstein Hegge
  2013-04-11 19:17 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: Torstein Hegge @ 2013-04-11 18:53 UTC (permalink / raw)
  To: git; +Cc: szeder

When the git directory is accessed through a symlink like

  ln -s /tmp/git /tmp/git-symlink
  cd /tmp/git-symlink/t
  make -C .. && ./t9903-bash-prompt.sh

$TRASH_DIRECTORY is /tmp/git-symlink/t/trash directory.t9903-bash-prompt
and $(pwd -P) is /tmp/git/t/trash directory.t9903-bash-prompt.

When __gitdir looks up the path through 'git rev-parse --git-dir', it
will return paths similar to $(pwd -P). This behavior is already tested in
t9903 'gitdir - resulting path avoids symlinks'.

Signed-off-by: Torstein Hegge <hegge@resisty.net>
---
 t/t9903-bash-prompt.sh |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index 2101d91..e147a8d 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -59,7 +59,7 @@ test_expect_success 'gitdir - .git directory in cwd' '
 '
 
 test_expect_success 'gitdir - .git directory in parent' '
-	echo "$TRASH_DIRECTORY/.git" > expected &&
+	echo "$(pwd -P)/.git" > expected &&
 	(
 		cd subdir/subsubdir &&
 		__gitdir > "$actual"
@@ -77,7 +77,7 @@ test_expect_success 'gitdir - cwd is a .git directory' '
 '
 
 test_expect_success 'gitdir - parent is a .git directory' '
-	echo "$TRASH_DIRECTORY/.git" > expected &&
+	echo "$(pwd -P)/.git" > expected &&
 	(
 		cd .git/refs/heads &&
 		__gitdir > "$actual"
@@ -115,7 +115,7 @@ test_expect_success 'gitdir - non-existing $GIT_DIR' '
 '
 
 test_expect_success 'gitdir - gitfile in cwd' '
-	echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
+	echo "$(pwd -P)/otherrepo/.git" > expected &&
 	echo "gitdir: $TRASH_DIRECTORY/otherrepo/.git" > subdir/.git &&
 	test_when_finished "rm -f subdir/.git" &&
 	(
@@ -126,7 +126,7 @@ test_expect_success 'gitdir - gitfile in cwd' '
 '
 
 test_expect_success 'gitdir - gitfile in parent' '
-	echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
+	echo "$(pwd -P)/otherrepo/.git" > expected &&
 	echo "gitdir: $TRASH_DIRECTORY/otherrepo/.git" > subdir/.git &&
 	test_when_finished "rm -f subdir/.git" &&
 	(
@@ -137,7 +137,7 @@ test_expect_success 'gitdir - gitfile in parent' '
 '
 
 test_expect_success SYMLINKS 'gitdir - resulting path avoids symlinks' '
-	echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
+	echo "$(pwd -P)/otherrepo/.git" > expected &&
 	mkdir otherrepo/dir &&
 	test_when_finished "rm -rf otherrepo/dir" &&
 	ln -s otherrepo/dir link &&
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] t9903: Don't fail when run from path accessed through symlink
  2013-04-11 18:53 [PATCH] t9903: Don't fail when run from path accessed through symlink Torstein Hegge
@ 2013-04-11 19:17 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2013-04-11 19:17 UTC (permalink / raw)
  To: Torstein Hegge; +Cc: git, szeder

On Thu, Apr 11, 2013 at 08:53:22PM +0200, Torstein Hegge wrote:

> When the git directory is accessed through a symlink like
> 
>   ln -s /tmp/git /tmp/git-symlink
>   cd /tmp/git-symlink/t
>   make -C .. && ./t9903-bash-prompt.sh
> 
> $TRASH_DIRECTORY is /tmp/git-symlink/t/trash directory.t9903-bash-prompt
> and $(pwd -P) is /tmp/git/t/trash directory.t9903-bash-prompt.
> 
> When __gitdir looks up the path through 'git rev-parse --git-dir', it
> will return paths similar to $(pwd -P). This behavior is already tested in
> t9903 'gitdir - resulting path avoids symlinks'.

Thanks, this makes sense to me, and is the same solution used in other
scripts (e.g., t2300), so I don't think we have to worry about any
portability concerns with "pwd -P".

-Peff

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-04-11 19:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-11 18:53 [PATCH] t9903: Don't fail when run from path accessed through symlink Torstein Hegge
2013-04-11 19:17 ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).