t7408: modernize style
[git] / t / t7408-submodule-reference.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2009, Red Hat Inc, Author: Michael S. Tsirkin (mst@redhat.com)
4 #
5
6 test_description='test clone --reference'
7 . ./test-lib.sh
8
9 base_dir=$(pwd)
10
11 test_expect_success 'preparing first repository' '
12         test_create_repo A &&
13         (
14                 cd A &&
15                 echo first >file1 &&
16                 git add file1 &&
17                 git commit -m A-initial
18         )
19 '
20
21 test_expect_success 'preparing second repository' '
22         git clone A B &&
23         (
24                 cd B &&
25                 echo second >file2 &&
26                 git add file2 &&
27                 git commit -m B-addition &&
28                 git repack -a -d &&
29                 git prune
30         )
31 '
32
33 test_expect_success 'preparing superproject' '
34         test_create_repo super &&
35         (
36                 cd super &&
37                 echo file >file &&
38                 git add file &&
39                 git commit -m B-super-initial
40         )
41 '
42
43 test_expect_success 'submodule add --reference' '
44         (
45                 cd super &&
46                 git submodule add --reference ../B "file://$base_dir/A" sub &&
47                 git commit -m B-super-added
48         )
49 '
50
51 test_expect_success 'after add: existence of info/alternates' '
52         test_line_count = 1 super/.git/modules/sub/objects/info/alternates
53 '
54
55 test_expect_success 'that reference gets used with add' '
56         (
57                 cd super/sub &&
58                 echo "0 objects, 0 kilobytes" >expected &&
59                 git count-objects >current &&
60                 diff expected current
61         )
62 '
63
64 test_expect_success 'cloning superproject' '
65         git clone super super-clone
66 '
67
68 test_expect_success 'update with reference' '
69         cd super-clone && git submodule update --init --reference ../B
70 '
71
72 test_expect_success 'after update: existence of info/alternates' '
73         test_line_count = 1 super-clone/.git/modules/sub/objects/info/alternates
74 '
75
76 test_expect_success 'that reference gets used with update' '
77         cd super-clone/sub &&
78         echo "0 objects, 0 kilobytes" >expected &&
79         git count-objects >current &&
80         diff expected current
81 '
82
83 test_done