* [PATCH] test: switch to POSIX compliance symlink check
@ 2019-12-21 16:40 Doan Tran Cong Danh
2019-12-21 20:45 ` Carlo Arenas
0 siblings, 1 reply; 3+ messages in thread
From: Doan Tran Cong Danh @ 2019-12-21 16:40 UTC (permalink / raw)
To: git; +Cc: Doan Tran Cong Danh
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] test: switch to POSIX compliance symlink check
2019-12-21 16:40 [PATCH] test: switch to POSIX compliance symlink check Doan Tran Cong Danh
@ 2019-12-21 20:45 ` Carlo Arenas
2019-12-22 2:07 ` Danh Doan
0 siblings, 1 reply; 3+ messages in thread
From: Carlo Arenas @ 2019-12-21 20:45 UTC (permalink / raw)
To: Doan Tran Cong Danh; +Cc: git
On Sat, Dec 21, 2019 at 8:50 AM Doan Tran Cong Danh
<congdanhqx@gmail.com> wrote:
>
> POSIX doesn't specify `-L' flag for test(1), POSIX specify `-h' for
> checking symlink instead.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
seems to indicate both are valid and equivalent
> 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]
and macOS (from FreeBSD[1]) says the exact opposite :
-h file True if file exists and is a symbolic link. This operator
is retained for compatibility with previous versions of
this program. Do not rely on its existence; use -L
instead.
agree it would be a good idea to use only one for consistency though,
but it might be in that case a good idea to add it as a
"recommendation" by adding this rule in t/check-non-portable-shell.pl
or something like that IMHO
Carlo
[1] https://www.freebsd.org/cgi/man.cgi?test
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] test: switch to POSIX compliance symlink check
2019-12-21 20:45 ` Carlo Arenas
@ 2019-12-22 2:07 ` Danh Doan
0 siblings, 0 replies; 3+ messages in thread
From: Danh Doan @ 2019-12-22 2:07 UTC (permalink / raw)
To: Carlo Arenas; +Cc: git
On 2019-12-21 12:45:43-0800, Carlo Arenas <carenas@gmail.com> wrote:
> On Sat, Dec 21, 2019 at 8:50 AM Doan Tran Cong Danh
> <congdanhqx@gmail.com> wrote:
> >
> > POSIX doesn't specify `-L' flag for test(1), POSIX specify `-h' for
> > checking symlink instead.
>
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
>
> seems to indicate both are valid and equivalent
It's seems like I've misread my manpages.
Somehow, I couldn't find the mention of `-L' when I tried it last
time.
Please ignore this patch.
>
> > 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]
>
> and macOS (from FreeBSD[1]) says the exact opposite :
>
> -h file True if file exists and is a symbolic link. This operator
> is retained for compatibility with previous versions of
> this program. Do not rely on its existence; use -L
> instead.
>
> agree it would be a good idea to use only one for consistency though,
> but it might be in that case a good idea to add it as a
> "recommendation" by adding this rule in t/check-non-portable-shell.pl
> or something like that IMHO
>
> Carlo
>
> [1] https://www.freebsd.org/cgi/man.cgi?test
--
Danh
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-12-22 2:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-21 16:40 [PATCH] test: switch to POSIX compliance symlink check Doan Tran Cong Danh
2019-12-21 20:45 ` Carlo Arenas
2019-12-22 2:07 ` Danh Doan
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).