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

Add two tests covering these cases, since they might be potential
regression points.
 t/ | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/t/ b/t/
index b8e92e1..c0a14f6 100755
--- a/t/
+++ b/t/
@@ -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 '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 
 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

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to