33
33
################################################################
34
# git-init has been done in an empty repository.
34
# git init has been done in an empty repository.
35
35
# make sure it is empty.
37
37
find .git/objects -type f -print >should-be-empty
38
38
test_expect_success \
39
'.git/objects should be empty after git-init in an empty repo.' \
40
'cmp -s /dev/null should-be-empty'
39
'.git/objects should be empty after git init in an empty repo.' \
40
'cmp -s /dev/null should-be-empty'
42
42
# also it should have 2 subdirectories; no fan-out anymore, pack, and info.
43
43
# 3 is counting "objects" itself
52
52
# updating a new file without --add should fail.
53
53
test_expect_failure \
54
'git-update-index without --add should fail adding.' \
55
'git-update-index should-be-empty'
54
'git update-index without --add should fail adding.' \
55
'git update-index should-be-empty'
57
57
# and with --add it should succeed, even if it is empty (it used to fail).
58
58
test_expect_success \
59
'git-update-index with --add should succeed.' \
60
'git-update-index --add should-be-empty'
59
'git update-index with --add should succeed.' \
60
'git update-index --add should-be-empty'
62
62
test_expect_success \
63
'writing tree out with git-write-tree' \
64
'tree=$(git-write-tree)'
63
'writing tree out with git write-tree' \
64
'tree=$(git write-tree)'
66
66
# we know the shape and contents of the tree and know the object ID for it.
67
67
test_expect_success \
72
72
rm -f should-be-empty full-of-directories
73
73
test_expect_failure \
74
'git-update-index without --remove should fail removing.' \
75
'git-update-index should-be-empty'
74
'git update-index without --remove should fail removing.' \
75
'git update-index should-be-empty'
77
77
test_expect_success \
78
'git-update-index with --remove should be able to remove.' \
79
'git-update-index --remove should-be-empty'
78
'git update-index with --remove should be able to remove.' \
79
'git update-index --remove should-be-empty'
81
81
# Empty tree can be written with recent write-tree.
82
82
test_expect_success \
83
'git-write-tree should be able to write an empty tree.' \
84
'tree=$(git-write-tree)'
83
'git write-tree should be able to write an empty tree.' \
84
'tree=$(git write-tree)'
86
86
test_expect_success \
87
87
'validate object ID of a known tree.' \
95
95
ln -s "hello $p" ${p}sym
97
97
test_expect_success \
98
'adding various types of objects with git-update-index --add.' \
99
'find path* ! -type d -print | xargs git-update-index --add'
98
'adding various types of objects with git update-index --add.' \
99
'find path* ! -type d -print | xargs git update-index --add'
101
101
# Show them and see that matches what we expect.
102
102
test_expect_success \
103
'showing stage with git-ls-files --stage' \
104
'git-ls-files --stage >current'
103
'showing stage with git ls-files --stage' \
104
'git ls-files --stage >current'
106
106
cat >expected <<\EOF
107
107
100644 f87290f8eb2cbbea7857214459a0739927eab154 0 path0
114
114
120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0 path3/subp3/file3sym
116
116
test_expect_success \
117
'validate git-ls-files output for a known tree.' \
117
'validate git ls-files output for a known tree.' \
118
118
'diff current expected'
120
120
test_expect_success \
121
'writing tree out with git-write-tree.' \
122
'tree=$(git-write-tree)'
121
'writing tree out with git write-tree.' \
122
'tree=$(git write-tree)'
123
123
test_expect_success \
124
124
'validate object ID for a known tree.' \
125
125
'test "$tree" = 087704a96baf1c2d1c869a8b084481e121c88b5b'
127
127
test_expect_success \
128
'showing tree with git-ls-tree' \
129
'git-ls-tree $tree >current'
128
'showing tree with git ls-tree' \
129
'git ls-tree $tree >current'
130
130
cat >expected <<\EOF
131
131
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
132
132
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
134
134
040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3 path3
136
136
test_expect_success \
137
'git-ls-tree output for a known tree.' \
137
'git ls-tree output for a known tree.' \
138
138
'diff current expected'
140
140
# This changed in ls-tree pathspec change -- recursive does
141
141
# not show tree nodes anymore.
142
142
test_expect_success \
143
'showing tree with git-ls-tree -r' \
144
'git-ls-tree -r $tree >current'
143
'showing tree with git ls-tree -r' \
144
'git ls-tree -r $tree >current'
145
145
cat >expected <<\EOF
146
146
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
147
147
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
153
153
120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym
155
155
test_expect_success \
156
'git-ls-tree -r output for a known tree.' \
156
'git ls-tree -r output for a known tree.' \
157
157
'diff current expected'
159
159
# But with -r -t we can have both.
160
160
test_expect_success \
161
'showing tree with git-ls-tree -r -t' \
162
'git-ls-tree -r -t $tree >current'
161
'showing tree with git ls-tree -r -t' \
162
'git ls-tree -r -t $tree >current'
163
163
cat >expected <<\EOF
164
164
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
165
165
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
174
174
120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym
176
176
test_expect_success \
177
'git-ls-tree -r output for a known tree.' \
177
'git ls-tree -r output for a known tree.' \
178
178
'diff current expected'
180
180
test_expect_success \
181
'writing partial tree out with git-write-tree --prefix.' \
182
'ptree=$(git-write-tree --prefix=path3)'
181
'writing partial tree out with git write-tree --prefix.' \
182
'ptree=$(git write-tree --prefix=path3)'
183
183
test_expect_success \
184
184
'validate object ID for a known tree.' \
185
185
'test "$ptree" = 21ae8269cacbe57ae09138dcc3a2887f904d02b3'
187
187
test_expect_success \
188
'writing partial tree out with git-write-tree --prefix.' \
189
'ptree=$(git-write-tree --prefix=path3/subp3)'
188
'writing partial tree out with git write-tree --prefix.' \
189
'ptree=$(git write-tree --prefix=path3/subp3)'
190
190
test_expect_success \
191
191
'validate object ID for a known tree.' \
192
192
'test "$ptree" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2'
203
203
test_expect_success \
204
204
'put invalid objects into the index.' \
205
'git-update-index --index-info < badobjects'
205
'git update-index --index-info < badobjects'
207
207
test_expect_failure \
208
208
'writing this tree without --missing-ok.' \
211
211
test_expect_success \
212
212
'writing this tree with --missing-ok.' \
213
'git-write-tree --missing-ok'
213
'git write-tree --missing-ok'
216
216
################################################################
218
218
test_expect_success \
219
'git-read-tree followed by write-tree should be idempotent.' \
220
'git-read-tree $tree &&
219
'git read-tree followed by write-tree should be idempotent.' \
220
'git read-tree $tree &&
221
221
test -f .git/index &&
222
newtree=$(git-write-tree) &&
222
newtree=$(git write-tree) &&
223
223
test "$newtree" = "$tree"'
225
225
cat >expected <<\EOF
233
233
:120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M path3/subp3/file3sym
235
235
test_expect_success \
236
'validate git-diff-files output for a know cache/work tree state.' \
237
'git-diff-files >current && diff >/dev/null -b current expected'
239
test_expect_success \
240
'git-update-index --refresh should succeed.' \
241
'git-update-index --refresh'
243
test_expect_success \
244
'no diff after checkout and git-update-index --refresh.' \
245
'git-diff-files >current && cmp -s current /dev/null'
236
'validate git diff-files output for a know cache/work tree state.' \
237
'git diff-files >current && diff >/dev/null -b current expected'
239
test_expect_success \
240
'git update-index --refresh should succeed.' \
241
'git update-index --refresh'
243
test_expect_success \
244
'no diff after checkout and git update-index --refresh.' \
245
'git diff-files >current && cmp -s current /dev/null'
247
247
################################################################
248
248
P=087704a96baf1c2d1c869a8b084481e121c88b5b
249
249
test_expect_success \
250
'git-commit-tree records the correct tree in a commit.' \
251
'commit0=$(echo NO | git-commit-tree $P) &&
250
'git commit-tree records the correct tree in a commit.' \
251
'commit0=$(echo NO | git commit-tree $P) &&
252
252
tree=$(git show --pretty=raw $commit0 |
253
253
sed -n -e "s/^tree //p" -e "/^author /q") &&
254
254
test "z$tree" = "z$P"'
256
256
test_expect_success \
257
'git-commit-tree records the correct parent in a commit.' \
258
'commit1=$(echo NO | git-commit-tree $P -p $commit0) &&
257
'git commit-tree records the correct parent in a commit.' \
258
'commit1=$(echo NO | git commit-tree $P -p $commit0) &&
259
259
parent=$(git show --pretty=raw $commit1 |
260
260
sed -n -e "s/^parent //p" -e "/^author /q") &&
261
261
test "z$commit0" = "z$parent"'
263
263
test_expect_success \
264
'git-commit-tree omits duplicated parent in a commit.' \
265
'commit2=$(echo NO | git-commit-tree $P -p $commit0 -p $commit0) &&
264
'git commit-tree omits duplicated parent in a commit.' \
265
'commit2=$(echo NO | git commit-tree $P -p $commit0 -p $commit0) &&
266
266
parent=$(git show --pretty=raw $commit2 |
267
267
sed -n -e "s/^parent //p" -e "/^author /q" |
281
281
test $numpath0 = 1
284
test_expect_success 'absolute path works as expected' '
286
ln -s ../.git first/.git &&
288
ln -s ../first second/other &&
290
dir="$(cd .git; pwd -P)" &&
291
dir2=third/../second/other/.git &&
292
test "$dir" = "$(test-absolute-path $dir2)" &&
294
test "$file" = "$(test-absolute-path $dir2/index)" &&
295
ln -s ../first/file .git/syml &&
296
sym="$(cd first; pwd -P)"/file &&
297
test "$sym" = "$(test-absolute-path $dir2/syml)"