Merge branch 'jn/gitweb-unspecified-action'
[git/dscho.git] / t / t1050-large.sh
blob29d6024b7f1b55c09cbd7e9ed682a3e745c550d6
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 git config core.bigfilethreshold 200k &&
10 echo X | dd of=large1 bs=1k seek=2000 &&
11 echo X | dd of=large2 bs=1k seek=2000 &&
12 echo X | dd of=large3 bs=1k seek=2000 &&
13 echo Y | dd of=huge bs=1k seek=2500
16 test_expect_success 'add a large file or two' '
17 git add large1 huge large2 &&
18 # make sure we got a single packfile and no loose objects
19 bad= count=0 idx= &&
20 for p in .git/objects/pack/pack-*.pack
22 count=$(( $count + 1 ))
23 if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
24 then
25 continue
27 bad=t
28 done &&
29 test -z "$bad" &&
30 test $count = 1 &&
31 cnt=$(git show-index <"$idx" | wc -l) &&
32 test $cnt = 2 &&
33 for l in .git/objects/??/??????????????????????????????????????
35 test -f "$l" || continue
36 bad=t
37 done &&
38 test -z "$bad" &&
40 # attempt to add another copy of the same
41 git add large3 &&
42 bad= count=0 &&
43 for p in .git/objects/pack/pack-*.pack
45 count=$(( $count + 1 ))
46 if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
47 then
48 continue
50 bad=t
51 done &&
52 test -z "$bad" &&
53 test $count = 1
56 test_expect_success 'checkout a large file' '
57 large1=$(git rev-parse :large1) &&
58 git update-index --add --cacheinfo 100644 $large1 another &&
59 git checkout another &&
60 cmp large1 another ;# this must not be test_cmp
63 test_expect_success 'packsize limit' '
64 test_create_repo mid &&
66 cd mid &&
67 git config core.bigfilethreshold 64k &&
68 git config pack.packsizelimit 256k &&
70 # mid1 and mid2 will fit within 256k limit but
71 # appending mid3 will bust the limit and will
72 # result in a separate packfile.
73 test-genrandom "a" $(( 66 * 1024 )) >mid1 &&
74 test-genrandom "b" $(( 80 * 1024 )) >mid2 &&
75 test-genrandom "c" $(( 128 * 1024 )) >mid3 &&
76 git add mid1 mid2 mid3 &&
78 count=0
79 for pi in .git/objects/pack/pack-*.idx
81 test -f "$pi" && count=$(( $count + 1 ))
82 done &&
83 test $count = 2 &&
86 git hash-object --stdin <mid1
87 git hash-object --stdin <mid2
88 git hash-object --stdin <mid3
89 ) |
90 sort >expect &&
92 for pi in .git/objects/pack/pack-*.idx
94 git show-index <"$pi"
95 done |
96 sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" |
97 sort >actual &&
99 test_cmp expect actual
103 test_done