pkt-line.[ch]: remove unused packet_buf_write_len()
[alt-git.git] / t / t1050-large.sh
blob4bab6a513c5c951c084d59a0e6ccd42422f27978
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 # add a large file with different settings
21 while read expect config
23 test_expect_success "add with $config" '
24 test_when_finished "rm -f .git/objects/pack/pack-*.* .git/index" &&
25 git $config add large1 &&
26 sz=$(test_file_size .git/objects/pack/pack-*.pack) &&
27 case "$expect" in
28 small) test "$sz" -le 100000 ;;
29 large) test "$sz" -ge 100000 ;;
30 esac
32 done <<\EOF
33 large -c core.compression=0
34 small -c core.compression=9
35 large -c core.compression=0 -c pack.compression=0
36 large -c core.compression=9 -c pack.compression=0
37 small -c core.compression=0 -c pack.compression=9
38 small -c core.compression=9 -c pack.compression=9
39 large -c pack.compression=0
40 small -c pack.compression=9
41 EOF
43 test_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
49 count=$(( $count + 1 ))
50 if test_path_is_file "$p" &&
51 idx=${p%.pack}.idx && test_path_is_file "$idx"
52 then
53 continue
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 &&
61 for l in .git/objects/$OIDPATH_REGEX
63 test_path_is_file "$l" || continue
64 bad=t
65 done &&
66 test -z "$bad" &&
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
73 count=$(( $count + 1 ))
74 if test_path_is_file "$p" &&
75 idx=${p%.pack}.idx && test_path_is_file "$idx"
76 then
77 continue
79 bad=t
80 done &&
81 test -z "$bad" &&
82 test $count = 1
85 test_expect_success 'checkout a large file' '
86 large1=$(git rev-parse :large1) &&
87 git update-index --add --cacheinfo 100644 $large1 another &&
88 git checkout another &&
89 test_cmp large1 another
92 test_expect_success 'packsize limit' '
93 test_create_repo mid &&
95 cd mid &&
96 git config core.bigfilethreshold 64k &&
97 git config pack.packsizelimit 256k &&
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.
102 test-tool genrandom "a" $(( 66 * 1024 )) >mid1 &&
103 test-tool genrandom "b" $(( 80 * 1024 )) >mid2 &&
104 test-tool genrandom "c" $(( 128 * 1024 )) >mid3 &&
105 git add mid1 mid2 mid3 &&
107 count=0 &&
108 for pi in .git/objects/pack/pack-*.idx
110 test_path_is_file "$pi" && count=$(( $count + 1 ))
111 done &&
112 test $count = 2 &&
115 git hash-object --stdin <mid1 &&
116 git hash-object --stdin <mid2 &&
117 git hash-object --stdin <mid3
119 sort >expect &&
121 for pi in .git/objects/pack/pack-*.idx
123 git show-index <"$pi"
124 done |
125 sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" |
126 sort >actual &&
128 test_cmp expect actual
132 test_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^
140 test_expect_success 'diff --stat' '
141 git diff --stat HEAD^ HEAD
144 test_expect_success 'diff' '
145 git diff HEAD^ HEAD >actual &&
146 grep "Binary files.*differ" actual
149 test_expect_success 'diff --cached' '
150 git diff --cached HEAD^ >actual &&
151 grep "Binary files.*differ" actual
154 test_expect_success 'hash-object' '
155 git hash-object large1
158 test_expect_success 'cat-file a large file' '
159 git cat-file blob :large1 >/dev/null
162 test_expect_success 'cat-file a large file from a tag' '
163 git tag -m largefile largefiletag :large1 &&
164 git cat-file blob largefiletag >/dev/null
167 test_expect_success 'git-show a large file' '
168 git show :large1 >/dev/null
172 test_expect_success 'index-pack' '
173 git clone file://"$(pwd)"/.git foo &&
174 GIT_DIR=non-existent git index-pack --object-format=$(test_oid algo) \
175 --strict --verify foo/.git/objects/pack/*.pack
178 test_expect_success 'repack' '
179 git repack -ad
182 test_expect_success 'pack-objects with large loose object' '
183 SHA1=$(git hash-object huge) &&
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 &&
191 test_cmp huge actual
194 test_expect_success 'tar archiving' '
195 git archive --format=tar HEAD >/dev/null
198 test_expect_success 'zip archiving, store only' '
199 git archive --format=zip -0 HEAD >/dev/null
202 test_expect_success 'zip archiving, deflate' '
203 git archive --format=zip HEAD >/dev/null
206 test_expect_success 'fsck large blobs' '
207 git fsck 2>err &&
208 test_must_be_empty err
211 test_done