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