]>
Commit | Line | Data |
---|---|---|
cf9dc653 MW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (C) 2006 Martin Waitz <tali@admingilde.org> | |
4 | # | |
5 | ||
6 | test_description='test clone --reference' | |
7 | . ./test-lib.sh | |
8 | ||
9 | base_dir=`pwd` | |
10 | ||
4ba776c2 DB |
11 | U=$base_dir/UPLOAD_LOG |
12 | ||
cf9dc653 MW |
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 initial' | |
18 | ||
19 | cd "$base_dir" | |
20 | ||
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 addition && | |
26 | git repack -a -d && | |
026aa938 | 27 | git prune' |
cf9dc653 MW |
28 | |
29 | cd "$base_dir" | |
30 | ||
1f7d1a53 | 31 | test_expect_success 'cloning with reference (-l -s)' \ |
cf9dc653 MW |
32 | 'git clone -l -s --reference B A C' |
33 | ||
34 | cd "$base_dir" | |
35 | ||
82e5a82f | 36 | test_expect_success 'existence of info/alternates' \ |
cf9dc653 MW |
37 | 'test `wc -l <C/.git/objects/info/alternates` = 2' |
38 | ||
39 | cd "$base_dir" | |
40 | ||
41 | test_expect_success 'pulling from reference' \ | |
42 | 'cd C && | |
da0204df | 43 | git pull ../B master' |
cf9dc653 MW |
44 | |
45 | cd "$base_dir" | |
46 | ||
47 | test_expect_success 'that reference gets used' \ | |
48 | 'cd C && | |
49 | echo "0 objects, 0 kilobytes" > expected && | |
50 | git count-objects > current && | |
51 | diff expected current' | |
52 | ||
53 | cd "$base_dir" | |
54 | ||
cb418b5a | 55 | rm -f "$U" |
4ba776c2 | 56 | |
1f7d1a53 | 57 | test_expect_success 'cloning with reference (no -l -s)' \ |
cb418b5a | 58 | 'GIT_DEBUG_SEND_PACK=3 git clone --reference B "file://$(pwd)/A" D 3>"$U"' |
4ba776c2 DB |
59 | |
60 | test_expect_success 'fetched no objects' \ | |
cb418b5a | 61 | '! grep "^want" "$U"' |
1f7d1a53 JH |
62 | |
63 | cd "$base_dir" | |
64 | ||
65 | test_expect_success 'existence of info/alternates' \ | |
66 | 'test `wc -l <D/.git/objects/info/alternates` = 1' | |
67 | ||
68 | cd "$base_dir" | |
69 | ||
70 | test_expect_success 'pulling from reference' \ | |
da0204df | 71 | 'cd D && git pull ../B master' |
1f7d1a53 JH |
72 | |
73 | cd "$base_dir" | |
74 | ||
75 | test_expect_success 'that reference gets used' \ | |
76 | 'cd D && echo "0 objects, 0 kilobytes" > expected && | |
77 | git count-objects > current && | |
78 | diff expected current' | |
79 | ||
80 | cd "$base_dir" | |
81 | ||
cf9dc653 MW |
82 | test_expect_success 'updating origin' \ |
83 | 'cd A && | |
84 | echo third > file3 && | |
85 | git add file3 && | |
86 | git commit -m update && | |
87 | git repack -a -d && | |
026aa938 | 88 | git prune' |
cf9dc653 MW |
89 | |
90 | cd "$base_dir" | |
91 | ||
92 | test_expect_success 'pulling changes from origin' \ | |
93 | 'cd C && | |
94 | git pull origin' | |
95 | ||
96 | cd "$base_dir" | |
97 | ||
98 | # the 2 local objects are commit and tree from the merge | |
99 | test_expect_success 'that alternate to origin gets used' \ | |
100 | 'cd C && | |
101 | echo "2 objects" > expected && | |
102 | git count-objects | cut -d, -f1 > current && | |
103 | diff expected current' | |
104 | ||
105 | cd "$base_dir" | |
106 | ||
1f7d1a53 JH |
107 | test_expect_success 'pulling changes from origin' \ |
108 | 'cd D && | |
109 | git pull origin' | |
110 | ||
111 | cd "$base_dir" | |
112 | ||
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' \ | |
116 | 'cd D && | |
117 | echo "5 objects" > expected && | |
118 | git count-objects | cut -d, -f1 > current && | |
119 | diff expected current' | |
120 | ||
121 | cd "$base_dir" | |
122 | ||
fabb0199 JH |
123 | test_expect_success 'preparing alternate repository #1' \ |
124 | 'test_create_repo F && cd F && | |
125 | echo first > file1 && | |
126 | git add file1 && | |
127 | git commit -m initial' | |
128 | ||
129 | cd "$base_dir" | |
130 | ||
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 && | |
134 | git add file2 && | |
135 | git commit -m addition' | |
136 | ||
137 | cd "$base_dir" | |
138 | ||
139 | test_expect_success 'cloning alternate repo #1, using #2 as reference' \ | |
140 | 'git clone --reference G F H' | |
141 | ||
142 | cd "$base_dir" | |
143 | ||
b50c8469 JH |
144 | test_expect_success 'cloning with reference being subset of source (-l -s)' \ |
145 | 'git clone -l -s --reference A B E' | |
146 | ||
147 | cd "$base_dir" | |
148 | ||
cf9dc653 | 149 | test_done |