t0060: add test for prefix_path on symlinks via absolute paths
authorMartin Erik Werner <martinerikwerner@gmail.com>
Tue, 4 Feb 2014 14:25:16 +0000 (15:25 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 4 Feb 2014 19:25:15 +0000 (11:25 -0800)
When symlinks in the working tree are manipulated using the absolute
path, git dereferences them, and tries to manipulate the link target
instead.

This applies to most high-level commands but prefix_path is the common
denominator for all of them.

Add a known-breakage tests using the prefix_path function, which
currently uses real_path, causing the dereference.

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>
t/t0060-path-utils.sh
index 07c10c8dca80b9d289431a72d5bf120ca442113d..0bba9887e9cc5dcdd9eb62a56bcd74c5c9acd644 100755 (executable)
@@ -190,6 +190,11 @@ test_expect_success SYMLINKS 'real path works on symlinks' '
        test "$sym" = "$(test-path-utils real_path "$dir2/syml")"
 '
 
+test_expect_failure SYMLINKS 'prefix_path works with absolute paths to work tree symlinks' '
+       ln -s target symlink &&
+       test "$(test-path-utils prefix_path prefix "$(pwd)/symlink")" = "symlink"
+'
+
 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