diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2014-12-24 12:43:15 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-12-29 21:56:14 +0300 |
commit | 052b2551adf308e663dbb3fda9ab0347e18dd42b (patch) | |
tree | 79e26bb8ae1240d31a02fe9bc713dfbd27057bfb /t | |
parent | 66e28e93bb817791cff837df9df0469962e47618 (diff) |
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 <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t2004-checkout-cache-temp.sh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/t/t2004-checkout-cache-temp.sh b/t/t2004-checkout-cache-temp.sh index 602fbc753c..3c2b2b9046 100755 --- a/t/t2004-checkout-cache-temp.sh +++ b/t/t2004-checkout-cache-temp.sh @@ -206,4 +206,16 @@ test_expect_success 'checkout --temp symlink' ' test $(cat $p) = path7 ' +test_expect_failure 'emit well-formed relative path' ' + rm -f path* .merge_* actual .git/index && + >path0123456789 && + git update-index --add path0123456789 && + ( + cd asubdir && + git checkout-index --temp -- ../path0123456789 >actual && + test_line_count = 1 actual && + test $(cut "-d " -f2 actual) = ../path0123456789 + ) +' + test_done |