Skip to content

Commit 176cd68

Browse files
jiangxingitster
authored andcommitted
transport-helper: call do_take_over() in process_connect
The existing pattern among all callers of process_connect() seems to be if (process_connect(...)) { do_take_over(); ... dispatch to the underlying method ... } ... otherwise implement the fallback ... where the return value from process_connect() is the return value of the call it makes to process_connect_service(). Move the call of do_take_over() inside process_connect(), so that calling the process_connect() function is more concise and will not miss do_take_over(). Suggested-by: Junio C Hamano <[email protected]> Signed-off-by: Jiang Xin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 35d26e7 commit 176cd68

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

transport-helper.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -646,14 +646,18 @@ static int process_connect(struct transport *transport,
646646
struct helper_data *data = transport->data;
647647
const char *name;
648648
const char *exec;
649+
int ret;
649650

650651
name = for_push ? "git-receive-pack" : "git-upload-pack";
651652
if (for_push)
652653
exec = data->transport_options.receivepack;
653654
else
654655
exec = data->transport_options.uploadpack;
655656

656-
return process_connect_service(transport, name, exec);
657+
ret = process_connect_service(transport, name, exec);
658+
if (ret)
659+
do_take_over(transport);
660+
return ret;
657661
}
658662

659663
static int connect_helper(struct transport *transport, const char *name,
@@ -685,10 +689,8 @@ static int fetch_refs(struct transport *transport,
685689

686690
get_helper(transport);
687691

688-
if (process_connect(transport, 0)) {
689-
do_take_over(transport);
692+
if (process_connect(transport, 0))
690693
return transport->vtable->fetch_refs(transport, nr_heads, to_fetch);
691-
}
692694

693695
/*
694696
* If we reach here, then the server, the client, and/or the transport
@@ -1145,10 +1147,8 @@ static int push_refs(struct transport *transport,
11451147
{
11461148
struct helper_data *data = transport->data;
11471149

1148-
if (process_connect(transport, 1)) {
1149-
do_take_over(transport);
1150+
if (process_connect(transport, 1))
11501151
return transport->vtable->push_refs(transport, remote_refs, flags);
1151-
}
11521152

11531153
if (!remote_refs) {
11541154
fprintf(stderr,
@@ -1189,11 +1189,9 @@ static struct ref *get_refs_list(struct transport *transport, int for_push,
11891189
{
11901190
get_helper(transport);
11911191

1192-
if (process_connect(transport, for_push)) {
1193-
do_take_over(transport);
1192+
if (process_connect(transport, for_push))
11941193
return transport->vtable->get_refs_list(transport, for_push,
11951194
transport_options);
1196-
}
11971195

11981196
return get_refs_list_using_list(transport, for_push);
11991197
}
@@ -1277,10 +1275,8 @@ static int get_bundle_uri(struct transport *transport)
12771275
{
12781276
get_helper(transport);
12791277

1280-
if (process_connect(transport, 0)) {
1281-
do_take_over(transport);
1278+
if (process_connect(transport, 0))
12821279
return transport->vtable->get_bundle_uri(transport);
1283-
}
12841280

12851281
return -1;
12861282
}

0 commit comments

Comments
 (0)