interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t7427-submodule-object-storage-format.sh

104 lines · 3446 bytes Raw Blame History
1#!/bin/sh
2
3test_description='submodules handle the object storage format'
4
5. ./test-lib.sh
6
7test_object_storage_format () {
8 echo "$2" >expect &&
9 git -C "$1" rev-parse --show-object-storage-format >actual &&
10 test_cmp expect actual
11}
12
13test_expect_success 'setup' '
14 git config set --global protocol.file.allow always
15'
16
17test_expect_success 'add existing repository with different object storage format' '
18 test_when_finished "rm -rf parent" &&
19
20 git init parent &&
21 (
22 cd parent &&
23 test_commit parent &&
24 git init --object-storage-format=files://objs submodule &&
25 test_commit -C submodule submodule &&
26 git submodule add ./submodule &&
27 test_object_storage_format submodule files://objs
28 )
29'
30
31test_expect_success 'add submodules with explicit files storage format' '
32 test_when_finished "rm -rf submodule upstream" &&
33
34 git init submodule &&
35 test_commit -C submodule submodule-initial &&
36 git init upstream &&
37 test_object_storage_format upstream files &&
38 git -C upstream submodule add --object-storage-format=files "file://$(pwd)/submodule" &&
39 test_object_storage_format upstream/submodule files
40'
41
42test_expect_success 'add submodules with garbage object storage format' '
43 test_when_finished "rm -rf submodule upstream" &&
44
45 git init submodule &&
46 test_commit -C submodule submodule-initial &&
47 git init upstream &&
48 cat >expect <<-EOF &&
49 fatal: unknown object storage format ${SQ}garbage${SQ}
50 EOF
51 test_must_fail git -C upstream submodule add --object-storage-format=garbage "file://$(pwd)/submodule" 2>err &&
52 test_cmp expect err
53'
54
55test_expect_success 'add submodules with object storage payload is rejected' '
56 test_when_finished "rm -rf submodule upstream" &&
57
58 git init submodule &&
59 test_commit -C submodule submodule-initial &&
60 git init upstream &&
61 cat >expect <<-EOF &&
62 fatal: unknown object storage format ${SQ}files://objs${SQ}
63 EOF
64 test_must_fail git -C upstream submodule add --object-storage-format=files://objs "file://$(pwd)/submodule" 2>err &&
65 test_cmp expect err
66'
67
68test_expect_success 'recursive clone propagates object storage format' '
69 test_when_finished "rm -rf submodule upstream downstream" &&
70
71 git init submodule &&
72 test_commit -C submodule submodule-initial &&
73 git init upstream &&
74 git -C upstream submodule add "file://$(pwd)/submodule" &&
75 git -C upstream commit -am "add submodule" &&
76
77 test_object_storage_format upstream files &&
78 test_object_storage_format upstream/submodule files &&
79
80 git clone --object-storage-format=files://objs --recurse-submodules \
81 upstream downstream &&
82 test_object_storage_format downstream files://objs &&
83 test_object_storage_format downstream/submodule files &&
84 test_path_is_dir downstream/.git/objs/pack &&
85 test_path_is_dir downstream/.git/modules/submodule/objects/pack
86'
87
88test_expect_success 'clone submodules with explicit object storage format' '
89 test_when_finished "rm -rf submodule upstream downstream" &&
90
91 git init submodule &&
92 test_commit -C submodule submodule-initial &&
93 git init upstream &&
94 git -C upstream submodule add "file://$(pwd)/submodule" &&
95 git -C upstream commit -m "upstream submodule" &&
96
97 git clone --no-recurse-submodules "file://$(pwd)/upstream" downstream &&
98 test_object_storage_format downstream files &&
99 git -C downstream submodule update --init --object-storage-format=files &&
100 test_object_storage_format downstream/submodule files &&
101 test_path_is_dir downstream/.git/modules/submodule/objects/pack
102'
103
104test_done