git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Doan Tran Cong Danh <congdanhqx@gmail.com>
To: git@vger.kernel.org
Cc: Doan Tran Cong Danh <congdanhqx@gmail.com>
Subject: [PATCH] test: switch to POSIX compliance symlink check
Date: Sat, 21 Dec 2019 23:40:57 +0700	[thread overview]
Message-ID: <20191221164057.24616-1-congdanhqx@gmail.com> (raw)

POSIX doesn't specify `-L' flag for test(1), POSIX specify `-h' for
checking symlink instead.

While most shells and test(1) implementation provides both `-L' and
`-h' for checking symlink,
OpenBSD and NetBSD says we shouldn't rely on its existence. [1]

Replace all usages of `test -L' with `test -h'.

[1]: https://man.openbsd.org/test.1

Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com>
---
 t/t9131-git-svn-empty-symlink.sh  | 4 ++--
 t/t9132-git-svn-broken-symlink.sh | 4 ++--
 t/t9802-git-p4-filetype.sh        | 2 +-
 t/t9830-git-p4-symlink-dir.sh     | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/t/t9131-git-svn-empty-symlink.sh b/t/t9131-git-svn-empty-symlink.sh
index 3bf4255aa3..6812028258 100755
--- a/t/t9131-git-svn-empty-symlink.sh
+++ b/t/t9131-git-svn-empty-symlink.sh
@@ -97,14 +97,14 @@ test_expect_success 'disable broken symlink workaround' \
 test_expect_success '"bar" is an empty file' 'test_must_be_empty y/bar'
 test_expect_success 'get "bar" => symlink fix from svn' \
 		'(cd y && git svn rebase)'
-test_expect_success '"bar" does not become a symlink' '! test -L y/bar'
+test_expect_success '"bar" does not become a symlink' '! test -h y/bar'
 
 # svn.brokenSymlinkWorkaround is unset
 test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" z'
 test_expect_success '"bar" is an empty file' 'test_must_be_empty z/bar'
 test_expect_success 'get "bar" => symlink fix from svn' \
 		'(cd z && git svn rebase)'
-test_expect_success '"bar" does not become a symlink' '! test -L z/bar'
+test_expect_success '"bar" does not become a symlink' '! test -h z/bar'
 
 
 test_done
diff --git a/t/t9132-git-svn-broken-symlink.sh b/t/t9132-git-svn-broken-symlink.sh
index aeceffaf7b..2b15b97cdf 100755
--- a/t/t9132-git-svn-broken-symlink.sh
+++ b/t/t9132-git-svn-broken-symlink.sh
@@ -86,7 +86,7 @@ EOF
 test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" x'
 
 test_expect_success SYMLINKS '"bar" is a symlink that points to "asdf"' '
-	test -L x/bar &&
+	test -h x/bar &&
 	(cd x && test xasdf = x"$(git cat-file blob HEAD:bar)")
 '
 
@@ -95,7 +95,7 @@ test_expect_success 'get "bar" => symlink fix from svn' '
 '
 
 test_expect_success SYMLINKS '"bar" remains a proper symlink' '
-	test -L x/bar &&
+	test -h x/bar &&
 	(cd x && test xdoink = x"$(git cat-file blob HEAD:bar)")
 '
 
diff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh
index 94edebe272..197752b45a 100755
--- a/t/t9802-git-p4-filetype.sh
+++ b/t/t9802-git-p4-filetype.sh
@@ -262,7 +262,7 @@ test_expect_success SYMLINKS 'ensure p4 symlink parsed correctly' '
 	git p4 clone --dest="$git" //depot@all &&
 	(
 		cd "$git" &&
-		test -L symlink &&
+		test -h symlink &&
 		test $(readlink symlink) = symlink-target
 	)
 '
diff --git a/t/t9830-git-p4-symlink-dir.sh b/t/t9830-git-p4-symlink-dir.sh
index 3fb6960c18..4b4cc015fc 100755
--- a/t/t9830-git-p4-symlink-dir.sh
+++ b/t/t9830-git-p4-symlink-dir.sh
@@ -30,7 +30,7 @@ test_expect_success 'symlinked directory' '
 	(
 		cd "$cli" &&
 		p4 sync &&
-		test -L some/sub/directory/subdir2 &&
+		test -h some/sub/directory/subdir2 &&
 		test_path_is_file some/sub/directory/subdir2/file.t
 	)
 
-- 
2.24.1.485.gad05a3d8e5


             reply	other threads:[~2019-12-21 16:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-21 16:40 Doan Tran Cong Danh [this message]
2019-12-21 20:45 ` [PATCH] test: switch to POSIX compliance symlink check Carlo Arenas
2019-12-22  2:07   ` Danh Doan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191221164057.24616-1-congdanhqx@gmail.com \
    --to=congdanhqx@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).