Git fork
at reftables-rust 42 lines 1.0 kB view raw
1# Library of git-bundle related functions. 2 3# Display the pack data contained in the bundle file, bypassing the 4# header that contains the signature, prerequisites and references. 5convert_bundle_to_pack () { 6 while read x && test -n "$x" 7 do 8 :; 9 done 10 cat 11} 12 13# Check count of objects in a bundle file. 14# We can use "--thin" option to check thin pack, which must be fixed by 15# command `git-index-pack --fix-thin --stdin`. 16test_bundle_object_count () { 17 thin= 18 if test "$1" = "--thin" 19 then 20 thin=t 21 shift 22 fi 23 if test $# -ne 2 24 then 25 echo >&2 "args should be: <bundle> <count>" 26 return 1 27 fi 28 bundle=$1 29 pack=$bundle.pack 30 convert_bundle_to_pack <"$bundle" >"$pack" && 31 if test -n "$thin" 32 then 33 mv "$pack" "$bundle.thin.pack" && 34 git index-pack --stdin --fix-thin "$pack" <"$bundle.thin.pack" 35 else 36 git index-pack "$pack" 37 fi || return 1 38 count=$(git show-index <"${pack%pack}idx" | wc -l) && 39 test $2 = $count && return 0 40 echo >&2 "error: object count for $bundle is $count, not $2" 41 return 1 42}