]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1050-large.sh
path.c: don't call the match function without value in trie_find()
[thirdparty/git.git] / t / t1050-large.sh
CommitLineData
4dd1fbc7
JH
1#!/bin/sh
2# Copyright (c) 2011, Google Inc.
3
4test_description='adding and checking out large blobs'
5
6. ./test-lib.sh
7
8de7eeb5
JH
8# This should be moved to test-lib.sh together with the
9# copy in t0021 after both topics have graduated to 'master'.
10file_size () {
5868bd86 11 test-tool path-utils file-size "$1"
8de7eeb5
JH
12}
13
4dd1fbc7 14test_expect_success setup '
d41489a6
NTND
15 # clone does not allow us to pass core.bigfilethreshold to
16 # new repos, so set core.bigfilethreshold globally
17 git config --global core.bigfilethreshold 200k &&
d0a042a1
JS
18 printf "%2000000s" X >large1 &&
19 cp large1 large2 &&
20 cp large1 large3 &&
21 printf "%2500000s" Y >huge &&
9927d962 22 GIT_ALLOC_LIMIT=1500k &&
d41489a6 23 export GIT_ALLOC_LIMIT
4dd1fbc7
JH
24'
25
8de7eeb5
JH
26# add a large file with different settings
27while read expect config
28do
29 test_expect_success "add with $config" '
30 test_when_finished "rm -f .git/objects/pack/pack-*.* .git/index" &&
31 git $config add large1 &&
32 sz=$(file_size .git/objects/pack/pack-*.pack) &&
33 case "$expect" in
34 small) test "$sz" -le 100000 ;;
35 large) test "$sz" -ge 100000 ;;
36 esac
37 '
38done <<\EOF
39large -c core.compression=0
40small -c core.compression=9
41large -c core.compression=0 -c pack.compression=0
42large -c core.compression=9 -c pack.compression=0
43small -c core.compression=0 -c pack.compression=9
44small -c core.compression=9 -c pack.compression=9
45large -c pack.compression=0
46small -c pack.compression=9
47EOF
48
568508e7
JH
49test_expect_success 'add a large file or two' '
50 git add large1 huge large2 &&
51 # make sure we got a single packfile and no loose objects
52 bad= count=0 idx= &&
53 for p in .git/objects/pack/pack-*.pack
54 do
55 count=$(( $count + 1 ))
56 if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
57 then
58 continue
59 fi
60 bad=t
61 done &&
62 test -z "$bad" &&
63 test $count = 1 &&
64 cnt=$(git show-index <"$idx" | wc -l) &&
65 test $cnt = 2 &&
66 for l in .git/objects/??/??????????????????????????????????????
67 do
68 test -f "$l" || continue
69 bad=t
70 done &&
71 test -z "$bad" &&
72
73 # attempt to add another copy of the same
74 git add large3 &&
75 bad= count=0 &&
76 for p in .git/objects/pack/pack-*.pack
77 do
78 count=$(( $count + 1 ))
79 if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
80 then
81 continue
82 fi
83 bad=t
84 done &&
85 test -z "$bad" &&
86 test $count = 1
4dd1fbc7
JH
87'
88
89test_expect_success 'checkout a large file' '
568508e7
JH
90 large1=$(git rev-parse :large1) &&
91 git update-index --add --cacheinfo 100644 $large1 another &&
4dd1fbc7 92 git checkout another &&
d0a042a1 93 test_cmp large1 another
568508e7
JH
94'
95
96test_expect_success 'packsize limit' '
97 test_create_repo mid &&
98 (
99 cd mid &&
100 git config core.bigfilethreshold 64k &&
101 git config pack.packsizelimit 256k &&
102
103 # mid1 and mid2 will fit within 256k limit but
104 # appending mid3 will bust the limit and will
105 # result in a separate packfile.
c680668d
NTND
106 test-tool genrandom "a" $(( 66 * 1024 )) >mid1 &&
107 test-tool genrandom "b" $(( 80 * 1024 )) >mid2 &&
108 test-tool genrandom "c" $(( 128 * 1024 )) >mid3 &&
568508e7
JH
109 git add mid1 mid2 mid3 &&
110
f2deabfc 111 count=0 &&
568508e7
JH
112 for pi in .git/objects/pack/pack-*.idx
113 do
114 test -f "$pi" && count=$(( $count + 1 ))
115 done &&
116 test $count = 2 &&
117
118 (
f2deabfc
ES
119 git hash-object --stdin <mid1 &&
120 git hash-object --stdin <mid2 &&
568508e7
JH
121 git hash-object --stdin <mid3
122 ) |
123 sort >expect &&
124
125 for pi in .git/objects/pack/pack-*.idx
126 do
127 git show-index <"$pi"
128 done |
129 sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" |
130 sort >actual &&
131
132 test_cmp expect actual
133 )
4dd1fbc7
JH
134'
135
d41489a6
NTND
136test_expect_success 'diff --raw' '
137 git commit -q -m initial &&
138 echo modified >>large1 &&
139 git add large1 &&
140 git commit -q -m modified &&
141 git diff --raw HEAD^
142'
143
6bf3b813
NTND
144test_expect_success 'diff --stat' '
145 git diff --stat HEAD^ HEAD
146'
147
1aaf69e6
NTND
148test_expect_success 'diff' '
149 git diff HEAD^ HEAD >actual &&
150 grep "Binary files.*differ" actual
151'
152
153test_expect_success 'diff --cached' '
154 git diff --cached HEAD^ >actual &&
155 grep "Binary files.*differ" actual
156'
157
d41489a6
NTND
158test_expect_success 'hash-object' '
159 git hash-object large1
160'
161
00c8fd49 162test_expect_success 'cat-file a large file' '
d41489a6
NTND
163 git cat-file blob :large1 >/dev/null
164'
165
00c8fd49 166test_expect_success 'cat-file a large file from a tag' '
d41489a6
NTND
167 git tag -m largefile largefiletag :large1 &&
168 git cat-file blob largefiletag >/dev/null
169'
170
74775a09 171test_expect_success 'git-show a large file' '
d41489a6
NTND
172 git show :large1 >/dev/null
173
174'
175
9ec2dde9 176test_expect_success 'index-pack' '
714c71b2 177 git clone file://"$(pwd)"/.git foo &&
9ec2dde9
NTND
178 GIT_DIR=non-existent git index-pack --strict --verify foo/.git/objects/pack/*.pack
179'
180
da591a7f 181test_expect_success 'repack' '
d41489a6
NTND
182 git repack -ad
183'
184
cf2ba13a 185test_expect_success 'pack-objects with large loose object' '
714c71b2 186 SHA1=$(git hash-object huge) &&
cf2ba13a
NTND
187 test_create_repo loose &&
188 echo $SHA1 | git pack-objects --stdout |
189 GIT_ALLOC_LIMIT=0 GIT_DIR=loose/.git git unpack-objects &&
190 echo $SHA1 | GIT_DIR=loose/.git git pack-objects pack &&
191 test_create_repo packed &&
192 mv pack-* packed/.git/objects/pack &&
193 GIT_DIR=packed/.git git cat-file blob $SHA1 >actual &&
d0a042a1 194 test_cmp huge actual
cf2ba13a
NTND
195'
196
5544049d
NTND
197test_expect_success 'tar achiving' '
198 git archive --format=tar HEAD >/dev/null
199'
200
2158f883
RS
201test_expect_success 'zip achiving, store only' '
202 git archive --format=zip -0 HEAD >/dev/null
203'
204
c743c215
RS
205test_expect_success 'zip achiving, deflate' '
206 git archive --format=zip HEAD >/dev/null
207'
208
ec9d2249
NTND
209test_expect_success 'fsck large blobs' '
210 git fsck 2>err &&
211 test_must_be_empty err
735efde8
NTND
212'
213
4dd1fbc7 214test_done