git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] t7400: fix bogus test failure with symlinked trash

From
Jeff King <peff@peff.net>
Date
Jul 30, 2011, 00:36 UTC
Message-ID
<20110730003609.GA6089@sigill.intra.peff.net>

One of the tests in t7400 fails if the trash directory has a symlink anywhere in its path. E.g.:

  $ mkdir /tmp/git-test
  $ mkdir /tmp/git-test/real
  $ ln -s real /tmp/git-test/link
  $ ./t7400-submodule-basic --root=/tmp/git-test/real
  ...
  # passed all 44 test(s)
  $ ./t7400-submodule-basic --root=/tmp/git-test/link
  ...
  not ok - 41 use superproject as upstream when path is relative and no url is set there
The failing test does:
  git submodule add ../repo relative &&
  ...
  git submodule sync relative &&
  test "$(git config submodule.relative.url)" = "$submodurl/repo"

where $submodurl comes from the $TRASH_DIRECTORY the user gave us. However, git will resolve symlinks when converting the relative path into an absolute one, leading them to be textually different (even though they point to the same directory).

Fix this by asking git to canonicalize the name of the trash directory for us.

Signed-off-by: Jeff King <peff@peff.net>
---
This feels a little funny, because we are probably using the same
"convert relative to absolute" code to generate our expected value, as
well as in the test itself. So any bug in that code is likely to be
masked. But this test isn't really about checking the absolute path
code, but rather making sure that it is invoked properly.
 t/t7400-submodule-basic.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 5afe6cc..12200ca 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -48,7 +48,7 @@ test_expect_success 'setup - repository to add submodules to' '
 
 # The 'submodule add' tests need some repository to add as a submodule.
 # The trash directory is a good one as any.
-submodurl=$TRASH_DIRECTORY
+submodurl=`git rev-parse --show-toplevel`
 
 listbranches() {
 	git for-each-ref --format='%(refname)' 'refs/heads/*'
-- 
1.7.5.4.31.ge4d5e
Next: Jens Lehmann
Message 1 of 4 in “t7400: fix bogus test failure with symlinked trash”
  1. t7400: fix bogus test failure with symlinked trashJeff King, Jul 30, 2011
  2. Jens LehmannJul 30, 2011
  3. Jeff KingJul 30, 2011
  4. Jens LehmannJul 30, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.