3 test_description='some bundle related tests'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9 test_expect_success 'setup' '
10 test_oid_cache <<-EOF &&
14 test_commit initial &&
24 test_expect_success '"verify" needs a worktree' '
25 git bundle create tip.bundle -1 main &&
26 nongit test_must_fail git bundle verify ../tip.bundle 2>err &&
27 test_i18ngrep "need a repository" err
30 test_expect_success 'annotated tags can be excluded by rev-list options' '
31 git bundle create bundle --all --since=7.Apr.2005.15:14:00.-0700 &&
32 git ls-remote bundle > output &&
34 git bundle create bundle --all --since=7.Apr.2005.15:16:00.-0700 &&
35 git ls-remote bundle > output &&
39 test_expect_success 'die if bundle file cannot be created' '
41 test_must_fail git bundle create adir --all
44 test_expect_failure 'bundle --stdin' '
45 echo main | git bundle create stdin-bundle.bdl --stdin &&
46 git ls-remote stdin-bundle.bdl >output &&
50 test_expect_failure 'bundle --stdin <rev-list options>' '
51 echo main | git bundle create hybrid-bundle.bdl --stdin tag &&
52 git ls-remote hybrid-bundle.bdl >output &&
56 test_expect_success 'empty bundle file is rejected' '
58 test_must_fail git fetch empty-bundle
61 # This triggers a bug in older versions where the resulting line (with
62 # --pretty=oneline) was longer than a 1024-char buffer.
63 test_expect_success 'ridiculously long subject in boundary' '
67 printf "%01200d\n" 0 | git commit -F - &&
69 git bundle create long-subject-bundle.bdl HEAD^..HEAD &&
70 git bundle list-heads long-subject-bundle.bdl >heads &&
72 git fetch long-subject-bundle.bdl &&
73 sed -n "/^-/{p;q;}" long-subject-bundle.bdl >boundary &&
74 grep "^-$OID_REGEX " boundary
77 test_expect_success 'prerequisites with an empty commit message' '
81 git commit --allow-empty-message -m "" &&
83 git bundle create bundle HEAD^.. &&
84 git bundle verify bundle
87 test_expect_success 'failed bundle creation does not leave cruft' '
88 # This fails because the bundle would be empty.
89 test_must_fail git bundle create fail.bundle main..main &&
90 test_path_is_missing fail.bundle.lock
93 test_expect_success 'fetch SHA-1 from bundle' '
94 test_create_repo foo &&
95 test_commit -C foo x &&
96 git -C foo bundle create tip.bundle -1 main &&
97 git -C foo rev-parse HEAD >hash &&
99 # Exercise to ensure that fetching a SHA-1 from a bundle works with no
101 git fetch --no-tags foo/tip.bundle "$(cat hash)"
104 test_expect_success 'git bundle uses expected default format' '
105 git bundle create bundle HEAD^.. &&
106 head -n1 bundle | grep "^# v$(test_oid version) git bundle$"
109 test_expect_success 'git bundle v3 has expected contents' '
110 git branch side HEAD &&
111 git bundle create --version=3 bundle HEAD^..side &&
112 head -n2 bundle >actual &&
113 cat >expect <<-EOF &&
115 @object-format=$(test_oid algo)
117 test_cmp expect actual &&
118 git bundle verify bundle
121 test_expect_success 'git bundle v3 rejects unknown capabilities' '
124 @object-format=$(test_oid algo)
127 test_must_fail git bundle verify new 2>output &&
128 test_i18ngrep "unknown capability .unknown=silly." output