interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t1050-large.sh

233 lines · 5793 bytes Raw Blame History
1#!/bin/sh
2# Copyright (c) 2011, Google Inc.
3
4test_description='adding and checking out large blobs'
5
6. ./test-lib.sh
7
8test_expect_success 'core.bigFileThreshold must be non-negative' '
9 : >input &&
10 test_must_fail git -c core.bigFileThreshold=-1 hash-object input >out 2>err &&
11 test_grep "bad numeric config value" err &&
12 test_must_be_empty out
13'
14
15test_expect_success setup '
16 # clone does not allow us to pass core.bigfilethreshold to
17 # new repos, so set core.bigfilethreshold globally
18 git config --global core.bigfilethreshold 200k &&
19 printf "%2000000s" X >large1 &&
20 cp large1 large2 &&
21 cp large1 large3 &&
22 printf "%2500000s" Y >huge &&
23 GIT_ALLOC_LIMIT=1500k &&
24 export GIT_ALLOC_LIMIT
25'
26
27test_expect_success 'enter "large" codepath, with small core.bigFileThreshold' '
28 test_when_finished "rm -rf repo" &&
29
30 git init --bare repo &&
31 echo large | git -C repo hash-object -w --stdin &&
32 git -C repo -c core.bigfilethreshold=4 fsck
33'
34
35# add a large file with different settings
36while read expect config
37do
38 test_expect_success "add with $config" '
39 test_when_finished "rm -f .git/objects/pack/pack-*.* .git/index" &&
40 git $config add large1 &&
41 sz=$(test_file_size .git/objects/pack/pack-*.pack) &&
42 case "$expect" in
43 small) test "$sz" -le 100000 ;;
44 large) test "$sz" -ge 100000 ;;
45 esac
46 '
47done <<\EOF
48large -c core.compression=0
49small -c core.compression=9
50large -c core.compression=0 -c pack.compression=0
51large -c core.compression=9 -c pack.compression=0
52small -c core.compression=0 -c pack.compression=9
53small -c core.compression=9 -c pack.compression=9
54large -c pack.compression=0
55small -c pack.compression=9
56EOF
57
58test_expect_success 'add a large file or two' '
59 git add large1 huge large2 &&
60 # make sure we got a single packfile and no loose objects
61 count=0 idx= &&
62 for p in .git/objects/pack/pack-*.pack
63 do
64 count=$(( $count + 1 )) &&
65 test_path_is_file "$p" &&
66 idx=${p%.pack}.idx &&
67 test_path_is_file "$idx" || return 1
68 done &&
69 test $count = 1 &&
70 cnt=$(git show-index <"$idx" | wc -l) &&
71 test $cnt = 2 &&
72 for l in .git/objects/$OIDPATH_REGEX
73 do
74 test_path_is_missing "$l" || return 1
75 done &&
76
77 # attempt to add another copy of the same
78 git add large3 &&
79 bad= count=0 &&
80 for p in .git/objects/pack/pack-*.pack
81 do
82 count=$(( $count + 1 )) &&
83 test_path_is_file "$p" &&
84 idx=${p%.pack}.idx &&
85 test_path_is_file "$idx" || return 1
86 done &&
87 test $count = 1
88'
89
90test_expect_success 'add large file with loose object in batch fsync' '
91 test_when_finished "rm -rf batch" &&
92 git init batch &&
93 (
94 cd batch &&
95 git config core.bigFileThreshold 5 &&
96 echo foo >1-small &&
97 echo foobar >2-large &&
98
99 git -c core.fsync=loose-object -c core.fsyncMethod=batch \
100 add 1-small 2-large &&
101
102 git cat-file -e :1-small &&
103 git cat-file -e :2-large
104 )
105'
106
107test_expect_success 'checkout a large file' '
108 large1=$(git rev-parse :large1) &&
109 git update-index --add --cacheinfo 100644 $large1 another &&
110 git checkout another &&
111 test_cmp large1 another
112'
113
114test_expect_success 'packsize limit' '
115 test_create_repo mid &&
116 (
117 cd mid &&
118 git config core.bigfilethreshold 64k &&
119 git config pack.packsizelimit 256k &&
120
121 # mid1 and mid2 will fit within 256k limit but
122 # appending mid3 will bust the limit and will
123 # result in a separate packfile.
124 test-tool genrandom "a" 66k >mid1 &&
125 test-tool genrandom "b" 80k >mid2 &&
126 test-tool genrandom "c" 128k >mid3 &&
127 git add mid1 mid2 mid3 &&
128
129 count=0 &&
130 for pi in .git/objects/pack/pack-*.idx
131 do
132 test_path_is_file "$pi" && count=$(( $count + 1 )) || return 1
133 done &&
134 test $count = 2 &&
135
136 (
137 git hash-object --stdin <mid1 &&
138 git hash-object --stdin <mid2 &&
139 git hash-object --stdin <mid3
140 ) |
141 sort >expect &&
142
143 for pi in .git/objects/pack/pack-*.idx
144 do
145 git show-index <"$pi" || return 1
146 done |
147 sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" |
148 sort >actual &&
149
150 test_cmp expect actual
151 )
152'
153
154test_expect_success 'diff --raw' '
155 git commit -q -m initial &&
156 echo modified >>large1 &&
157 git add large1 &&
158 git commit -q -m modified &&
159 git diff --raw HEAD^
160'
161
162test_expect_success 'diff --stat' '
163 git diff --stat HEAD^ HEAD
164'
165
166test_expect_success 'diff' '
167 git diff HEAD^ HEAD >actual &&
168 test_grep "Binary files.*differ" actual
169'
170
171test_expect_success 'diff --cached' '
172 git diff --cached HEAD^ >actual &&
173 test_grep "Binary files.*differ" actual
174'
175
176test_expect_success 'hash-object' '
177 git hash-object large1
178'
179
180test_expect_success 'cat-file a large file' '
181 git cat-file blob :large1 >/dev/null
182'
183
184test_expect_success 'cat-file a large file from a tag' '
185 git tag -m largefile largefiletag :large1 &&
186 git cat-file blob largefiletag >/dev/null
187'
188
189test_expect_success 'git-show a large file' '
190 git show :large1 >/dev/null
191
192'
193
194test_expect_success 'index-pack' '
195 git clone file://"$(pwd)"/.git foo &&
196 GIT_DIR=non-existent git index-pack --object-format=$(test_oid algo) \
197 --strict --verify foo/.git/objects/pack/*.pack
198'
199
200test_expect_success 'repack' '
201 git repack -ad
202'
203
204test_expect_success 'pack-objects with large loose object' '
205 SHA1=$(git hash-object huge) &&
206 test_create_repo loose &&
207 echo $SHA1 | git pack-objects --stdout |
208 GIT_ALLOC_LIMIT=0 GIT_DIR=loose/.git git unpack-objects &&
209 echo $SHA1 | GIT_DIR=loose/.git git pack-objects pack &&
210 test_create_repo packed &&
211 mv pack-* packed/.git/objects/pack &&
212 GIT_DIR=packed/.git git cat-file blob $SHA1 >actual &&
213 test_cmp huge actual
214'
215
216test_expect_success 'tar archiving' '
217 git archive --format=tar HEAD >/dev/null
218'
219
220test_expect_success 'zip archiving, store only' '
221 git archive --format=zip -0 HEAD >/dev/null
222'
223
224test_expect_success 'zip archiving, deflate' '
225 git archive --format=zip HEAD >/dev/null
226'
227
228test_expect_success 'fsck large blobs' '
229 git fsck 2>err &&
230 test_must_be_empty err
231'
232
233test_done