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