3 test_description='basic checkout-index tests
8 test_expect_success 'checkout-index --gobbledegook' '
9 test_expect_code 129 git checkout-index --gobbledegook 2>err &&
10 test_i18ngrep "[Uu]sage" err
13 test_expect_success 'checkout-index -h in broken repository' '
19 test_expect_code 129 git checkout-index -h >usage 2>&1
21 test_i18ngrep "[Uu]sage" broken/usage
24 test_expect_success 'checkout-index reports errors (cmdline)' '
25 test_must_fail git checkout-index -- does-not-exist 2>stderr &&
26 test_i18ngrep not.in.the.cache stderr
29 test_expect_success 'checkout-index reports errors (stdin)' '
31 test_must_fail git checkout-index --stdin 2>stderr &&
32 test_i18ngrep not.in.the.cache stderr
34 for mode in 'case' 'utf-8'
37 case) dir='A' symlink='a' mode_prereq='CASE_INSENSITIVE_FS' ;;
39 dir=$(printf "\141\314\210") symlink=$(printf "\303\244")
40 mode_prereq='UTF8_NFD_TO_NFC' ;;
43 test_expect_success SYMLINKS,$mode_prereq \
44 "checkout-index with $mode-collision don't write to the wrong place" '
45 git init $mode-collision &&
50 empty_obj_hex=$(git hash-object -w --stdin </dev/null) &&
51 symlink_hex=$(printf "%s" "$PWD/target-dir" | git hash-object -w --stdin) &&
54 100644 blob ${empty_obj_hex} ${dir}/x
55 100644 blob ${empty_obj_hex} ${dir}/y
56 100644 blob ${empty_obj_hex} ${dir}/z
57 120000 blob ${symlink_hex} ${symlink}
60 git update-index --index-info <objs &&
62 # Note: the order is important here to exercise the
63 # case where the file at ${dir} has its type changed by
64 # the time Git tries to check out ${dir}/z.
66 # Also, we use core.precomposeUnicode=false because we
67 # want Git to treat the UTF-8 paths transparently on
68 # Mac OS, matching what is in the index.
70 git -c core.precomposeUnicode=false checkout-index -f \
71 ${dir}/x ${dir}/y ${symlink} ${dir}/z &&
73 # Should not create ${dir}/z at ${symlink}/z
74 test_path_is_missing target-dir/z
80 test_expect_success 'checkout-index --temp correctly reports error on missing blobs' '
81 test_when_finished git reset --hard &&
82 missing_blob=$(echo "no such blob here" | git hash-object --stdin) &&
84 100644 $missing_blob file
85 120000 $missing_blob symlink
87 git update-index --index-info <objs &&
89 test_must_fail git checkout-index --temp symlink file 2>stderr &&
90 test_i18ngrep "unable to read sha1 file of file ($missing_blob)" stderr &&
91 test_i18ngrep "unable to read sha1 file of symlink ($missing_blob)" stderr
94 test_expect_success 'checkout-index --temp correctly reports error for submodules' '
96 test_commit -C sub file &&
97 git submodule add ./sub &&
99 test_must_fail git checkout-index --temp sub 2>stderr &&
100 test_i18ngrep "cannot create temporary submodule sub" stderr