Download raw body.
install symbolic links in the work tree
On Thu, May 28, 2020 at 12:51:58PM +0200, Stefan Sperling wrote:
> This adds support for creating symbolic links in the work tree.
>
> At present symbolic links in the repository are installed as regular
> files in the work tree, which contain the link target path.
> We keep doing so as a fallback if a particular symbolic link cannot
> be installed.
>
> A big concern here is to avoid creating symbolic links which point
> anywhere outside of the work tree. Did I get this right?
>
This appears to work properly.
> Only tested with 'got checkout' yet, but more tests will likely follow.
>
> ok?
Checkout is working just fine. I added a test for rm, which points to a
problem.
Calling got rm marks the actual file for removal, instead of the
symlink. Also, the test errors out on epsilon, since it points to a
directory and got rm expects -R in that situation.
This is all I've tested, but it makes me wonder how diff and blame are
going to handle the links.
I have not had time to check diff for correctness.
--
Tracey Emery
diff 887ab48904d4fec78cd74f4ad026e8c59899a974 /home/tracey/src/got
blob - d96dfe3602ef3a7ee2a20198083c20e833f9567a
file + regress/cmdline/rm.sh
--- regress/cmdline/rm.sh
+++ regress/cmdline/rm.sh
@@ -404,6 +404,38 @@ function test_rm_subtree {
test_done "$testroot" "$ret"
}
+function test_rm_symlink {
+ local testroot=`test_init rm_symlink`
+
+ (cd $testroot/repo && ln -s alpha alpha.link)
+ (cd $testroot/repo && ln -s epsilon epsilon.link)
+ (cd $testroot/repo && ln -s /etc/passwd passwd.link)
+ (cd $testroot/repo && git add .)
+ git_commit $testroot/repo -m "add a symlink"
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ echo 'D alpha.link' > $testroot/stdout.expected
+ echo 'D epsilon.link' >> $testroot/stdout.expected
+ echo 'D passwd.link' >> $testroot/stdout.expected
+ (cd $testroot/wt && got rm alpha.link epsilon.link password.link > \
+ $testroot/stdout)
+
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+ test_done "$testroot" "$ret"
+
+}
run_test test_rm_basic
run_test test_rm_with_local_mods
run_test test_double_rm
@@ -411,3 +443,4 @@ run_test test_rm_and_add_elsewhere
run_test test_rm_directory
run_test test_rm_directory_keep_files
run_test test_rm_subtree
+run_test test_rm_symlink
install symbolic links in the work tree