3 # Copyright (C) 2006 Martin Waitz <tali@admingilde.org>
6 test_description='test clone --reference'
11 U=$base_dir/UPLOAD_LOG
13 test_expect_success 'preparing first repository' \
14 'test_create_repo A && cd A &&
17 git commit -m initial'
21 test_expect_success 'preparing second repository' \
22 'git clone A B && cd B &&
23 echo second > file2 &&
25 git commit -m addition &&
31 test_expect_success 'cloning with reference (-l -s)' \
32 'git clone -l -s --reference B A C'
36 test_expect_success 'existence of info/alternates' \
37 'test_line_count = 2 C/.git/objects/info/alternates'
41 test_expect_success 'pulling from reference' \
47 test_expect_success 'that reference gets used' \
49 echo "0 objects, 0 kilobytes" > expected &&
50 git count-objects > current &&
51 test_cmp expected current'
57 test_expect_success 'cloning with reference (no -l -s)' \
58 'GIT_DEBUG_SEND_PACK=3 git clone --reference B "file://$(pwd)/A" D 3>"$U.D"'
60 test_expect_success 'fetched no objects' \
61 '! grep "^want" "$U.D"'
65 test_expect_success 'existence of info/alternates' \
66 'test_line_count = 1 D/.git/objects/info/alternates'
70 test_expect_success 'pulling from reference' \
71 'cd D && git pull ../B master'
75 test_expect_success 'that reference gets used' \
76 'cd D && echo "0 objects, 0 kilobytes" > expected &&
77 git count-objects > current &&
78 test_cmp expected current'
82 test_expect_success 'updating origin' \
86 git commit -m update &&
92 test_expect_success 'pulling changes from origin' \
98 # the 2 local objects are commit and tree from the merge
99 test_expect_success 'that alternate to origin gets used' \
101 echo "2 objects" > expected &&
102 git count-objects | cut -d, -f1 > current &&
103 test_cmp expected current'
107 test_expect_success 'pulling changes from origin' \
113 # the 5 local objects are expected; file3 blob, commit in A to add it
114 # and its tree, and 2 are our tree and the merge commit.
115 test_expect_success 'check objects expected to exist locally' \
117 echo "5 objects" > expected &&
118 git count-objects | cut -d, -f1 > current &&
119 test_cmp expected current'
123 test_expect_success 'preparing alternate repository #1' \
124 'test_create_repo F && cd F &&
125 echo first > file1 &&
127 git commit -m initial'
131 test_expect_success 'cloning alternate repo #2 and adding changes to repo #1' \
132 'git clone F G && cd F &&
133 echo second > file2 &&
135 git commit -m addition'
139 test_expect_success 'cloning alternate repo #1, using #2 as reference' \
140 'git clone --reference G F H'
144 test_expect_success 'cloning with reference being subset of source (-l -s)' \
145 'git clone -l -s --reference A B E'
149 test_expect_success 'clone with reference from a tagged repository' '
151 cd A && git tag -a -m 'tagged' HEAD
153 git clone --reference=A A I
156 test_expect_success 'prepare branched repository' '
160 git checkout -b other master^ &&
161 echo other >otherfile &&
163 git commit -m other &&
170 test_expect_success 'fetch with incomplete alternates' '
172 echo "$base_dir/A/.git/objects" >K/.git/objects/info/alternates &&
175 git remote add J "file://$base_dir/J" &&
176 GIT_DEBUG_SEND_PACK=3 git fetch J 3>"$U.K"
178 master_object=$(cd A && git for-each-ref --format="%(objectname)" refs/heads/master) &&
179 ! grep "^want $master_object" "$U.K" &&
180 tag_object=$(cd A && git for-each-ref --format="%(objectname)" refs/tags/HEAD) &&
181 ! grep "^want $tag_object" "$U.K"