summaryrefslogtreecommitdiff
path: root/t/t0060-path-utils.sh
diff options
context:
space:
mode:
authorMartin Erik Werner <martinerikwerner@gmail.com>2014-02-04 14:25:18 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-02-04 20:08:47 (GMT)
commite131daa4c6baa53aba22e5d8bc1defa83b443bf0 (patch)
treeae5e28d1fb9508e2335e0b960b96590ea89a3797 /t/t0060-path-utils.sh
parente5aa1fc472696bfc337b3f128d45c1ef2aba394d (diff)
downloadgit-e131daa4c6baa53aba22e5d8bc1defa83b443bf0.zip
git-e131daa4c6baa53aba22e5d8bc1defa83b443bf0.tar.gz
git-e131daa4c6baa53aba22e5d8bc1defa83b443bf0.tar.bz2
t0060: add tests for prefix_path when path begins with work tree
One edge-case that isn't currently checked in the tests is the beginning of the path matching the work tree, despite the target not actually being the work tree, for example: path = /dir/repoa work_tree = /dir/repo should fail since the path is outside the repo. However, if /dir/repoa is in fact a symlink that points to /dir/repo, it should instead succeed. Add two tests covering these cases, since they might be potential regression points. Signed-off-by: Martin Erik Werner <martinerikwerner@gmail.com> Reviewed-by: Duy Nguyen <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0060-path-utils.sh')
-rwxr-xr-xt/t0060-path-utils.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index b8e92e1..f8286b1 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -201,6 +201,16 @@ test_expect_success 'prefix_path works with only absolute path to work tree' '
test_cmp expected actual
'
+test_expect_success 'prefix_path rejects absolute path to dir with same beginning as work tree' '
+ test_must_fail test-path-utils prefix_path prefix "$(pwd)a"
+'
+
+test_expect_success SYMLINKS 'prefix_path works with absolute path to a symlink to work tree having same beginning as work tree' '
+ git init repo &&
+ ln -s repo repolink &&
+ test "a" = "$(cd repo && test-path-utils prefix_path prefix "$(pwd)/../repolink/a")"
+'
+
relative_path /foo/a/b/c/ /foo/a/b/ c/
relative_path /foo/a/b/c/ /foo/a/b c/
relative_path /foo/a//b//c/ ///foo/a/b// c/ POSIX