]>
Commit | Line | Data |
---|---|---|
3f1b7b60 JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='update-index with options' | |
4 | ||
977e458c | 5 | TEST_PASSES_SANITIZE_LEAK=true |
3f1b7b60 JH |
6 | . ./test-lib.sh |
7 | ||
8 | test_expect_success basics ' | |
9 | >one && | |
10 | >two && | |
11 | >three && | |
12 | ||
13 | # need --add when adding | |
14 | test_must_fail git update-index one && | |
15 | test -z "$(git ls-files)" && | |
16 | git update-index --add one && | |
17 | test zone = "z$(git ls-files)" && | |
18 | ||
19 | # update-index is atomic | |
20 | echo 1 >one && | |
21 | test_must_fail git update-index one two && | |
22 | echo "M one" >expect && | |
23 | git diff-files --name-status >actual && | |
24 | test_cmp expect actual && | |
25 | ||
26 | git update-index --add one two three && | |
08495412 | 27 | test_write_lines one three two >expect && |
3f1b7b60 JH |
28 | git ls-files >actual && |
29 | test_cmp expect actual && | |
30 | ||
31 | test_tick && | |
32 | ( | |
33 | test_create_repo xyzzy && | |
34 | cd xyzzy && | |
35 | >file && | |
2c2d0f9f | 36 | git add file && |
3f1b7b60 JH |
37 | git commit -m "sub initial" |
38 | ) && | |
39 | git add xyzzy && | |
40 | ||
41 | test_tick && | |
42 | git commit -m initial && | |
43 | git tag initial | |
44 | ' | |
45 | ||
46 | test_expect_success '--ignore-missing --refresh' ' | |
47 | git reset --hard initial && | |
48 | echo 2 >one && | |
49 | test_must_fail git update-index --refresh && | |
50 | echo 1 >one && | |
51 | git update-index --refresh && | |
52 | rm -f two && | |
53 | test_must_fail git update-index --refresh && | |
54 | git update-index --ignore-missing --refresh | |
55 | ||
56 | ' | |
57 | ||
58 | test_expect_success '--unmerged --refresh' ' | |
59 | git reset --hard initial && | |
60 | info=$(git ls-files -s one | sed -e "s/ 0 / 1 /") && | |
61 | git rm --cached one && | |
62 | echo "$info" | git update-index --index-info && | |
63 | test_must_fail git update-index --refresh && | |
64 | git update-index --unmerged --refresh && | |
65 | echo 2 >two && | |
66 | test_must_fail git update-index --unmerged --refresh >actual && | |
67 | grep two actual && | |
68 | ! grep one actual && | |
69 | ! grep three actual | |
70 | ' | |
71 | ||
72 | test_expect_success '--ignore-submodules --refresh (1)' ' | |
73 | git reset --hard initial && | |
74 | rm -f two && | |
75 | test_must_fail git update-index --ignore-submodules --refresh | |
76 | ' | |
77 | ||
78 | test_expect_success '--ignore-submodules --refresh (2)' ' | |
79 | git reset --hard initial && | |
80 | test_tick && | |
81 | ( | |
82 | cd xyzzy && | |
83 | git commit -m "sub second" --allow-empty | |
84 | ) && | |
85 | test_must_fail git update-index --refresh && | |
86 | test_must_fail git update-index --ignore-missing --refresh && | |
87 | git update-index --ignore-submodules --refresh | |
88 | ' | |
89 | ||
90 | test_done |