Skip to content

Commit 052b255

Browse files
sunshinecogitster
authored andcommitted
t2004: demonstrate broken relative path printing
checkout-index --temp only properly prints relative paths which are descendants of the current directory. Paths in ancestor or sibling directories (or their children) are often printed in mangled form. For example: mkdir a bbb && >file && >bbb/file && git update-index --add file bbb/file && cd a && git checkout-index --temp ../file ../bbb/file prints: .merge_file_ooblek le .merge_file_igloo0 b/file rather than the correct: .merge_file_ooblek ../file .merge_file_igloo0 ../bbb/file Unfortunately, testing is complicated slightly by relative paths sometimes _appearing_ to be printed correctly, but this is an accident of implementation in which a "correct" copy of the string exists in memory beyond the end of the real string, and that "correct" copy gets printed. This test takes care to avoid the accidentally "correct" behavior by testing with a filename longer than the directory name in which checkout-index is invoked. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 66e28e9 commit 052b255

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

t/t2004-checkout-cache-temp.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,16 @@ test_expect_success 'checkout --temp symlink' '
206206
test $(cat $p) = path7
207207
'
208208

209+
test_expect_failure 'emit well-formed relative path' '
210+
rm -f path* .merge_* actual .git/index &&
211+
>path0123456789 &&
212+
git update-index --add path0123456789 &&
213+
(
214+
cd asubdir &&
215+
git checkout-index --temp -- ../path0123456789 >actual &&
216+
test_line_count = 1 actual &&
217+
test $(cut "-d " -f2 actual) = ../path0123456789
218+
)
219+
'
220+
209221
test_done

0 commit comments

Comments
 (0)