]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t2107-update-index-basic.sh
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 &&
16 test_expect_success
'update-index --nonsense dumps usage' '
17 test_expect_code 129 git update-index --nonsense 2>err &&
18 test_i18ngrep "[Uu]sage: git update-index" err
21 test_expect_success
'update-index -h with corrupt index' '
27 test_expect_code 129 git update-index -h >usage 2>&1
29 test_i18ngrep "[Uu]sage: git update-index" broken/usage
32 test_expect_success
'--cacheinfo complains of missing arguments' '
33 test_must_fail git update-index --cacheinfo
36 test_expect_success
'--cacheinfo does not accept blob null sha1' '
39 git rev-parse :file >expect &&
40 test_must_fail git update-index --cacheinfo 100644 $ZERO_OID file &&
41 git rev-parse :file >actual &&
42 test_cmp expect actual
45 test_expect_success
'--cacheinfo does not accept gitlink null sha1' '
47 (cd submodule && test_commit foo) &&
49 git rev-parse :submodule >expect &&
50 test_must_fail git update-index --cacheinfo 160000 $ZERO_OID submodule &&
51 git rev-parse :submodule >actual &&
52 test_cmp expect actual
55 test_expect_success
'--cacheinfo mode,sha1,path (new syntax)' '
57 git hash-object -w --stdin <file >expect &&
59 git update-index --add --cacheinfo 100644 "$(cat expect)" file &&
60 git rev-parse :file >actual &&
61 test_cmp expect actual &&
63 git update-index --add --cacheinfo "100644,$(cat expect),elif" &&
64 git rev-parse :elif >actual &&
65 test_cmp expect actual
68 test_expect_success
'.lock files cleaned up' '
75 git config core.worktree ../../worktree &&
76 # --refresh triggers late setup_work_tree,
77 # active_cache_changed is zero, rollback_lock_file fails
78 git update-index --refresh &&
79 ! test -f .git/index.lock
83 test_expect_success
'--chmod=+x and chmod=-x in the same argument list' '
87 git update-index --chmod=+x A --chmod=-x B &&
89 100755 $EMPTY_BLOB 0 A
90 100644 $EMPTY_BLOB 0 B
92 git ls-files --stage A B >actual &&
93 test_cmp expect actual