Skip to content

Commit e131daa

Browse files
ienorandgitster
authored andcommitted
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 <[email protected]> Reviewed-by: Duy Nguyen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e5aa1fc commit e131daa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

t/t0060-path-utils.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,16 @@ test_expect_success 'prefix_path works with only absolute path to work tree' '
201201
test_cmp expected actual
202202
'
203203

204+
test_expect_success 'prefix_path rejects absolute path to dir with same beginning as work tree' '
205+
test_must_fail test-path-utils prefix_path prefix "$(pwd)a"
206+
'
207+
208+
test_expect_success SYMLINKS 'prefix_path works with absolute path to a symlink to work tree having same beginning as work tree' '
209+
git init repo &&
210+
ln -s repo repolink &&
211+
test "a" = "$(cd repo && test-path-utils prefix_path prefix "$(pwd)/../repolink/a")"
212+
'
213+
204214
relative_path /foo/a/b/c/ /foo/a/b/ c/
205215
relative_path /foo/a/b/c/ /foo/a/b c/
206216
relative_path /foo/a//b//c/ ///foo/a/b// c/ POSIX

0 commit comments

Comments
 (0)