"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
Regress: replace unportable "ln -h"
To:
gameoftrees@openbsd.org
Date:
Thu, 2 Mar 2023 22:53:18 +0100

Download raw body.

Thread
The -h option to ln(1) is not portable.  The regression tests use
it to replace a symlink pointing to a directory; without it, a
symlink would be created inside the linked directory.  I suggest
to simply replace it with "rm symlink && ln -s foo symlink".

This could be a local change in -portable, but I think it is not
too onerous to have it in main and shrink the diff to -portable.

Thomas: This also obviates the need for ln() in common.sh.

OK?

diff refs/heads/main refs/heads/regress
commit - 038b5b12dddbc93e926a6446737f35122838decf
commit + f91a7c2fd2b2e9c6cd170bc1d91847cd28fd2632
blob - fac54ca43c8da9be765539a05b8b421d64c36807
blob + 5f8f09cafb0426ef5bc92fae1bf7d909c80282ad
--- regress/cmdline/cherrypick.sh
+++ regress/cmdline/cherrypick.sh
@@ -479,7 +479,7 @@ EOF
 	got checkout -b foo $testroot/repo $testroot/wt > /dev/null
 
 	(cd $testroot/repo && ln -sf beta alpha.link)
-	(cd $testroot/repo && ln -sfh gamma epsilon.link)
+	(cd $testroot/repo && rm epsilon.link && ln -s gamma epsilon.link)
 	(cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
 	(cd $testroot/repo && ln -sf .got/foo $testroot/repo/dotgotfoo.link)
 	(cd $testroot/repo && git rm -q nonexistent.link)
@@ -657,7 +657,7 @@ test_cherrypick_symlink_conflicts() {
 
 	(cd $testroot/repo && ln -sf beta alpha.link)
 	(cd $testroot/repo && ln -sf beta boo.link)
-	(cd $testroot/repo && ln -sfh gamma epsilon.link)
+	(cd $testroot/repo && rm epsilon.link && ln -s gamma epsilon.link)
 	(cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
 	echo 'this is regular file foo' > $testroot/repo/dotgotfoo.link
 	(cd $testroot/repo && ln -sf .got/bar dotgotbar.link)
@@ -674,9 +674,10 @@ test_cherrypick_symlink_conflicts() {
 	# modified symlink to file A vs modified symlink to file B
 	(cd $testroot/wt && ln -sf gamma/delta alpha.link)
 	# modified symlink to dir A vs modified symlink to file B
-	(cd $testroot/wt && ln -sfh beta epsilon.link)
+	(cd $testroot/wt && rm epsilon.link && ln -s beta epsilon.link)
 	# modeified symlink to file A vs modified symlink to dir B
-	(cd $testroot/wt && ln -sfh ../gamma epsilon/beta.link)
+	(cd $testroot/wt && rm epsilon/beta.link && ln -s ../gamma \
+		epsilon/beta.link)
 	# added regular file A vs added bad symlink to file A
 	(cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
 	(cd $testroot/wt && got add dotgotfoo.link > /dev/null)
blob - 8ab732f77ce0d79d8a050bfedb50712fa26428d2
blob + 5abd887aa45862efaed44d7fe13cdbf897e90883
--- regress/cmdline/commit.sh
+++ regress/cmdline/commit.sh
@@ -1402,7 +1402,7 @@ test_commit_symlink() {
 	fi
 
 	(cd $testroot/wt && ln -sf beta alpha.link)
-	(cd $testroot/wt && ln -sfh gamma epsilon.link)
+	(cd $testroot/wt && rm epsilon.link && ln -s gamma epsilon.link)
 	rm $testroot/wt/epsilon/beta.link
 	echo "this is a regular file" > $testroot/wt/epsilon/beta.link
 	(cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
@@ -1513,7 +1513,7 @@ test_commit_fix_bad_symlink() {
 	fi
 
 	# change "bad" symlink back into a "good" symlink
-	(cd $testroot/wt && ln -sfh alpha passwd.link)
+	(cd $testroot/wt && rm passwd.link && ln -s alpha passwd.link)
 
 	(cd $testroot/wt && got commit -m 'fix bad symlink' \
 		> $testroot/stdout)
blob - 84681e2a5ec0f41b9ea674365f6fb81fb230a356
blob + cfcbb7402cba3671e0519ad680092846ffd36a21
--- regress/cmdline/diff.sh
+++ regress/cmdline/diff.sh
@@ -729,7 +729,7 @@ test_diff_symlinks_in_work_tree() {
 	fi
 
 	(cd $testroot/wt && ln -sf beta alpha.link)
-	(cd $testroot/wt && ln -sfh gamma epsilon.link)
+	(cd $testroot/wt && rm epsilon.link && ln -s gamma epsilon.link)
 	(cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
 	echo -n '.got/bar' > $testroot/wt/dotgotfoo.link
 	(cd $testroot/wt && got rm nonexistent.link > /dev/null)
@@ -828,7 +828,7 @@ test_diff_symlinks_in_repo() {
 	local commit_id1=`git_show_head $testroot/repo`
 
 	(cd $testroot/repo && ln -sf beta alpha.link)
-	(cd $testroot/repo && ln -sfh gamma epsilon.link)
+	(cd $testroot/repo && rm epsilon.link && ln -s gamma epsilon.link)
 	(cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
 	(cd $testroot/repo && ln -sf .got/bar $testroot/repo/dotgotfoo.link)
 	(cd $testroot/repo && git rm -q nonexistent.link)
blob - 3d38c4d175937ca52bef1b76659276b50d0cf91e
blob + b568329b09e4e5ae44e43459bc4b32b4d3050b36
--- regress/cmdline/revert.sh
+++ regress/cmdline/revert.sh
@@ -1077,11 +1077,12 @@ test_revert_symlink() {
 	# symlink to file A now points to file B
 	(cd $testroot/wt && ln -sf gamma/delta alpha.link)
 	# symlink to a directory A now points to file B
-	(cd $testroot/wt && ln -sfh beta epsilon.link)
+	(cd $testroot/wt && rm epsilon.link && ln -s beta epsilon.link)
 	# "bad" symlink now contains a different target path
 	echo "foo" > $testroot/wt/passwd.link
 	# relative symlink to directory A now points to relative directory B
-	(cd $testroot/wt && ln -sfh ../gamma epsilon/beta.link)
+	(cd $testroot/wt && rm epsilon/beta.link && ln -s ../gamma \
+		epsilon/beta.link)
 	# an unversioned symlink
 	(cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
 	# symlink to file A now points to non-existent file B
@@ -1250,11 +1251,12 @@ test_revert_patch_symlink() {
 	# symlink to file A now points to file B
 	(cd $testroot/wt && ln -sf gamma/delta alpha.link)
 	# symlink to a directory A now points to file B
-	(cd $testroot/wt && ln -sfh beta epsilon.link)
+	(cd $testroot/wt && rm epsilon.link && ln -s beta epsilon.link)
 	# "bad" symlink now contains a different target path
 	echo "foo" > $testroot/wt/passwd.link
 	# relative symlink to directory A now points to relative directory B
-	(cd $testroot/wt && ln -sfh ../gamma epsilon/beta.link)
+	(cd $testroot/wt && rm epsilon/beta.link && ln -s ../gamma \
+		epsilon/beta.link)
 	# an unversioned symlink
 	(cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
 	# symlink to file A now points to non-existent file B
blob - a5219920d083205b95e1b41ccd7b95d63d7a7752
blob + 01dd0b976f6f7b5d840e72398cadf29728591229
--- regress/cmdline/stage.sh
+++ regress/cmdline/stage.sh
@@ -2442,7 +2442,7 @@ test_stage_symlink() {
 	fi
 
 	(cd $testroot/wt && ln -sf beta alpha.link)
-	(cd $testroot/wt && ln -sfh gamma epsilon.link)
+	(cd $testroot/wt && rm epsilon.link && ln -s gamma epsilon.link)
 	(cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
 	echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
 	(cd $testroot/wt && got add dotgotfoo.link > /dev/null)
@@ -2755,7 +2755,7 @@ test_stage_patch_symlink() {
 	fi
 
 	(cd $testroot/wt && ln -sf beta alpha.link)
-	(cd $testroot/wt && ln -sfh gamma epsilon.link)
+	(cd $testroot/wt && rm epsilon.link && ln -s gamma epsilon.link)
 	(cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
 	echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
 	(cd $testroot/wt && got add dotgotfoo.link > /dev/null)
blob - f2d3d5dfe1904cd50bfc165b2d05f293cb4fad5f
blob + 6098eb8ab154c97c655c6d305d0d01b1db1c71a7
--- regress/cmdline/status.sh
+++ regress/cmdline/status.sh
@@ -301,7 +301,7 @@ test_status_symlink() {
 	fi
 
 	(cd $testroot/wt && ln -sf beta alpha.link)
-	(cd $testroot/wt && ln -sfh gamma epsilon.link)
+	(cd $testroot/wt && rm epsilon.link && ln -s gamma epsilon.link)
 
 	(cd $testroot/wt && ln -s /etc/passwd passwd.link)
 	(cd $testroot/wt && ln -s ../beta epsilon/beta.link)
blob - 9800c7a89b0e7cb56c713845da4176515a2d7dba
blob + 768bc40e938998a7e2da71aaab91d5477bcc2725
--- regress/cmdline/unstage.sh
+++ regress/cmdline/unstage.sh
@@ -987,7 +987,7 @@ test_unstage_symlink() {
 	fi
 
 	(cd $testroot/wt && ln -sf beta alpha.link)
-	(cd $testroot/wt && ln -sfh gamma epsilon.link)
+	(cd $testroot/wt && rm epsilon.link && ln -s gamma epsilon.link)
 	(cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
 	echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
 	(cd $testroot/wt && got add dotgotfoo.link > /dev/null)
@@ -1173,11 +1173,12 @@ test_unstage_patch_symlink() {
 	# symlink to file A now points to file B
 	(cd $testroot/wt && ln -sf gamma/delta alpha.link)
 	# symlink to a directory A now points to file B
-	(cd $testroot/wt && ln -sfh beta epsilon.link)
+	(cd $testroot/wt && rm epsilon.link && ln -s beta epsilon.link)
 	# "bad" symlink now contains a different target path
 	echo "foo" > $testroot/wt/passwd.link
 	# relative symlink to directory A now points to relative directory B
-	(cd $testroot/wt && ln -sfh ../gamma epsilon/beta.link)
+	(cd $testroot/wt && rm epsilon/beta.link && ln -s ../gamma \
+		epsilon/beta.link)
 	# an unversioned symlink
 	(cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
 	# symlink to file A now points to non-existent file B
blob - ee6313e0eeacb23072fc990719f2ed3bc32a7459
blob + 0c032a1c4d45adc6a488c656983e61f0effc8e54
--- regress/cmdline/update.sh
+++ regress/cmdline/update.sh
@@ -2045,7 +2045,7 @@ test_update_symlink_conflicts() {
 	fi
 
 	(cd $testroot/repo && ln -sf beta alpha.link)
-	(cd $testroot/repo && ln -sfh gamma epsilon.link)
+	(cd $testroot/repo && rm epsilon.link && ln -s gamma epsilon.link)
 	(cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
 	echo 'this is regular file foo' > $testroot/repo/dotgotfoo.link
 	(cd $testroot/repo && ln -sf .got/bar dotgotbar.link)
@@ -2059,9 +2059,10 @@ test_update_symlink_conflicts() {
 	# modified symlink to file A vs modified symlink to file B
 	(cd $testroot/wt && ln -sf gamma/delta alpha.link)
 	# modified symlink to dir A vs modified symlink to file B
-	(cd $testroot/wt && ln -sfh beta epsilon.link)
+	(cd $testroot/wt && rm epsilon.link && ln -s beta epsilon.link)
 	# modeified symlink to file A vs modified symlink to dir B
-	(cd $testroot/wt && ln -sfh ../gamma epsilon/beta.link)
+	(cd $testroot/wt && rm epsilon/beta.link && ln -s ../gamma \
+		epsilon/beta.link)
 	# added regular file A vs added bad symlink to file A
 	(cd $testroot/wt && ln -sf .got/bar dotgotfoo.link)
 	(cd $testroot/wt && got add dotgotfoo.link > /dev/null)
-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de