3 test_description
='basic update-index tests
5 Tests for command-line parsing and basic operation.
10 test_expect_success
'update-index --nonsense fails' '
11 test_must_fail git update-index --nonsense 2>msg &&
15 test_expect_success
'update-index --nonsense dumps usage' '
16 test_expect_code 129 git update-index --nonsense 2>err &&
17 test_i18ngrep "[Uu]sage: git update-index" err
20 test_expect_success
'update-index -h with corrupt index' '
26 test_expect_code 129 git update-index -h >usage 2>&1
28 test_i18ngrep "[Uu]sage: git update-index" broken/usage
31 test_expect_success
'--cacheinfo complains of missing arguments' '
32 test_must_fail git update-index --cacheinfo
35 test_expect_success
'--cacheinfo does not accept blob null sha1' '
38 git rev-parse :file >expect &&
39 test_must_fail git update-index --verbose --cacheinfo 100644 $ZERO_OID file >out &&
40 git rev-parse :file >actual &&
41 test_cmp expect actual &&
43 cat >expect <<-\EOF &&
49 test_expect_success
'--cacheinfo does not accept gitlink null sha1' '
51 (cd submodule && test_commit foo) &&
53 git rev-parse :submodule >expect &&
54 test_must_fail git update-index --cacheinfo 160000 $ZERO_OID submodule &&
55 git rev-parse :submodule >actual &&
56 test_cmp expect actual
59 test_expect_success
'--cacheinfo mode,sha1,path (new syntax)' '
61 git hash-object -w --stdin <file >expect &&
63 git update-index --add --cacheinfo 100644 "$(cat expect)" file &&
64 git rev-parse :file >actual &&
65 test_cmp expect actual &&
67 git update-index --add --verbose --cacheinfo "100644,$(cat expect),elif" >out &&
68 git rev-parse :elif >actual &&
69 test_cmp expect actual &&
71 cat >expect <<-\EOF &&
77 test_expect_success
'.lock files cleaned up' '
84 git config core.worktree ../../worktree &&
85 # --refresh triggers late setup_work_tree,
86 # the_index.cache_changed is zero, rollback_lock_file fails
87 git update-index --refresh --verbose >out &&
88 test_must_be_empty out &&
89 ! test -f .git/index.lock
93 test_expect_success
'--chmod=+x and chmod=-x in the same argument list' '
97 git update-index --verbose --chmod=+x A --chmod=-x B >out &&
98 cat >expect <<-\EOF &&
104 test_cmp expect out &&
106 cat >expect <<-EOF &&
107 100755 $EMPTY_BLOB 0 A
108 100644 $EMPTY_BLOB 0 B
110 git ls-files --stage A B >actual &&
111 test_cmp expect actual