Merge branch 'jc/ci-upload-artifact-and-linux32'
[git/gitster.git] / t / lib-bundle.sh
blobcf7ed818b246ac314af875bc42ad74e4ae661fd5
1 # Library of git-bundle related functions.
3 # Display the pack data contained in the bundle file, bypassing the
4 # header that contains the signature, prerequisites and references.
5 convert_bundle_to_pack () {
6 while read x && test -n "$x"
7 do
8 :;
9 done
10 cat
13 # Check count of objects in a bundle file.
14 # We can use "--thin" opiton to check thin pack, which must be fixed by
15 # command `git-index-pack --fix-thin --stdin`.
16 test_bundle_object_count () {
17 thin=
18 if test "$1" = "--thin"
19 then
20 thin=t
21 shift
23 if test $# -ne 2
24 then
25 echo >&2 "args should be: <bundle> <count>"
26 return 1
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