Windows ANSI - hook write()
[git/mingw/4msysgit/peterh.git] / t / t2201-add-update-typechange.sh
blob69ac97e64876b42645227519be566de533478e6d
1 #!/bin/sh
3 test_description='more git add -u'
5 . ./test-lib.sh
7 symlink_change=T
8 if test "$no_symlinks"
9 then
10 ln () {
11 echo -n "$2" > "$3"
13 symlink_change=M
16 _z40=0000000000000000000000000000000000000000
18 test_expect_success setup '
19 >xyzzy &&
20 _empty=$(git hash-object --stdin <xyzzy) &&
21 >yomin &&
22 >caskly &&
23 ln -s frotz nitfol &&
24 mkdir rezrov &&
25 >rezrov/bozbar &&
26 git add caskly xyzzy yomin nitfol rezrov/bozbar &&
28 test_tick &&
29 git commit -m initial
33 test_expect_success modify '
34 rm -f xyzzy yomin nitfol caskly &&
35 # caskly disappears (not a submodule)
36 mkdir caskly &&
37 # nitfol changes from symlink to regular
38 >nitfol &&
39 # rezrov/bozbar disappears
40 rm -fr rezrov &&
41 ln -s xyzzy rezrov &&
42 # xyzzy disappears (not a submodule)
43 mkdir xyzzy &&
44 echo gnusto >xyzzy/bozbar &&
45 # yomin gets replaced with a submodule
46 mkdir yomin &&
47 >yomin/yomin &&
49 cd yomin &&
50 git init &&
51 git add yomin &&
52 git commit -m "sub initial"
53 ) &&
54 yomin=$(GIT_DIR=yomin/.git git rev-parse HEAD) &&
55 # yonk is added and then turned into a submodule
56 # this should appear as T in diff-files and as A in diff-index
57 >yonk &&
58 git add yonk &&
59 rm -f yonk &&
60 mkdir yonk &&
61 >yonk/yonk &&
63 cd yonk &&
64 git init &&
65 git add yonk &&
66 git commit -m "sub initial"
67 ) &&
68 yonk=$(GIT_DIR=yonk/.git git rev-parse HEAD) &&
69 # zifmia is added and then removed
70 # this should appear in diff-files but not in diff-index.
71 >zifmia &&
72 git add zifmia &&
73 rm -f zifmia &&
74 mkdir zifmia &&
76 git ls-tree -r HEAD |
77 sed -e "s/^/:/" -e "
78 / caskly/{
79 s/ caskly/ $_z40 D&/
80 s/blob/000000/
82 / nitfol/{
83 s/ nitfol/ $_z40 $symlink_change&/
84 s/blob/100644/
86 / rezrov.bozbar/{
87 s/ rezrov.bozbar/ $_z40 D&/
88 s/blob/000000/
90 / xyzzy/{
91 s/ xyzzy/ $_z40 D&/
92 s/blob/000000/
94 / yomin/{
95 s/ yomin/ $_z40 T&/
96 s/blob/160000/
99 } >expect &&
101 cat expect
102 echo ":100644 160000 $_empty $_z40 T yonk"
103 echo ":100644 000000 $_empty $_z40 D zifmia"
104 } >expect-files &&
106 cat expect
107 echo ":000000 160000 $_z40 $_z40 A yonk"
108 } >expect-index &&
110 echo "100644 $_empty 0 nitfol"
111 echo "160000 $yomin 0 yomin"
112 echo "160000 $yonk 0 yonk"
113 } >expect-final
116 test_expect_success diff-files '
117 git diff-files --raw >actual &&
118 diff -u expect-files actual
121 test_expect_success diff-index '
122 git diff-index --raw HEAD -- >actual &&
123 diff -u expect-index actual
126 test_expect_success 'add -u' '
127 rm -f ".git/saved-index" &&
128 cp -p ".git/index" ".git/saved-index" &&
129 git add -u &&
130 git ls-files -s >actual &&
131 diff -u expect-final actual
134 test_expect_success 'commit -a' '
135 if test -f ".git/saved-index"
136 then
137 rm -f ".git/index" &&
138 mv ".git/saved-index" ".git/index"
139 fi &&
140 git commit -m "second" -a &&
141 git ls-files -s >actual &&
142 diff -u expect-final actual &&
143 rm -f .git/index &&
144 git read-tree HEAD &&
145 git ls-files -s >actual &&
146 diff -u expect-final actual
149 test_done