]>
Commit | Line | Data |
---|---|---|
9c7c27ee NTND |
1 | #!/bin/sh |
2 | ||
3 | test_description='basic update-index tests | |
4 | ||
5 | Tests for command-line parsing and basic operation. | |
6 | ' | |
7 | ||
8 | . ./test-lib.sh | |
9 | ||
10 | test_expect_success 'update-index --nonsense fails' ' | |
11 | test_must_fail git update-index --nonsense 2>msg && | |
9c7c27ee NTND |
12 | test -s msg |
13 | ' | |
14 | ||
ac5ad864 | 15 | test_expect_success 'update-index --nonsense dumps usage' ' |
9c7c27ee | 16 | test_expect_code 129 git update-index --nonsense 2>err && |
9a001381 | 17 | test_i18ngrep "[Uu]sage: git update-index" err |
9c7c27ee NTND |
18 | ' |
19 | ||
20 | test_expect_success 'update-index -h with corrupt index' ' | |
21 | mkdir broken && | |
22 | ( | |
23 | cd broken && | |
24 | git init && | |
25 | >.git/index && | |
26 | test_expect_code 129 git update-index -h >usage 2>&1 | |
27 | ) && | |
9a001381 | 28 | test_i18ngrep "[Uu]sage: git update-index" broken/usage |
9c7c27ee NTND |
29 | ' |
30 | ||
c8e1ee4f JK |
31 | test_expect_success '--cacheinfo complains of missing arguments' ' |
32 | test_must_fail git update-index --cacheinfo | |
33 | ' | |
34 | ||
4337b585 JK |
35 | test_expect_success '--cacheinfo does not accept blob null sha1' ' |
36 | echo content >file && | |
37 | git add file && | |
38 | git rev-parse :file >expect && | |
8125a58b | 39 | test_must_fail git update-index --cacheinfo 100644 $ZERO_OID file && |
4337b585 JK |
40 | git rev-parse :file >actual && |
41 | test_cmp expect actual | |
42 | ' | |
43 | ||
44 | test_expect_success '--cacheinfo does not accept gitlink null sha1' ' | |
45 | git init submodule && | |
46 | (cd submodule && test_commit foo) && | |
47 | git add submodule && | |
48 | git rev-parse :submodule >expect && | |
8125a58b | 49 | test_must_fail git update-index --cacheinfo 160000 $ZERO_OID submodule && |
4337b585 JK |
50 | git rev-parse :submodule >actual && |
51 | test_cmp expect actual | |
52 | ' | |
53 | ||
ec160ae1 JH |
54 | test_expect_success '--cacheinfo mode,sha1,path (new syntax)' ' |
55 | echo content >file && | |
56 | git hash-object -w --stdin <file >expect && | |
57 | ||
58 | git update-index --add --cacheinfo 100644 "$(cat expect)" file && | |
59 | git rev-parse :file >actual && | |
60 | test_cmp expect actual && | |
61 | ||
62 | git update-index --add --cacheinfo "100644,$(cat expect),elif" && | |
63 | git rev-parse :elif >actual && | |
64 | test_cmp expect actual | |
65 | ' | |
66 | ||
fa137f67 NTND |
67 | test_expect_success '.lock files cleaned up' ' |
68 | mkdir cleanup && | |
69 | ( | |
70 | cd cleanup && | |
71 | mkdir worktree && | |
72 | git init repo && | |
73 | cd repo && | |
74 | git config core.worktree ../../worktree && | |
75 | # --refresh triggers late setup_work_tree, | |
76 | # active_cache_changed is zero, rollback_lock_file fails | |
77 | git update-index --refresh && | |
78 | ! test -f .git/index.lock | |
79 | ) | |
80 | ' | |
81 | ||
22433ce4 TG |
82 | test_expect_success '--chmod=+x and chmod=-x in the same argument list' ' |
83 | >A && | |
84 | >B && | |
85 | git add A B && | |
86 | git update-index --chmod=+x A --chmod=-x B && | |
31bdb1f2 | 87 | cat >expect <<-EOF && |
88 | 100755 $EMPTY_BLOB 0 A | |
89 | 100644 $EMPTY_BLOB 0 B | |
22433ce4 TG |
90 | EOF |
91 | git ls-files --stage A B >actual && | |
92 | test_cmp expect actual | |
93 | ' | |
94 | ||
9c7c27ee | 95 | test_done |