Merge branch 'maint-1.6.3' into maint
[git/dkf.git] / t / t2103-update-index-ignore-missing.sh
blob332694e7d38083fad18b3e53e4def268d54e9423
1 #!/bin/sh
3 test_description='update-index with options'
5 . ./test-lib.sh
7 test_expect_success basics '
8 >one &&
9 >two &&
10 >three &&
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)" &&
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 &&
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 &&
30 test_tick &&
32 test_create_repo xyzzy &&
33 cd xyzzy &&
34 >file &&
35 git add file
36 git commit -m "sub initial"
37 ) &&
38 git add xyzzy &&
40 test_tick &&
41 git commit -m initial &&
42 git tag initial
45 test_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
57 test_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
71 test_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
77 test_expect_success '--ignore-submodules --refresh (2)' '
78 git reset --hard initial &&
79 test_tick &&
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
89 test_done