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