]>
Commit | Line | Data |
---|---|---|
c9a42c4a JS |
1 | #!/bin/sh |
2 | ||
3 | test_description='some bundle related tests' | |
95cf2c01 | 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
6 | ||
c9a42c4a JS |
7 | . ./test-lib.sh |
8 | ||
9 | test_expect_success 'setup' ' | |
c5aecfc8 | 10 | test_oid_cache <<-EOF && |
11 | version sha1:2 | |
12 | version sha256:3 | |
13 | EOF | |
8a557bb7 | 14 | test_commit initial && |
c9a42c4a JS |
15 | test_tick && |
16 | git tag -m tag tag && | |
8a557bb7 TR |
17 | test_commit second && |
18 | test_commit third && | |
19 | git tag -d initial && | |
20 | git tag -d second && | |
21 | git tag -d third | |
c9a42c4a JS |
22 | ' |
23 | ||
3bbbe467 | 24 | test_expect_success '"verify" needs a worktree' ' |
95cf2c01 | 25 | git bundle create tip.bundle -1 main && |
85db3488 | 26 | nongit test_must_fail git bundle verify ../tip.bundle 2>err && |
3bbbe467 JS |
27 | test_i18ngrep "need a repository" err |
28 | ' | |
29 | ||
2c8544ab LF |
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 && | |
33 | grep tag output && | |
c9a42c4a JS |
34 | git bundle create bundle --all --since=7.Apr.2005.15:16:00.-0700 && |
35 | git ls-remote bundle > output && | |
36 | ! grep tag output | |
c9a42c4a JS |
37 | ' |
38 | ||
0f5cdf65 | 39 | test_expect_success 'die if bundle file cannot be created' ' |
0f5cdf65 CH |
40 | mkdir adir && |
41 | test_must_fail git bundle create adir --all | |
0f5cdf65 CH |
42 | ' |
43 | ||
5bb0fd2c | 44 | test_expect_success 'bundle --stdin' ' |
95cf2c01 | 45 | echo main | git bundle create stdin-bundle.bdl --stdin && |
f62e0a39 | 46 | git ls-remote stdin-bundle.bdl >output && |
95cf2c01 | 47 | grep main output |
f62e0a39 JN |
48 | ' |
49 | ||
5bb0fd2c | 50 | test_expect_success 'bundle --stdin <rev-list options>' ' |
95cf2c01 | 51 | echo main | git bundle create hybrid-bundle.bdl --stdin tag && |
f62e0a39 | 52 | git ls-remote hybrid-bundle.bdl >output && |
95cf2c01 | 53 | grep main output |
f62e0a39 JN |
54 | ' |
55 | ||
54440e15 | 56 | test_expect_success 'empty bundle file is rejected' ' |
8a557bb7 TR |
57 | : >empty-bundle && |
58 | test_must_fail git fetch empty-bundle | |
54440e15 BH |
59 | ' |
60 | ||
bc2fed49 TR |
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' ' | |
64 | : >file4 && | |
65 | test_tick && | |
66 | git add file4 && | |
67 | printf "%01200d\n" 0 | git commit -F - && | |
68 | test_commit fifth && | |
69 | git bundle create long-subject-bundle.bdl HEAD^..HEAD && | |
70 | git bundle list-heads long-subject-bundle.bdl >heads && | |
71 | test -s heads && | |
72 | git fetch long-subject-bundle.bdl && | |
0dbe6592 | 73 | sed -n "/^-/{p;q;}" long-subject-bundle.bdl >boundary && |
88ed241a | 74 | grep "^-$OID_REGEX " boundary |
bc2fed49 TR |
75 | ' |
76 | ||
5446e33f LF |
77 | test_expect_success 'prerequisites with an empty commit message' ' |
78 | : >file1 && | |
79 | git add file1 && | |
80 | test_tick && | |
81 | git commit --allow-empty-message -m "" && | |
82 | test_commit file2 && | |
83 | git bundle create bundle HEAD^.. && | |
84 | git bundle verify bundle | |
85 | ' | |
86 | ||
2c8ee1f5 JK |
87 | test_expect_success 'failed bundle creation does not leave cruft' ' |
88 | # This fails because the bundle would be empty. | |
95cf2c01 | 89 | test_must_fail git bundle create fail.bundle main..main && |
2c8ee1f5 JK |
90 | test_path_is_missing fail.bundle.lock |
91 | ' | |
92 | ||
fddf2ebe JT |
93 | test_expect_success 'fetch SHA-1 from bundle' ' |
94 | test_create_repo foo && | |
95 | test_commit -C foo x && | |
95cf2c01 | 96 | git -C foo bundle create tip.bundle -1 main && |
fddf2ebe JT |
97 | git -C foo rev-parse HEAD >hash && |
98 | ||
99 | # Exercise to ensure that fetching a SHA-1 from a bundle works with no | |
100 | # errors | |
101 | git fetch --no-tags foo/tip.bundle "$(cat hash)" | |
102 | ' | |
103 | ||
c5aecfc8 | 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$" | |
107 | ' | |
108 | ||
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 && | |
114 | # v3 git bundle | |
115 | @object-format=$(test_oid algo) | |
116 | EOF | |
117 | test_cmp expect actual && | |
118 | git bundle verify bundle | |
119 | ' | |
120 | ||
121 | test_expect_success 'git bundle v3 rejects unknown capabilities' ' | |
122 | cat >new <<-EOF && | |
123 | # v3 git bundle | |
124 | @object-format=$(test_oid algo) | |
125 | @unknown=silly | |
126 | EOF | |
127 | test_must_fail git bundle verify new 2>output && | |
128 | test_i18ngrep "unknown capability .unknown=silly." output | |
129 | ' | |
130 | ||
c9a42c4a | 131 | test_done |