]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5700-clone-reference.sh
git-svn: disable _rev_list memoization
[thirdparty/git.git] / t / t5700-clone-reference.sh
CommitLineData
cf9dc653
MW
1#!/bin/sh
2#
3# Copyright (C) 2006 Martin Waitz <tali@admingilde.org>
4#
5
6test_description='test clone --reference'
7. ./test-lib.sh
8
9base_dir=`pwd`
10
4ba776c2
DB
11U=$base_dir/UPLOAD_LOG
12
cf9dc653
MW
13test_expect_success 'preparing first repository' \
14'test_create_repo A && cd A &&
15echo first > file1 &&
16git add file1 &&
17git commit -m initial'
18
19cd "$base_dir"
20
21test_expect_success 'preparing second repository' \
22'git clone A B && cd B &&
23echo second > file2 &&
24git add file2 &&
25git commit -m addition &&
26git repack -a -d &&
026aa938 27git prune'
cf9dc653
MW
28
29cd "$base_dir"
30
1f7d1a53 31test_expect_success 'cloning with reference (-l -s)' \
cf9dc653
MW
32'git clone -l -s --reference B A C'
33
34cd "$base_dir"
35
82e5a82f 36test_expect_success 'existence of info/alternates' \
3fb0459b 37'test_line_count = 2 C/.git/objects/info/alternates'
cf9dc653
MW
38
39cd "$base_dir"
40
41test_expect_success 'pulling from reference' \
42'cd C &&
da0204df 43git pull ../B master'
cf9dc653
MW
44
45cd "$base_dir"
46
47test_expect_success 'that reference gets used' \
48'cd C &&
49echo "0 objects, 0 kilobytes" > expected &&
50git count-objects > current &&
4fdf71be 51test_cmp expected current'
cf9dc653
MW
52
53cd "$base_dir"
54
acede2eb 55rm -f "$U.D"
4ba776c2 56
2ad23273
JK
57test_expect_success 'cloning with reference (no -l -s)' '
58 GIT_TRACE_PACKET=$U.D git clone --reference B "file://$(pwd)/A" D
59'
4ba776c2 60
2ad23273
JK
61test_expect_success 'fetched no objects' '
62 test -s "$U.D" &&
63 ! grep " want" "$U.D"
64'
1f7d1a53
JH
65
66cd "$base_dir"
67
68test_expect_success 'existence of info/alternates' \
3fb0459b 69'test_line_count = 1 D/.git/objects/info/alternates'
1f7d1a53
JH
70
71cd "$base_dir"
72
73test_expect_success 'pulling from reference' \
da0204df 74'cd D && git pull ../B master'
1f7d1a53
JH
75
76cd "$base_dir"
77
78test_expect_success 'that reference gets used' \
79'cd D && echo "0 objects, 0 kilobytes" > expected &&
80git count-objects > current &&
4fdf71be 81test_cmp expected current'
1f7d1a53
JH
82
83cd "$base_dir"
84
cf9dc653
MW
85test_expect_success 'updating origin' \
86'cd A &&
87echo third > file3 &&
88git add file3 &&
89git commit -m update &&
90git repack -a -d &&
026aa938 91git prune'
cf9dc653
MW
92
93cd "$base_dir"
94
95test_expect_success 'pulling changes from origin' \
96'cd C &&
97git pull origin'
98
99cd "$base_dir"
100
101# the 2 local objects are commit and tree from the merge
102test_expect_success 'that alternate to origin gets used' \
103'cd C &&
104echo "2 objects" > expected &&
105git count-objects | cut -d, -f1 > current &&
4fdf71be 106test_cmp expected current'
cf9dc653
MW
107
108cd "$base_dir"
109
1f7d1a53
JH
110test_expect_success 'pulling changes from origin' \
111'cd D &&
112git pull origin'
113
114cd "$base_dir"
115
116# the 5 local objects are expected; file3 blob, commit in A to add it
117# and its tree, and 2 are our tree and the merge commit.
118test_expect_success 'check objects expected to exist locally' \
119'cd D &&
120echo "5 objects" > expected &&
121git count-objects | cut -d, -f1 > current &&
4fdf71be 122test_cmp expected current'
1f7d1a53
JH
123
124cd "$base_dir"
125
fabb0199
JH
126test_expect_success 'preparing alternate repository #1' \
127'test_create_repo F && cd F &&
128echo first > file1 &&
129git add file1 &&
130git commit -m initial'
131
132cd "$base_dir"
133
134test_expect_success 'cloning alternate repo #2 and adding changes to repo #1' \
135'git clone F G && cd F &&
136echo second > file2 &&
137git add file2 &&
138git commit -m addition'
139
140cd "$base_dir"
141
142test_expect_success 'cloning alternate repo #1, using #2 as reference' \
143'git clone --reference G F H'
144
145cd "$base_dir"
146
b50c8469
JH
147test_expect_success 'cloning with reference being subset of source (-l -s)' \
148'git clone -l -s --reference A B E'
149
150cd "$base_dir"
151
09116a1c
JH
152test_expect_success 'clone with reference from a tagged repository' '
153 (
154 cd A && git tag -a -m 'tagged' HEAD
155 ) &&
156 git clone --reference=A A I
157'
158
acede2eb
MH
159test_expect_success 'prepare branched repository' '
160 git clone A J &&
161 (
162 cd J &&
163 git checkout -b other master^ &&
164 echo other >otherfile &&
165 git add otherfile &&
166 git commit -m other &&
167 git checkout master
168 )
169'
170
171rm -f "$U.K"
172
f2576591 173test_expect_success 'fetch with incomplete alternates' '
acede2eb
MH
174 git init K &&
175 echo "$base_dir/A/.git/objects" >K/.git/objects/info/alternates &&
176 (
177 cd K &&
178 git remote add J "file://$base_dir/J" &&
2ad23273 179 GIT_TRACE_PACKET=$U.K git fetch J
acede2eb
MH
180 ) &&
181 master_object=$(cd A && git for-each-ref --format="%(objectname)" refs/heads/master) &&
2ad23273 182 test -s "$U.K" &&
97a83fa8 183 ! grep " want $master_object" "$U.K" &&
acede2eb 184 tag_object=$(cd A && git for-each-ref --format="%(objectname)" refs/tags/HEAD) &&
97a83fa8 185 ! grep " want $tag_object" "$U.K"
acede2eb
MH
186'
187
b552b56d
AS
188test_expect_success 'clone using repo with gitfile as a reference' '
189 git clone --separate-git-dir=L A M &&
190 git clone --reference=M A N &&
191 echo "$base_dir/L/objects" >expected &&
192 test_cmp expected "$base_dir/N/.git/objects/info/alternates"
193'
194
195test_expect_success 'clone using repo pointed at by gitfile as reference' '
196 git clone --reference=M/.git A O &&
197 echo "$base_dir/L/objects" >expected &&
198 test_cmp expected "$base_dir/O/.git/objects/info/alternates"
199'
200
cf9dc653 201test_done