commit - 8ba819a3547825c0e0d657a7e41610da16f6cd4f
commit + 0ab20ee9ead0bcdb626ef9fb52d63f58e13082a5
blob - 1f4dfd3657f769e5b82c587069c4f33f57427be0
blob + 03438c0b820def82a8574d7f14c80d53cc19a1c7
--- lib/worktree.c
+++ lib/worktree.c
}
/* Only allow symlinks pointing at paths within the work tree. */
- if (!got_path_is_child(resolved_path ? resolved_path : target_path,
- worktree->root_path, strlen(worktree->root_path))) {
+ if (!got_path_is_child(resolved_path ? resolved_path : (abspath ?
+ abspath : target_path), worktree->root_path,
+ strlen(worktree->root_path))) {
/* install as a regular file */
got_object_blob_rewind(blob);
err = install_blob(worktree, ondisk_path, path,
blob - 8bb0b0d52dfb1516850a25bf3e9b77204b3ae314
blob + 6cde66bae40dff4c5b2cb46b31fe7b2ca5f1df13
--- regress/cmdline/checkout.sh
+++ regress/cmdline/checkout.sh
(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 && ln -s ../beta epsilon/beta.link)
+ (cd $testroot/repo && ln -s nonexistent nonexistent.link)
(cd $testroot/repo && git add .)
- git_commit $testroot/repo -m "add a symlink"
+ git_commit $testroot/repo -m "add symlinks"
got checkout $testroot/repo $testroot/wt > /dev/null
ret="$?"
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/content.expected $testroot/content
- fi
- test_done "$testroot" "$ret"
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+ readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
+ echo "../beta" > $testroot/stdout.expected
+ 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
+
+ readlink $testroot/wt/nonexistent.link > $testroot/stdout
+ echo "nonexistent" > $testroot/stdout.expected
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
+ test_done "$testroot" "$ret"
}
run_test test_checkout_basic