chainlint.sed: drop subshell-closing ">" annotation
[git/debian.git] / t / t1050-large.sh
blob6bc1d76fb108f38f1fdb9a68904c5251866149fb
1 #!/bin/sh
2 # Copyright (c) 2011, Google Inc.
4 test_description='adding and checking out large blobs'
6 . ./test-lib.sh
8 test_expect_success setup '
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 &&
12 printf "%2000000s" X >large1 &&
13 cp large1 large2 &&
14 cp large1 large3 &&
15 printf "%2500000s" Y >huge &&
16 GIT_ALLOC_LIMIT=1500k &&
17 export GIT_ALLOC_LIMIT
20 test_expect_success 'enter "large" codepath, with small core.bigFileThreshold' '
21 test_when_finished "rm -rf repo" &&
23 git init --bare repo &&
24 echo large | git -C repo hash-object -w --stdin &&
25 git -C repo -c core.bigfilethreshold=4 fsck
28 # add a large file with different settings
29 while read expect config
31 test_expect_success "add with $config" '
32 test_when_finished "rm -f .git/objects/pack/pack-*.* .git/index" &&
33 git $config add large1 &&
34 sz=$(test_file_size .git/objects/pack/pack-*.pack) &&
35 case "$expect" in
36 small) test "$sz" -le 100000 ;;
37 large) test "$sz" -ge 100000 ;;
38 esac
40 done <<\EOF
41 large -c core.compression=0
42 small -c core.compression=9
43 large -c core.compression=0 -c pack.compression=0
44 large -c core.compression=9 -c pack.compression=0
45 small -c core.compression=0 -c pack.compression=9
46 small -c core.compression=9 -c pack.compression=9
47 large -c pack.compression=0
48 small -c pack.compression=9
49 EOF
51 test_expect_success 'add a large file or two' '
52 git add large1 huge large2 &&
53 # make sure we got a single packfile and no loose objects
54 bad= count=0 idx= &&
55 for p in .git/objects/pack/pack-*.pack
57 count=$(( $count + 1 ))
58 if test_path_is_file "$p" &&
59 idx=${p%.pack}.idx && test_path_is_file "$idx"
60 then
61 continue
63 bad=t
64 done &&
65 test -z "$bad" &&
66 test $count = 1 &&
67 cnt=$(git show-index <"$idx" | wc -l) &&
68 test $cnt = 2 &&
69 for l in .git/objects/$OIDPATH_REGEX
71 test_path_is_file "$l" || continue
72 bad=t
73 done &&
74 test -z "$bad" &&
76 # attempt to add another copy of the same
77 git add large3 &&
78 bad= count=0 &&
79 for p in .git/objects/pack/pack-*.pack
81 count=$(( $count + 1 ))
82 if test_path_is_file "$p" &&
83 idx=${p%.pack}.idx && test_path_is_file "$idx"
84 then
85 continue
87 bad=t
88 done &&
89 test -z "$bad" &&
90 test $count = 1
93 test_expect_success 'checkout a large file' '
94 large1=$(git rev-parse :large1) &&
95 git update-index --add --cacheinfo 100644 $large1 another &&
96 git checkout another &&
97 test_cmp large1 another
100 test_expect_success 'packsize limit' '
101 test_create_repo mid &&
103 cd mid &&
104 git config core.bigfilethreshold 64k &&
105 git config pack.packsizelimit 256k &&
107 # mid1 and mid2 will fit within 256k limit but
108 # appending mid3 will bust the limit and will
109 # result in a separate packfile.
110 test-tool genrandom "a" $(( 66 * 1024 )) >mid1 &&
111 test-tool genrandom "b" $(( 80 * 1024 )) >mid2 &&
112 test-tool genrandom "c" $(( 128 * 1024 )) >mid3 &&
113 git add mid1 mid2 mid3 &&
115 count=0 &&
116 for pi in .git/objects/pack/pack-*.idx
118 test_path_is_file "$pi" && count=$(( $count + 1 ))
119 done &&
120 test $count = 2 &&
123 git hash-object --stdin <mid1 &&
124 git hash-object --stdin <mid2 &&
125 git hash-object --stdin <mid3
127 sort >expect &&
129 for pi in .git/objects/pack/pack-*.idx
131 git show-index <"$pi"
132 done |
133 sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" |
134 sort >actual &&
136 test_cmp expect actual
140 test_expect_success 'diff --raw' '
141 git commit -q -m initial &&
142 echo modified >>large1 &&
143 git add large1 &&
144 git commit -q -m modified &&
145 git diff --raw HEAD^
148 test_expect_success 'diff --stat' '
149 git diff --stat HEAD^ HEAD
152 test_expect_success 'diff' '
153 git diff HEAD^ HEAD >actual &&
154 grep "Binary files.*differ" actual
157 test_expect_success 'diff --cached' '
158 git diff --cached HEAD^ >actual &&
159 grep "Binary files.*differ" actual
162 test_expect_success 'hash-object' '
163 git hash-object large1
166 test_expect_success 'cat-file a large file' '
167 git cat-file blob :large1 >/dev/null
170 test_expect_success 'cat-file a large file from a tag' '
171 git tag -m largefile largefiletag :large1 &&
172 git cat-file blob largefiletag >/dev/null
175 test_expect_success 'git-show a large file' '
176 git show :large1 >/dev/null
180 test_expect_success 'index-pack' '
181 git clone file://"$(pwd)"/.git foo &&
182 GIT_DIR=non-existent git index-pack --object-format=$(test_oid algo) \
183 --strict --verify foo/.git/objects/pack/*.pack
186 test_expect_success 'repack' '
187 git repack -ad
190 test_expect_success 'pack-objects with large loose object' '
191 SHA1=$(git hash-object huge) &&
192 test_create_repo loose &&
193 echo $SHA1 | git pack-objects --stdout |
194 GIT_ALLOC_LIMIT=0 GIT_DIR=loose/.git git unpack-objects &&
195 echo $SHA1 | GIT_DIR=loose/.git git pack-objects pack &&
196 test_create_repo packed &&
197 mv pack-* packed/.git/objects/pack &&
198 GIT_DIR=packed/.git git cat-file blob $SHA1 >actual &&
199 test_cmp huge actual
202 test_expect_success 'tar archiving' '
203 git archive --format=tar HEAD >/dev/null
206 test_expect_success 'zip archiving, store only' '
207 git archive --format=zip -0 HEAD >/dev/null
210 test_expect_success 'zip archiving, deflate' '
211 git archive --format=zip HEAD >/dev/null
214 test_expect_success 'fsck large blobs' '
215 git fsck 2>err &&
216 test_must_be_empty err
219 test_done