The sixteenth batch
[alt-git.git] / t / t2103-update-index-ignore-missing.sh
blobe9451cd567cd61ffb678ee33d3c01e646b4cbe3a
1 #!/bin/sh
3 test_description='update-index with options'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success basics '
9 >one &&
10 >two &&
11 >three &&
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)" &&
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 &&
26 git update-index --add one two three &&
27 test_write_lines one three two >expect &&
28 git ls-files >actual &&
29 test_cmp expect actual &&
31 test_tick &&
33 test_create_repo xyzzy &&
34 cd xyzzy &&
35 >file &&
36 git add file &&
37 git commit -m "sub initial"
38 ) &&
39 git add xyzzy &&
41 test_tick &&
42 git commit -m initial &&
43 git tag initial
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
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
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
78 test_expect_success '--ignore-submodules --refresh (2)' '
79 git reset --hard initial &&
80 test_tick &&
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
90 test_done