Merge branch 'maint'
[git/mingw/4msysgit/kblees.git] / t / t7408-submodule-reference.sh
blobcc16d3f05de7ec51e8a071253654a6698f8f33c4
1 #!/bin/sh
3 # Copyright (c) 2009, Red Hat Inc, Author: Michael S. Tsirkin (mst@redhat.com)
6 test_description='test clone --reference'
7 . ./test-lib.sh
9 base_dir=`pwd`
11 U=$base_dir/UPLOAD_LOG
13 test_expect_success 'preparing first repository' \
14 'test_create_repo A && cd A &&
15 echo first > file1 &&
16 git add file1 &&
17 git commit -m A-initial'
19 cd "$base_dir"
21 test_expect_success 'preparing second repository' \
22 'git clone A B && cd B &&
23 echo second > file2 &&
24 git add file2 &&
25 git commit -m B-addition &&
26 git repack -a -d &&
27 git prune'
29 cd "$base_dir"
31 test_expect_success 'preparing supermodule' \
32 'test_create_repo super && cd super &&
33 echo file > file &&
34 git add file &&
35 git commit -m B-super-initial'
37 cd "$base_dir"
39 test_expect_success 'submodule add --reference' \
40 'cd super && git submodule add --reference ../B "file://$base_dir/A" sub &&
41 git commit -m B-super-added'
43 cd "$base_dir"
45 test_expect_success 'after add: existence of info/alternates' \
46 'test `wc -l <super/sub/.git/objects/info/alternates` = 1'
48 cd "$base_dir"
50 test_expect_success 'that reference gets used with add' \
51 'cd super/sub &&
52 echo "0 objects, 0 kilobytes" > expected &&
53 git count-objects > current &&
54 diff expected current'
56 cd "$base_dir"
58 test_expect_success 'cloning supermodule' \
59 'git clone super super-clone'
61 cd "$base_dir"
63 test_expect_success 'update with reference' \
64 'cd super-clone && git submodule update --init --reference ../B'
66 cd "$base_dir"
68 test_expect_success 'after update: existence of info/alternates' \
69 'test `wc -l <super-clone/sub/.git/objects/info/alternates` = 1'
71 cd "$base_dir"
73 test_expect_success 'that reference gets used with update' \
74 'cd super-clone/sub &&
75 echo "0 objects, 0 kilobytes" > expected &&
76 git count-objects > current &&
77 diff expected current'
79 cd "$base_dir"
81 test_done