diff options
| author | Junio C Hamano <gitster@pobox.com> | 2021-02-22 16:12:43 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2021-02-22 16:12:43 -0800 |
| commit | d68fccef86af1ceb5ae3a9abb02c8fe4f6ff3317 (patch) | |
| tree | 020527039643bd7dcf1c498e6d1c90b2aabc612d /t/lib-bundle.sh | |
| parent | 45df6c4d756df25d04f82f4803923baaf0c12a33 (diff) | |
| parent | e7884b353b7f3b61c2b8ace086bc7e030946e270 (diff) | |
| download | git-d68fccef86af1ceb5ae3a9abb02c8fe4f6ff3317.tar.xz | |
Merge branch 'ab/test-lib'
Test framework clean-up.
* ab/test-lib:
test-lib-functions: assert correct parameter count
test-lib-functions: remove bug-inducing "diagnostics" helper param
test libs: rename "diff-lib" to "lib-diff"
t/.gitattributes: sort lines
test-lib-functions: move function to lib-bitmap.sh
test libs: rename gitweb-lib.sh to lib-gitweb.sh
test libs: rename bundle helper to "lib-bundle.sh"
test-lib-functions: remove generate_zero_bytes() wrapper
test-lib-functions: move test_set_index_version() to its user
test lib: change "error" to "BUG" as appropriate
test-lib: remove check_var_migration
Diffstat (limited to 't/lib-bundle.sh')
| -rw-r--r-- | t/lib-bundle.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/t/lib-bundle.sh b/t/lib-bundle.sh new file mode 100644 index 0000000000..cf7ed818b2 --- /dev/null +++ b/t/lib-bundle.sh @@ -0,0 +1,42 @@ +# Library of git-bundle related functions. + +# Display the pack data contained in the bundle file, bypassing the +# header that contains the signature, prerequisites and references. +convert_bundle_to_pack () { + while read x && test -n "$x" + do + :; + done + cat +} + +# Check count of objects in a bundle file. +# We can use "--thin" opiton to check thin pack, which must be fixed by +# command `git-index-pack --fix-thin --stdin`. +test_bundle_object_count () { + thin= + if test "$1" = "--thin" + then + thin=t + shift + fi + if test $# -ne 2 + then + echo >&2 "args should be: <bundle> <count>" + return 1 + fi + bundle=$1 + pack=$bundle.pack + convert_bundle_to_pack <"$bundle" >"$pack" && + if test -n "$thin" + then + mv "$pack" "$bundle.thin.pack" && + git index-pack --stdin --fix-thin "$pack" <"$bundle.thin.pack" + else + git index-pack "$pack" + fi || return 1 + count=$(git show-index <"${pack%pack}idx" | wc -l) && + test $2 = $count && return 0 + echo >&2 "error: object count for $bundle is $count, not $2" + return 1 +} |
