2 # Copyright (c) 2011, Google Inc.
4 test_description
='adding and checking out large blobs'
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 &&
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) &&
36 small) test "$sz" -le 100000 ;;
37 large) test "$sz" -ge 100000 ;;
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
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
55 for p in .git/objects/pack/pack-*.pack
57 count=$(( $count + 1 )) &&
58 test_path_is_file "$p" &&
60 test_path_is_file "$idx" || return 1
63 cnt=$(git show-index <"$idx" | wc -l) &&
65 for l in .git/objects/$OIDPATH_REGEX
67 test_path_is_missing "$l" || return 1
70 # attempt to add another copy of the same
73 for p in .git/objects/pack/pack-*.pack
75 count=$(( $count + 1 )) &&
76 test_path_is_file "$p" &&
78 test_path_is_file "$idx" || return 1
83 test_expect_success
'checkout a large file' '
84 large1=$(git rev-parse :large1) &&
85 git update-index --add --cacheinfo 100644 $large1 another &&
86 git checkout another &&
87 test_cmp large1 another
90 test_expect_success
'packsize limit' '
91 test_create_repo mid &&
94 git config core.bigfilethreshold 64k &&
95 git config pack.packsizelimit 256k &&
97 # mid1 and mid2 will fit within 256k limit but
98 # appending mid3 will bust the limit and will
99 # result in a separate packfile.
100 test-tool genrandom "a" $(( 66 * 1024 )) >mid1 &&
101 test-tool genrandom "b" $(( 80 * 1024 )) >mid2 &&
102 test-tool genrandom "c" $(( 128 * 1024 )) >mid3 &&
103 git add mid1 mid2 mid3 &&
106 for pi in .git/objects/pack/pack-*.idx
108 test_path_is_file "$pi" && count=$(( $count + 1 )) || return 1
113 git hash-object --stdin <mid1 &&
114 git hash-object --stdin <mid2 &&
115 git hash-object --stdin <mid3
119 for pi in .git/objects/pack/pack-*.idx
121 git show-index <"$pi" || return 1
123 sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" |
126 test_cmp expect actual
130 test_expect_success
'diff --raw' '
131 git commit -q -m initial &&
132 echo modified >>large1 &&
134 git commit -q -m modified &&
138 test_expect_success
'diff --stat' '
139 git diff --stat HEAD^ HEAD
142 test_expect_success
'diff' '
143 git diff HEAD^ HEAD >actual &&
144 grep "Binary files.*differ" actual
147 test_expect_success
'diff --cached' '
148 git diff --cached HEAD^ >actual &&
149 grep "Binary files.*differ" actual
152 test_expect_success
'hash-object' '
153 git hash-object large1
156 test_expect_success
'cat-file a large file' '
157 git cat-file blob :large1 >/dev/null
160 test_expect_success
'cat-file a large file from a tag' '
161 git tag -m largefile largefiletag :large1 &&
162 git cat-file blob largefiletag >/dev/null
165 test_expect_success
'git-show a large file' '
166 git show :large1 >/dev/null
170 test_expect_success
'index-pack' '
171 git clone file://"$(pwd)"/.git foo &&
172 GIT_DIR=non-existent git index-pack --object-format=$(test_oid algo) \
173 --strict --verify foo/.git/objects/pack/*.pack
176 test_expect_success
'repack' '
180 test_expect_success
'pack-objects with large loose object' '
181 SHA1=$(git hash-object huge) &&
182 test_create_repo loose &&
183 echo $SHA1 | git pack-objects --stdout |
184 GIT_ALLOC_LIMIT=0 GIT_DIR=loose/.git git unpack-objects &&
185 echo $SHA1 | GIT_DIR=loose/.git git pack-objects pack &&
186 test_create_repo packed &&
187 mv pack-* packed/.git/objects/pack &&
188 GIT_DIR=packed/.git git cat-file blob $SHA1 >actual &&
192 test_expect_success
'tar archiving' '
193 git archive --format=tar HEAD >/dev/null
196 test_expect_success
'zip archiving, store only' '
197 git archive --format=zip -0 HEAD >/dev/null
200 test_expect_success
'zip archiving, deflate' '
201 git archive --format=zip HEAD >/dev/null
204 test_expect_success
'fsck large blobs' '
206 test_must_be_empty err