sparse-index: loose integration with cache_tree_verify()
[git] / t / t2006-checkout-index-basic.sh
1 #!/bin/sh
2
3 test_description='basic checkout-index tests
4 '
5
6 . ./test-lib.sh
7
8 test_expect_success 'checkout-index --gobbledegook' '
9         test_expect_code 129 git checkout-index --gobbledegook 2>err &&
10         test_i18ngrep "[Uu]sage" err
11 '
12
13 test_expect_success 'checkout-index -h in broken repository' '
14         mkdir broken &&
15         (
16                 cd broken &&
17                 git init &&
18                 >.git/index &&
19                 test_expect_code 129 git checkout-index -h >usage 2>&1
20         ) &&
21         test_i18ngrep "[Uu]sage" broken/usage
22 '
23
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
27 '
28
29 test_expect_success 'checkout-index reports errors (stdin)' '
30         echo does-not-exist |
31         test_must_fail git checkout-index --stdin 2>stderr &&
32         test_i18ngrep not.in.the.cache stderr
33 '
34
35 test_expect_success 'checkout-index --temp correctly reports error on missing blobs' '
36         test_when_finished git reset --hard &&
37         missing_blob=$(echo "no such blob here" | git hash-object --stdin) &&
38         cat >objs <<-EOF &&
39         100644 $missing_blob    file
40         120000 $missing_blob    symlink
41         EOF
42         git update-index --index-info <objs &&
43
44         test_must_fail git checkout-index --temp symlink file 2>stderr &&
45         test_i18ngrep "unable to read sha1 file of file ($missing_blob)" stderr &&
46         test_i18ngrep "unable to read sha1 file of symlink ($missing_blob)" stderr
47 '
48
49 test_expect_success 'checkout-index --temp correctly reports error for submodules' '
50         git init sub &&
51         test_commit -C sub file &&
52         git submodule add ./sub &&
53         git commit -m sub &&
54         test_must_fail git checkout-index --temp sub 2>stderr &&
55         test_i18ngrep "cannot create temporary submodule sub" stderr
56 '
57
58 test_done