3 test_description
='basic checkout-index tests
6 TEST_PASSES_SANITIZE_LEAK
=true
9 test_expect_success
'checkout-index --gobbledegook' '
10 test_expect_code 129 git checkout-index --gobbledegook 2>err &&
11 test_grep "[Uu]sage" err
14 test_expect_success
'checkout-index -h in broken repository' '
20 test_expect_code 129 git checkout-index -h >usage 2>&1
22 test_grep "[Uu]sage" broken/usage
25 test_expect_success
'checkout-index reports errors (cmdline)' '
26 test_must_fail git checkout-index -- does-not-exist 2>stderr &&
27 test_grep not.in.the.cache stderr
30 test_expect_success
'checkout-index reports errors (stdin)' '
32 test_must_fail git checkout-index --stdin 2>stderr &&
33 test_grep not.in.the.cache stderr
35 for mode
in 'case' 'utf-8'
38 case) dir
='A' symlink
='a' mode_prereq
='CASE_INSENSITIVE_FS' ;;
40 dir
=$
(printf "\141\314\210") symlink
=$
(printf "\303\244")
41 mode_prereq
='UTF8_NFD_TO_NFC' ;;
44 test_expect_success SYMLINKS
,$mode_prereq \
45 "checkout-index with $mode-collision don't write to the wrong place" '
46 git init $mode-collision &&
51 empty_obj_hex=$(git hash-object -w --stdin </dev/null) &&
52 symlink_hex=$(printf "%s" "$PWD/target-dir" | git hash-object -w --stdin) &&
55 100644 blob ${empty_obj_hex} ${dir}/x
56 100644 blob ${empty_obj_hex} ${dir}/y
57 100644 blob ${empty_obj_hex} ${dir}/z
58 120000 blob ${symlink_hex} ${symlink}
61 git update-index --index-info <objs &&
63 # Note: the order is important here to exercise the
64 # case where the file at ${dir} has its type changed by
65 # the time Git tries to check out ${dir}/z.
67 # Also, we use core.precomposeUnicode=false because we
68 # want Git to treat the UTF-8 paths transparently on
69 # Mac OS, matching what is in the index.
71 git -c core.precomposeUnicode=false checkout-index -f \
72 ${dir}/x ${dir}/y ${symlink} ${dir}/z &&
74 # Should not create ${dir}/z at ${symlink}/z
75 test_path_is_missing target-dir/z
81 test_expect_success
'checkout-index --temp correctly reports error on missing blobs' '
82 test_when_finished git reset --hard &&
83 missing_blob=$(echo "no such blob here" | git hash-object --stdin) &&
85 100644 $missing_blob file
86 120000 $missing_blob symlink
88 git update-index --index-info <objs &&
90 test_must_fail git checkout-index --temp symlink file 2>stderr &&
91 test_grep "unable to read sha1 file of file ($missing_blob)" stderr &&
92 test_grep "unable to read sha1 file of symlink ($missing_blob)" stderr
95 test_expect_success
'checkout-index --temp correctly reports error for submodules' '
97 test_commit -C sub file &&
98 git submodule add ./sub &&
100 test_must_fail git checkout-index --temp sub 2>stderr &&
101 test_grep "cannot create temporary submodule sub" stderr