git-add--interactive: manual hunk editing mode
[git/vmiklos.git] / t / t2201-add-update-typechange.sh
blobe15e3eb81b11216f87a8010aa11edc0835e29b0f
1 #!/bin/sh
3 test_description='more git add -u'
5 . ./test-lib.sh
7 _z40=0000000000000000000000000000000000000000
9 test_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 &&
19 test_tick &&
20 git commit -m initial
24 test_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 &&
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 &&
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 &&
67 git ls-tree -r HEAD |
68 sed -e "s/^/:/" -e "
69 / caskly/{
70 s/ caskly/ $_z40 D&/
71 s/blob/000000/
73 / nitfol/{
74 s/ nitfol/ $_z40 T&/
75 s/blob/100644/
77 / rezrov.bozbar/{
78 s/ rezrov.bozbar/ $_z40 D&/
79 s/blob/000000/
81 / xyzzy/{
82 s/ xyzzy/ $_z40 D&/
83 s/blob/000000/
85 / yomin/{
86 s/ yomin/ $_z40 T&/
87 s/blob/160000/
90 } >expect &&
92 cat expect
93 echo ":100644 160000 $_empty $_z40 T yonk"
94 echo ":100644 000000 $_empty $_z40 D zifmia"
95 } >expect-files &&
97 cat expect
98 echo ":000000 160000 $_z40 $_z40 A yonk"
99 } >expect-index &&
101 echo "100644 $_empty 0 nitfol"
102 echo "160000 $yomin 0 yomin"
103 echo "160000 $yonk 0 yonk"
104 } >expect-final
107 test_expect_success diff-files '
108 git diff-files --raw >actual &&
109 diff -u expect-files actual
112 test_expect_success diff-index '
113 git diff-index --raw HEAD -- >actual &&
114 diff -u expect-index actual
117 test_expect_success 'add -u' '
118 rm -f ".git/saved-index" &&
119 cp -p ".git/index" ".git/saved-index" &&
120 git add -u &&
121 git ls-files -s >actual &&
122 diff -u expect-final actual
125 test_expect_success 'commit -a' '
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 &&
133 diff -u expect-final actual &&
134 rm -f .git/index &&
135 git read-tree HEAD &&
136 git ls-files -s >actual &&
137 diff -u expect-final actual
140 test_done