@@ -10,49 +10,51 @@ base_dir=`pwd`
10
10
11
11
U=$base_dir /UPLOAD_LOG
12
12
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 &&
27
- git prune'
28
-
29
- cd " $base_dir "
30
-
31
- test_expect_success ' cloning with reference (-l -s)' \
32
- ' git clone -l -s --reference B A C'
33
-
34
- cd " $base_dir "
35
-
36
- test_expect_success ' existence of info/alternates' \
37
- ' test_line_count = 2 C/.git/objects/info/alternates'
38
-
39
- cd " $base_dir "
13
+ # create a commit in repo $1 with name $2
14
+ commit_in () {
15
+ (
16
+ cd " $1 " &&
17
+ echo " $2 " > " $2 " &&
18
+ git add " $2 " &&
19
+ git commit -m " $2 "
20
+ )
21
+ }
22
+
23
+ # check that there are $2 loose objects in repo $1
24
+ test_objcount () {
25
+ echo " $2 " > expect &&
26
+ git -C " $1 " count-objects > actual.raw &&
27
+ cut -d' ' -f1 < actual.raw > actual &&
28
+ test_cmp expect actual
29
+ }
30
+
31
+ test_expect_success ' preparing first repository' '
32
+ test_create_repo A &&
33
+ commit_in A file1
34
+ '
40
35
41
- test_expect_success ' pulling from reference' \
42
- ' cd C &&
43
- git pull ../B master'
36
+ test_expect_success ' preparing second repository' '
37
+ git clone A B &&
38
+ commit_in B file2 &&
39
+ git -C B repack -ad &&
40
+ git -C B prune
41
+ '
44
42
45
- cd " $base_dir "
43
+ test_expect_success ' cloning with reference (-l -s)' '
44
+ git clone -l -s --reference B A C
45
+ '
46
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
- test_cmp expected current'
47
+ test_expect_success ' existence of info/alternates' '
48
+ test_line_count = 2 C/.git/objects/info/alternates
49
+ '
52
50
53
- cd " $base_dir "
51
+ test_expect_success ' pulling from reference' '
52
+ git -C C pull ../B master
53
+ '
54
54
55
- rm -f " $U .D"
55
+ test_expect_success ' that reference gets used' '
56
+ test_objcount C 0
57
+ '
56
58
57
59
test_expect_success ' cloning with reference (no -l -s)' '
58
60
GIT_TRACE_PACKET=$U.D git clone --reference B "file://$(pwd)/A" D
@@ -63,95 +65,64 @@ test_expect_success 'fetched no objects' '
63
65
! grep " want" "$U.D"
64
66
'
65
67
66
- cd " $base_dir "
67
-
68
- test_expect_success ' existence of info/alternates' \
69
- ' test_line_count = 1 D/.git/objects/info/alternates'
70
-
71
- cd " $base_dir "
72
-
73
- test_expect_success ' pulling from reference' \
74
- ' cd D && git pull ../B master'
75
-
76
- cd " $base_dir "
77
-
78
- test_expect_success ' that reference gets used' \
79
- ' cd D && echo "0 objects, 0 kilobytes" > expected &&
80
- git count-objects > current &&
81
- test_cmp expected current'
82
-
83
- cd " $base_dir "
68
+ test_expect_success ' existence of info/alternates' '
69
+ test_line_count = 1 D/.git/objects/info/alternates
70
+ '
84
71
85
- test_expect_success ' updating origin' \
86
- ' cd A &&
87
- echo third > file3 &&
88
- git add file3 &&
89
- git commit -m update &&
90
- git repack -a -d &&
91
- git prune'
72
+ test_expect_success ' pulling from reference' '
73
+ git -C D pull ../B master
74
+ '
92
75
93
- cd " $base_dir "
76
+ test_expect_success ' that reference gets used' '
77
+ test_objcount D 0
78
+ '
94
79
95
- test_expect_success ' pulling changes from origin' \
96
- ' cd C &&
97
- git pull origin'
80
+ test_expect_success ' updating origin' '
81
+ commit_in A file3 &&
82
+ git -C A repack -ad &&
83
+ git -C A prune
84
+ '
98
85
99
- cd " $base_dir "
86
+ test_expect_success ' pulling changes from origin' '
87
+ git -C C pull origin
88
+ '
100
89
101
90
# the 2 local objects are commit and tree from the merge
102
- test_expect_success ' that alternate to origin gets used' \
103
- ' cd C &&
104
- echo "2 objects" > expected &&
105
- git count-objects | cut -d, -f1 > current &&
106
- test_cmp expected current'
107
-
108
- cd " $base_dir "
109
-
110
- test_expect_success ' pulling changes from origin' \
111
- ' cd D &&
112
- git pull origin'
91
+ test_expect_success ' that alternate to origin gets used' '
92
+ test_objcount C 2
93
+ '
113
94
114
- cd " $base_dir "
95
+ test_expect_success ' pulling changes from origin' '
96
+ git -C D pull origin
97
+ '
115
98
116
99
# the 5 local objects are expected; file3 blob, commit in A to add it
117
100
# and its tree, and 2 are our tree and the merge commit.
118
- test_expect_success ' check objects expected to exist locally' \
119
- ' cd D &&
120
- echo "5 objects" > expected &&
121
- git count-objects | cut -d, -f1 > current &&
122
- test_cmp expected current'
123
-
124
- cd " $base_dir "
125
-
126
- test_expect_success ' preparing alternate repository #1' \
127
- ' test_create_repo F && cd F &&
128
- echo first > file1 &&
129
- git add file1 &&
130
- git commit -m initial'
131
-
132
- cd " $base_dir "
133
-
134
- test_expect_success ' cloning alternate repo #2 and adding changes to repo #1' \
135
- ' git clone F G && cd F &&
136
- echo second > file2 &&
137
- git add file2 &&
138
- git commit -m addition'
139
-
140
- cd " $base_dir "
101
+ test_expect_success ' check objects expected to exist locally' '
102
+ test_objcount D 5
103
+ '
141
104
142
- test_expect_success ' cloning alternate repo #1, using #2 as reference' \
143
- ' git clone --reference G F H'
105
+ test_expect_success ' preparing alternate repository #1' '
106
+ test_create_repo F &&
107
+ commit_in F file1
108
+ '
144
109
145
- cd " $base_dir "
110
+ test_expect_success ' cloning alternate repo #2 and adding changes to repo #1' '
111
+ git clone F G &&
112
+ commit_in F file2
113
+ '
146
114
147
- test_expect_success ' cloning with reference being subset of source (-l -s)' \
148
- ' git clone -l -s --reference A B E'
115
+ test_expect_success ' cloning alternate repo #1, using #2 as reference' '
116
+ git clone --reference G F H
117
+ '
149
118
150
- cd " $base_dir "
119
+ test_expect_success ' cloning with reference being subset of source (-l -s)' '
120
+ git clone -l -s --reference A B E
121
+ '
151
122
152
123
test_expect_success ' clone with reference from a tagged repository' '
153
124
(
154
- cd A && git tag -a -m ' tagged' HEAD
125
+ cd A && git tag -a -m tagged HEAD
155
126
) &&
156
127
git clone --reference=A A I
157
128
'
@@ -168,8 +139,6 @@ test_expect_success 'prepare branched repository' '
168
139
)
169
140
'
170
141
171
- rm -f " $U .K"
172
-
173
142
test_expect_success ' fetch with incomplete alternates' '
174
143
git init K &&
175
144
echo "$base_dir/A/.git/objects" >K/.git/objects/info/alternates &&
0 commit comments