t3004: add test for ls-files on symlinks via absolute paths

When symlinks in the working tree are manipulated using the absolute path, git dereferences them, and tries to manipulate the link target instead. This causes most high-level functions to misbehave when acting on symlinks given via absolute paths. For example $ git add /dir/repo/symlink attempts to add the target of the symlink rather than the symlink itself, which is usually not what the user intends to do. This is a regression introduced by 18e051a: setup: translate symlinks in filename when using absolute paths (which did not take symlinks inside the work tree into consideration). Add a known-breakage test using the ls-files function, checking both if the symlink leads to a target in the same directory, and a target in the above directory. Signed-off-by: Martin Erik Werner <martinerikwerner@gmail.com> Tested-by: Martin Erik Werner <martinerikwerner@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Feb 4, 2014 at 15:25 UTC f02033f1d02a55b32815a4702389e4d492f38bcc
1 file changed +17
t/t3004-ls-files-basic.sh
+17
@@ -36,4 +36,21 @@ test_expect_success 'ls-files -h in corrupt repository' '
36 test_i18ngrep "[Uu]sage: git ls-files " broken/usage
37 '
38
39 +test_expect_failure SYMLINKS 'ls-files with absolute paths to symlinks' '
40 + mkdir subs &&
41 + ln -s nosuch link &&
42 + ln -s ../nosuch subs/link &&
43 + git add link subs/link &&
44 + git ls-files -s link subs/link >expect &&
45 + git ls-files -s "$(pwd)/link" "$(pwd)/subs/link" >actual &&
46 + test_cmp expect actual &&
47 +
48 + (
49 + cd subs &&
50 + git ls-files -s link >../expect &&
51 + git ls-files -s "$(pwd)/link" >../actual
52 + ) &&
53 + test_cmp expect actual
54 +'
55 +
56 test_done