t / t1050-large.shon commit Merge branch 'pw/p4-view-updates' (8cbfc11)
   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 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
  14'
  15
  16test_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
  21        do
  22                count=$(( $count + 1 ))
  23                if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
  24                then
  25                        continue
  26                fi
  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/??/??????????????????????????????????????
  34        do
  35                test -f "$l" || continue
  36                bad=t
  37        done &&
  38        test -z "$bad" &&
  39
  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
  44        do
  45                count=$(( $count + 1 ))
  46                if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
  47                then
  48                        continue
  49                fi
  50                bad=t
  51        done &&
  52        test -z "$bad" &&
  53        test $count = 1
  54'
  55
  56test_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
  61'
  62
  63test_expect_success 'packsize limit' '
  64        test_create_repo mid &&
  65        (
  66                cd mid &&
  67                git config core.bigfilethreshold 64k &&
  68                git config pack.packsizelimit 256k &&
  69
  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 &&
  77
  78                count=0
  79                for pi in .git/objects/pack/pack-*.idx
  80                do
  81                        test -f "$pi" && count=$(( $count + 1 ))
  82                done &&
  83                test $count = 2 &&
  84
  85                (
  86                        git hash-object --stdin <mid1
  87                        git hash-object --stdin <mid2
  88                        git hash-object --stdin <mid3
  89                ) |
  90                sort >expect &&
  91
  92                for pi in .git/objects/pack/pack-*.idx
  93                do
  94                        git show-index <"$pi"
  95                done |
  96                sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" |
  97                sort >actual &&
  98
  99                test_cmp expect actual
 100        )
 101'
 102
 103test_done