3 # Copyright (c) 2009, Red Hat Inc, Author: Michael S. Tsirkin (mst@redhat.com)
6 test_description='test clone --reference'
11 test_alternate_is_used () {
12 alternates_file="$1" &&
14 test_line_count = 1 "$alternates_file" &&
15 echo "0 objects, 0 kilobytes" >expect &&
16 git -C "$working_dir" count-objects >actual &&
17 test_cmp expect actual
20 test_expect_success 'preparing first repository' '
26 git commit -m A-initial
30 test_expect_success 'preparing second repository' '
36 git commit -m B-addition &&
42 test_expect_success 'preparing superproject' '
43 test_create_repo super &&
48 git commit -m B-super-initial
52 test_expect_success 'submodule add --reference uses alternates' '
55 git submodule add --reference ../B "file://$base_dir/A" sub &&
56 git commit -m B-super-added &&
59 test_alternate_is_used super/.git/modules/sub/objects/info/alternates super/sub
62 test_expect_success 'that reference gets used with add' '
65 echo "0 objects, 0 kilobytes" >expected &&
66 git count-objects >current &&
71 # The tests up to this point, and repositories created by them
72 # (A, B, super and super/sub), are about setting up the stage
73 # for subsequent tests and meant to be kept throughout the
74 # remainder of the test.
75 # Tests from here on, if they create their own test repository,
76 # are expected to clean after themselves.
78 test_expect_success 'updating superproject keeps alternates' '
79 test_when_finished "rm -rf super-clone" &&
80 git clone super super-clone &&
81 git -C super-clone submodule update --init --reference ../B &&
82 test_alternate_is_used super-clone/.git/modules/sub/objects/info/alternates super-clone/sub