Skip to content

Commit 9e471b6

Browse files
calvin-wan-googlegitster
authored andcommitted
fetch-pack: move fetch initialization
There are some variables initialized at the start of the do_fetch_pack_v2() state machine. Currently, they are initialized in FETCH_CHECK_LOCAL, which is the initial state set at the beginning of the function. However, a subsequent patch will allow for another initial state, while still requiring these initialized variables. Move the initialization to be before the state machine, so that they are set regardless of the initial state. Note that there is no change in behavior, because we're moving code from the beginning of the first state to just before the execution of the state machine. Helped-by: Jonathan Tan <[email protected]> Helped-by: Christian Couder <[email protected]> Signed-off-by: Calvin Wan <[email protected]> Signed-off-by: Eric Ju <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4278fbd commit 9e471b6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

fetch-pack.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,18 +1650,18 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
16501650
reader.me = "fetch-pack";
16511651
}
16521652

1653+
/* v2 supports these by default */
1654+
allow_unadvertised_object_request |= ALLOW_REACHABLE_SHA1;
1655+
use_sideband = 2;
1656+
if (args->depth > 0 || args->deepen_since || args->deepen_not)
1657+
args->deepen = 1;
1658+
16531659
while (state != FETCH_DONE) {
16541660
switch (state) {
16551661
case FETCH_CHECK_LOCAL:
16561662
sort_ref_list(&ref, ref_compare_name);
16571663
QSORT(sought, nr_sought, cmp_ref_by_name);
16581664

1659-
/* v2 supports these by default */
1660-
allow_unadvertised_object_request |= ALLOW_REACHABLE_SHA1;
1661-
use_sideband = 2;
1662-
if (args->depth > 0 || args->deepen_since || args->deepen_not)
1663-
args->deepen = 1;
1664-
16651665
/* Filter 'ref' by 'sought' and those that aren't local */
16661666
mark_complete_and_common_ref(negotiator, args, &ref);
16671667
filter_refs(args, &ref, sought, nr_sought);

0 commit comments

Comments
 (0)