Skip to content

Commit

Permalink
t7400: fix bogus test failure with symlinked trash
Browse files Browse the repository at this point in the history
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 pwd to canonicalize the name of the trash
directory for us.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Aug 1, 2011
1 parent e44b6df commit dd008b3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions t/t7400-submodule-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ 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
# The trash directory is a good one as any. We need to canonicalize
# the name, though, as some tests compare it to the absolute path git
# generates, which will expand symbolic links.
submodurl=$(pwd -P)

listbranches() {
git for-each-ref --format='%(refname)' 'refs/heads/*'
Expand Down

0 comments on commit dd008b3

Please sign in to comment.