Thread (47 messages) flat view 47 messages, 5 authors, 2016-06-15
DORMANTno replies REVIEWED: 1 (0M)

Revision v6 of 3 in this series; 1 review trailer.

Revisions (3)
  1. v4 [diff vs current]
  2. v5 [diff vs current]
  3. v6 current

[PATCH v6 4/6] t0060: Add tests for prefix_path when path begins with work tree

From: Martin Erik Werner <hidden>
Date: 2016-06-15 22:59:49
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
Reviewed-by: Duy Nguyen <redacted>
---
 t/t0060-path-utils.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index b8e92e1..c0a14f6 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 '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
-- 
1.8.5.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help