]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2201-add-update-typechange.sh
Enhance hold_lock_file_for_{update,append}() API
[thirdparty/git.git] / t / t2201-add-update-typechange.sh
CommitLineData
6301f303
JH
1#!/bin/sh
2
3test_description='more git add -u'
4
5. ./test-lib.sh
6
7_z40=0000000000000000000000000000000000000000
8
9test_expect_success setup '
10 >xyzzy &&
11 _empty=$(git hash-object --stdin <xyzzy) &&
12 >yomin &&
13 >caskly &&
14 ln -s frotz nitfol &&
15 mkdir rezrov &&
16 >rezrov/bozbar &&
17 git add caskly xyzzy yomin nitfol rezrov/bozbar &&
18
19 test_tick &&
20 git commit -m initial
21
22'
23
24test_expect_success modify '
25 rm -f xyzzy yomin nitfol caskly &&
26 # caskly disappears (not a submodule)
27 mkdir caskly &&
28 # nitfol changes from symlink to regular
29 >nitfol &&
30 # rezrov/bozbar disappears
31 rm -fr rezrov &&
32 ln -s xyzzy rezrov &&
33 # xyzzy disappears (not a submodule)
34 mkdir xyzzy &&
35 echo gnusto >xyzzy/bozbar &&
36 # yomin gets replaced with a submodule
37 mkdir yomin &&
38 >yomin/yomin &&
39 (
40 cd yomin &&
41 git init &&
42 git add yomin &&
43 git commit -m "sub initial"
44 ) &&
45 yomin=$(GIT_DIR=yomin/.git git rev-parse HEAD) &&
46 # yonk is added and then turned into a submodule
47 # this should appear as T in diff-files and as A in diff-index
48 >yonk &&
49 git add yonk &&
50 rm -f yonk &&
51 mkdir yonk &&
52 >yonk/yonk &&
53 (
54 cd yonk &&
55 git init &&
56 git add yonk &&
57 git commit -m "sub initial"
58 ) &&
59 yonk=$(GIT_DIR=yonk/.git git rev-parse HEAD) &&
60 # zifmia is added and then removed
61 # this should appear in diff-files but not in diff-index.
62 >zifmia &&
63 git add zifmia &&
64 rm -f zifmia &&
65 mkdir zifmia &&
66 {
67 git ls-tree -r HEAD |
68 sed -e "s/^/:/" -e "
69 / caskly/{
70 s/ caskly/ $_z40 D&/
71 s/blob/000000/
72 }
73 / nitfol/{
74 s/ nitfol/ $_z40 T&/
75 s/blob/100644/
76 }
77 / rezrov.bozbar/{
78 s/ rezrov.bozbar/ $_z40 D&/
79 s/blob/000000/
80 }
81 / xyzzy/{
82 s/ xyzzy/ $_z40 D&/
83 s/blob/000000/
84 }
85 / yomin/{
86 s/ yomin/ $_z40 T&/
87 s/blob/160000/
88 }
89 "
90 } >expect &&
91 {
92 cat expect
93 echo ":100644 160000 $_empty $_z40 T yonk"
94 echo ":100644 000000 $_empty $_z40 D zifmia"
95 } >expect-files &&
96 {
97 cat expect
98 echo ":000000 160000 $_z40 $_z40 A yonk"
99 } >expect-index &&
100 {
101 echo "100644 $_empty 0 nitfol"
102 echo "160000 $yomin 0 yomin"
103 echo "160000 $yonk 0 yonk"
104 } >expect-final
105'
106
f58dbf23 107test_expect_success diff-files '
6301f303 108 git diff-files --raw >actual &&
2b14d072 109 test_cmp expect-files actual
6301f303
JH
110'
111
948dd346 112test_expect_success diff-index '
6301f303 113 git diff-index --raw HEAD -- >actual &&
2b14d072 114 test_cmp expect-index actual
6301f303
JH
115'
116
f58dbf23 117test_expect_success 'add -u' '
6301f303
JH
118 rm -f ".git/saved-index" &&
119 cp -p ".git/index" ".git/saved-index" &&
120 git add -u &&
121 git ls-files -s >actual &&
2b14d072 122 test_cmp expect-final actual
6301f303
JH
123'
124
f58dbf23 125test_expect_success 'commit -a' '
6301f303
JH
126 if test -f ".git/saved-index"
127 then
128 rm -f ".git/index" &&
129 mv ".git/saved-index" ".git/index"
130 fi &&
131 git commit -m "second" -a &&
132 git ls-files -s >actual &&
2b14d072 133 test_cmp expect-final actual &&
6301f303
JH
134 rm -f .git/index &&
135 git read-tree HEAD &&
136 git ls-files -s >actual &&
2b14d072 137 test_cmp expect-final actual
6301f303
JH
138'
139
140test_done