File tree Expand file tree Collapse file tree 2 files changed +62
-1
lines changed
Expand file tree Collapse file tree 2 files changed +62
-1
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,36 @@ test_expect_success 'fsck in shallow repo' '
139139 )
140140'
141141
142+ test_expect_success ' simple fetch in shallow repo' '
143+ (
144+ cd shallow &&
145+ git fetch
146+ )
147+ '
148+
149+ test_expect_success ' no changes expected' '
150+ (
151+ cd shallow &&
152+ git count-objects -v
153+ ) > count.shallow.2 &&
154+ cmp count.shallow count.shallow.2
155+ '
156+
157+ test_expect_success ' fetch same depth in shallow repo' '
158+ (
159+ cd shallow &&
160+ git fetch --depth=2
161+ )
162+ '
163+
164+ test_expect_success ' no changes expected' '
165+ (
166+ cd shallow &&
167+ git count-objects -v
168+ ) > count.shallow.3 &&
169+ cmp count.shallow count.shallow.3
170+ '
171+
142172test_expect_success ' add two more' '
143173 add B66 $B65 &&
144174 add B67 $B66
@@ -201,4 +231,21 @@ test_expect_success 'pull in shallow repo with missing merge base' '
201231 )
202232'
203233
234+ test_expect_success ' additional simple shallow deepenings' '
235+ (
236+ cd shallow &&
237+ git fetch --depth=8 &&
238+ git fetch --depth=10 &&
239+ git fetch --depth=11
240+ )
241+ '
242+
243+ test_expect_success ' clone shallow object count' '
244+ (
245+ cd shallow &&
246+ git count-objects -v
247+ ) > count.shallow &&
248+ grep "^count: 52" count.shallow
249+ '
250+
204251test_done
Original file line number Diff line number Diff line change @@ -1059,18 +1059,32 @@ const struct ref *transport_get_remote_refs(struct transport *transport)
10591059int transport_fetch_refs (struct transport * transport , const struct ref * refs )
10601060{
10611061 int rc ;
1062- int nr_heads = 0 , nr_alloc = 0 ;
1062+ int nr_heads = 0 , nr_alloc = 0 , nr_refs = 0 ;
10631063 const struct ref * * heads = NULL ;
10641064 const struct ref * rm ;
10651065
10661066 for (rm = refs ; rm ; rm = rm -> next ) {
1067+ nr_refs ++ ;
10671068 if (rm -> peer_ref &&
10681069 !hashcmp (rm -> peer_ref -> old_sha1 , rm -> old_sha1 ))
10691070 continue ;
10701071 ALLOC_GROW (heads , nr_heads + 1 , nr_alloc );
10711072 heads [nr_heads ++ ] = rm ;
10721073 }
10731074
1075+ if (!nr_heads ) {
1076+ /*
1077+ * When deepening of a shallow repository is requested,
1078+ * then local and remote refs are likely to still be equal.
1079+ * Just feed them all to the fetch method in that case.
1080+ * This condition shouldn't be met in a non-deepening fetch
1081+ * (see builtin-fetch.c:quickfetch()).
1082+ */
1083+ heads = xmalloc (nr_refs * sizeof (* heads ));
1084+ for (rm = refs ; rm ; rm = rm -> next )
1085+ heads [nr_heads ++ ] = rm ;
1086+ }
1087+
10741088 rc = transport -> fetch (transport , nr_heads , heads );
10751089 free (heads );
10761090 return rc ;
You can’t perform that action at this time.
0 commit comments