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