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