| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='check bitmap operation with shallow repositories' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | # We want to create a situation where the shallow, grafted |
| 8 | # view of reachability does not match reality in a way that |
| 9 | # might cause us to send insufficient objects. |
| 10 | # |
| 11 | # We do this with a history that repeats a state, like: |
| 12 | # |
| 13 | # A -- B -- C |
| 14 | # file=1 file=2 file=1 |
| 15 | # |
| 16 | # and then create a shallow clone to the second commit, B. |
| 17 | # In a non-shallow clone, that would mean we already have |
| 18 | # the tree for A. But in a shallow one, we've grafted away |
| 19 | # A, and fetching A to B requires that the other side send |
| 20 | # us the tree for file=1. |
| 21 | test_shallow_bitmaps () { |
| 22 | writeLookupTable=false |
| 23 | |
| 24 | for i in "$@" |
| 25 | do |
| 26 | case $i in |
| 27 | "pack.writeBitmapLookupTable") writeLookupTable=true;; |
| 28 | esac |
| 29 | done |
| 30 | |
| 31 | test_expect_success 'setup shallow repo' ' |
| 32 | rm -rf * .git && |
| 33 | git init && |
| 34 | git config pack.writeBitmapLookupTable '"$writeLookupTable"' && |
| 35 | echo 1 >file && |
| 36 | git add file && |
| 37 | git commit -m orig && |
| 38 | echo 2 >file && |
| 39 | git commit -a -m update && |
| 40 | git clone --no-local --bare --depth=1 . shallow.git && |
| 41 | echo 1 >file && |
| 42 | git commit -a -m repeat |
| 43 | ' |
| 44 | |
| 45 | test_expect_success 'turn on bitmaps in the parent' ' |
| 46 | git repack -adb |
| 47 | ' |
| 48 | |
| 49 | test_expect_success 'shallow fetch from bitmapped repo' ' |
| 50 | (cd shallow.git && git fetch) |
| 51 | ' |
| 52 | } |
| 53 | |
| 54 | test_shallow_bitmaps |
| 55 | test_shallow_bitmaps "pack.writeBitmapLookupTable" |
| 56 | |
| 57 | test_done |