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