]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t6020-bundle-misc.sh
bundle: create filtered bundles
[thirdparty/git.git] / t / t6020-bundle-misc.sh
index df5ff561fa5c1b837d2db0222af7631677c17169..6e97c044ee7fa83f7c3fa837cae01d1ebec85331 100755 (executable)
@@ -487,4 +487,52 @@ test_expect_success 'unfiltered bundle with --objects' '
        test_cmp expect actual
 '
 
+for filter in "blob:none" "tree:0" "tree:1" "blob:limit=100"
+do
+       test_expect_success "filtered bundle: $filter" '
+               test_when_finished rm -rf .git/objects/pack cloned unbundled &&
+               git bundle create partial.bdl \
+                       --all \
+                       --filter=$filter &&
+
+               git bundle verify partial.bdl >unfiltered &&
+               make_user_friendly_and_stable_output <unfiltered >actual &&
+
+               cat >expect <<-EOF &&
+               The bundle contains these 10 refs:
+               <COMMIT-P> refs/heads/main
+               <COMMIT-N> refs/heads/release
+               <COMMIT-D> refs/heads/topic/1
+               <COMMIT-H> refs/heads/topic/2
+               <COMMIT-D> refs/pull/1/head
+               <COMMIT-G> refs/pull/2/head
+               <TAG-1> refs/tags/v1
+               <TAG-2> refs/tags/v2
+               <TAG-3> refs/tags/v3
+               <COMMIT-P> HEAD
+               The bundle uses this filter: $filter
+               The bundle records a complete history.
+               EOF
+               test_cmp expect actual &&
+
+               test_config uploadpack.allowfilter 1 &&
+               test_config uploadpack.allowanysha1inwant 1 &&
+               git clone --no-local --filter=$filter --bare "file://$(pwd)" cloned &&
+
+               git init unbundled &&
+               git -C unbundled bundle unbundle ../partial.bdl >ref-list.txt &&
+
+               # Count the same number of reachable objects.
+               reflist=$(git for-each-ref --format="%(objectname)") &&
+               git rev-list --objects --filter=$filter --missing=allow-any \
+                       $reflist >expect &&
+               for repo in cloned unbundled
+               do
+                       git -C $repo rev-list --objects --missing=allow-any \
+                               $reflist >actual &&
+                       test_cmp expect actual || return 1
+               done
+       '
+done
+
 test_done