t / t5310-pack-bitmaps.shon commit Merge branch 'hs/simplify-bit-setting-in-fsck-tree' (f7804e2)
   1#!/bin/sh
   2
   3test_description='exercise basic bitmap functionality'
   4. ./test-lib.sh
   5
   6test_expect_success 'setup repo with moderate-sized history' '
   7        for i in $(test_seq 1 10); do
   8                test_commit $i
   9        done &&
  10        git checkout -b other HEAD~5 &&
  11        for i in $(test_seq 1 10); do
  12                test_commit side-$i
  13        done &&
  14        git checkout master &&
  15        blob=$(echo tagged-blob | git hash-object -w --stdin) &&
  16        git tag tagged-blob $blob &&
  17        git config pack.writebitmaps true &&
  18        git config pack.writebitmaphashcache true
  19'
  20
  21test_expect_success 'full repack creates bitmaps' '
  22        git repack -ad &&
  23        ls .git/objects/pack/ | grep bitmap >output &&
  24        test_line_count = 1 output
  25'
  26
  27test_expect_success 'rev-list --test-bitmap verifies bitmaps' '
  28        git rev-list --test-bitmap HEAD
  29'
  30
  31rev_list_tests() {
  32        state=$1
  33
  34        test_expect_success "counting commits via bitmap ($state)" '
  35                git rev-list --count HEAD >expect &&
  36                git rev-list --use-bitmap-index --count HEAD >actual &&
  37                test_cmp expect actual
  38        '
  39
  40        test_expect_success "counting partial commits via bitmap ($state)" '
  41                git rev-list --count HEAD~5..HEAD >expect &&
  42                git rev-list --use-bitmap-index --count HEAD~5..HEAD >actual &&
  43                test_cmp expect actual
  44        '
  45
  46        test_expect_success "counting non-linear history ($state)" '
  47                git rev-list --count other...master >expect &&
  48                git rev-list --use-bitmap-index --count other...master >actual &&
  49                test_cmp expect actual
  50        '
  51
  52        test_expect_success "enumerate --objects ($state)" '
  53                git rev-list --objects --use-bitmap-index HEAD >tmp &&
  54                cut -d" " -f1 <tmp >tmp2 &&
  55                sort <tmp2 >actual &&
  56                git rev-list --objects HEAD >tmp &&
  57                cut -d" " -f1 <tmp >tmp2 &&
  58                sort <tmp2 >expect &&
  59                test_cmp expect actual
  60        '
  61
  62        test_expect_success "bitmap --objects handles non-commit objects ($state)" '
  63                git rev-list --objects --use-bitmap-index HEAD tagged-blob >actual &&
  64                grep $blob actual
  65        '
  66}
  67
  68rev_list_tests 'full bitmap'
  69
  70test_expect_success 'clone from bitmapped repository' '
  71        git clone --no-local --bare . clone.git &&
  72        git rev-parse HEAD >expect &&
  73        git --git-dir=clone.git rev-parse HEAD >actual &&
  74        test_cmp expect actual
  75'
  76
  77test_expect_success 'setup further non-bitmapped commits' '
  78        for i in $(test_seq 1 10); do
  79                test_commit further-$i
  80        done
  81'
  82
  83rev_list_tests 'partial bitmap'
  84
  85test_expect_success 'fetch (partial bitmap)' '
  86        git --git-dir=clone.git fetch origin master:master &&
  87        git rev-parse HEAD >expect &&
  88        git --git-dir=clone.git rev-parse HEAD >actual &&
  89        test_cmp expect actual
  90'
  91
  92test_expect_success 'incremental repack cannot create bitmaps' '
  93        test_commit more-1 &&
  94        find .git/objects/pack -name "*.bitmap" >expect &&
  95        git repack -d &&
  96        find .git/objects/pack -name "*.bitmap" >actual &&
  97        test_cmp expect actual
  98'
  99
 100test_expect_success 'incremental repack can disable bitmaps' '
 101        test_commit more-2 &&
 102        git repack -d --no-write-bitmap-index
 103'
 104
 105test_expect_success 'full repack, reusing previous bitmaps' '
 106        git repack -ad &&
 107        ls .git/objects/pack/ | grep bitmap >output &&
 108        test_line_count = 1 output
 109'
 110
 111test_expect_success 'fetch (full bitmap)' '
 112        git --git-dir=clone.git fetch origin master:master &&
 113        git rev-parse HEAD >expect &&
 114        git --git-dir=clone.git rev-parse HEAD >actual &&
 115        test_cmp expect actual
 116'
 117
 118test_lazy_prereq JGIT '
 119        type jgit
 120'
 121
 122test_expect_success JGIT 'we can read jgit bitmaps' '
 123        git clone . compat-jgit &&
 124        (
 125                cd compat-jgit &&
 126                rm -f .git/objects/pack/*.bitmap &&
 127                jgit gc &&
 128                git rev-list --test-bitmap HEAD
 129        )
 130'
 131
 132test_expect_success JGIT 'jgit can read our bitmaps' '
 133        git clone . compat-us &&
 134        (
 135                cd compat-us &&
 136                git repack -adb &&
 137                # jgit gc will barf if it does not like our bitmaps
 138                jgit gc
 139        )
 140'
 141
 142test_done