]>
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 | ||
11 | test_expect_success 'preparing first repository' \ | |
12 | 'test_create_repo A && cd A && | |
13 | echo first > file1 && | |
14 | git add file1 && | |
15 | git commit -m initial' | |
16 | ||
17 | cd "$base_dir" | |
18 | ||
19 | test_expect_success 'preparing second repository' \ | |
20 | 'git clone A B && cd B && | |
21 | echo second > file2 && | |
22 | git add file2 && | |
23 | git commit -m addition && | |
24 | git repack -a -d && | |
026aa938 | 25 | git prune' |
cf9dc653 MW |
26 | |
27 | cd "$base_dir" | |
28 | ||
1f7d1a53 | 29 | test_expect_success 'cloning with reference (-l -s)' \ |
cf9dc653 MW |
30 | 'git clone -l -s --reference B A C' |
31 | ||
32 | cd "$base_dir" | |
33 | ||
82e5a82f | 34 | test_expect_success 'existence of info/alternates' \ |
cf9dc653 MW |
35 | 'test `wc -l <C/.git/objects/info/alternates` = 2' |
36 | ||
37 | cd "$base_dir" | |
38 | ||
39 | test_expect_success 'pulling from reference' \ | |
40 | 'cd C && | |
da0204df | 41 | git pull ../B master' |
cf9dc653 MW |
42 | |
43 | cd "$base_dir" | |
44 | ||
45 | test_expect_success 'that reference gets used' \ | |
46 | 'cd C && | |
47 | echo "0 objects, 0 kilobytes" > expected && | |
48 | git count-objects > current && | |
49 | diff expected current' | |
50 | ||
51 | cd "$base_dir" | |
52 | ||
1f7d1a53 | 53 | test_expect_success 'cloning with reference (no -l -s)' \ |
f69e836f | 54 | 'git clone --reference B "file://$(pwd)/A" D' |
1f7d1a53 JH |
55 | |
56 | cd "$base_dir" | |
57 | ||
58 | test_expect_success 'existence of info/alternates' \ | |
59 | 'test `wc -l <D/.git/objects/info/alternates` = 1' | |
60 | ||
61 | cd "$base_dir" | |
62 | ||
63 | test_expect_success 'pulling from reference' \ | |
da0204df | 64 | 'cd D && git pull ../B master' |
1f7d1a53 JH |
65 | |
66 | cd "$base_dir" | |
67 | ||
68 | test_expect_success 'that reference gets used' \ | |
69 | 'cd D && echo "0 objects, 0 kilobytes" > expected && | |
70 | git count-objects > current && | |
71 | diff expected current' | |
72 | ||
73 | cd "$base_dir" | |
74 | ||
cf9dc653 MW |
75 | test_expect_success 'updating origin' \ |
76 | 'cd A && | |
77 | echo third > file3 && | |
78 | git add file3 && | |
79 | git commit -m update && | |
80 | git repack -a -d && | |
026aa938 | 81 | git prune' |
cf9dc653 MW |
82 | |
83 | cd "$base_dir" | |
84 | ||
85 | test_expect_success 'pulling changes from origin' \ | |
86 | 'cd C && | |
87 | git pull origin' | |
88 | ||
89 | cd "$base_dir" | |
90 | ||
91 | # the 2 local objects are commit and tree from the merge | |
92 | test_expect_success 'that alternate to origin gets used' \ | |
93 | 'cd C && | |
94 | echo "2 objects" > expected && | |
95 | git count-objects | cut -d, -f1 > current && | |
96 | diff expected current' | |
97 | ||
98 | cd "$base_dir" | |
99 | ||
1f7d1a53 JH |
100 | test_expect_success 'pulling changes from origin' \ |
101 | 'cd D && | |
102 | git pull origin' | |
103 | ||
104 | cd "$base_dir" | |
105 | ||
106 | # the 5 local objects are expected; file3 blob, commit in A to add it | |
107 | # and its tree, and 2 are our tree and the merge commit. | |
108 | test_expect_success 'check objects expected to exist locally' \ | |
109 | 'cd D && | |
110 | echo "5 objects" > expected && | |
111 | git count-objects | cut -d, -f1 > current && | |
112 | diff expected current' | |
113 | ||
114 | cd "$base_dir" | |
115 | ||
cf9dc653 | 116 | test_done |