@@ -1035,6 +1035,7 @@ static enum ssh_variant determine_ssh_variant(const char *ssh_command,
1035
1035
*/
1036
1036
static struct child_process * git_connect_git (int fd [2 ], char * hostandport ,
1037
1037
const char * path , const char * prog ,
1038
+ enum protocol_version version ,
1038
1039
int flags )
1039
1040
{
1040
1041
struct child_process * conn ;
@@ -1073,10 +1074,10 @@ static struct child_process *git_connect_git(int fd[2], char *hostandport,
1073
1074
target_host , 0 );
1074
1075
1075
1076
/* If using a new version put that stuff here after a second null byte */
1076
- if (get_protocol_version_config () > 0 ) {
1077
+ if (version > 0 ) {
1077
1078
strbuf_addch (& request , '\0' );
1078
1079
strbuf_addf (& request , "version=%d%c" ,
1079
- get_protocol_version_config () , '\0' );
1080
+ version , '\0' );
1080
1081
}
1081
1082
1082
1083
packet_write (fd [1 ], request .buf , request .len );
@@ -1092,14 +1093,14 @@ static struct child_process *git_connect_git(int fd[2], char *hostandport,
1092
1093
*/
1093
1094
static void push_ssh_options (struct argv_array * args , struct argv_array * env ,
1094
1095
enum ssh_variant variant , const char * port ,
1095
- int flags )
1096
+ enum protocol_version version , int flags )
1096
1097
{
1097
1098
if (variant == VARIANT_SSH &&
1098
- get_protocol_version_config () > 0 ) {
1099
+ version > 0 ) {
1099
1100
argv_array_push (args , "-o" );
1100
1101
argv_array_push (args , "SendEnv=" GIT_PROTOCOL_ENVIRONMENT );
1101
1102
argv_array_pushf (env , GIT_PROTOCOL_ENVIRONMENT "=version=%d" ,
1102
- get_protocol_version_config () );
1103
+ version );
1103
1104
}
1104
1105
1105
1106
if (flags & CONNECT_IPV4 ) {
@@ -1152,7 +1153,8 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env,
1152
1153
1153
1154
/* Prepare a child_process for use by Git's SSH-tunneled transport. */
1154
1155
static void fill_ssh_args (struct child_process * conn , const char * ssh_host ,
1155
- const char * port , int flags )
1156
+ const char * port , enum protocol_version version ,
1157
+ int flags )
1156
1158
{
1157
1159
const char * ssh ;
1158
1160
enum ssh_variant variant ;
@@ -1186,14 +1188,14 @@ static void fill_ssh_args(struct child_process *conn, const char *ssh_host,
1186
1188
argv_array_push (& detect .args , ssh );
1187
1189
argv_array_push (& detect .args , "-G" );
1188
1190
push_ssh_options (& detect .args , & detect .env_array ,
1189
- VARIANT_SSH , port , flags );
1191
+ VARIANT_SSH , port , version , flags );
1190
1192
argv_array_push (& detect .args , ssh_host );
1191
1193
1192
1194
variant = run_command (& detect ) ? VARIANT_SIMPLE : VARIANT_SSH ;
1193
1195
}
1194
1196
1195
1197
argv_array_push (& conn -> args , ssh );
1196
- push_ssh_options (& conn -> args , & conn -> env_array , variant , port , flags );
1198
+ push_ssh_options (& conn -> args , & conn -> env_array , variant , port , version , flags );
1197
1199
argv_array_push (& conn -> args , ssh_host );
1198
1200
}
1199
1201
@@ -1214,6 +1216,7 @@ struct child_process *git_connect(int fd[2], const char *url,
1214
1216
char * hostandport , * path ;
1215
1217
struct child_process * conn ;
1216
1218
enum protocol protocol ;
1219
+ enum protocol_version version = get_protocol_version_config ();
1217
1220
1218
1221
/* Without this we cannot rely on waitpid() to tell
1219
1222
* what happened to our children.
@@ -1228,7 +1231,7 @@ struct child_process *git_connect(int fd[2], const char *url,
1228
1231
printf ("Diag: path=%s\n" , path ? path : "NULL" );
1229
1232
conn = NULL ;
1230
1233
} else if (protocol == PROTO_GIT ) {
1231
- conn = git_connect_git (fd , hostandport , path , prog , flags );
1234
+ conn = git_connect_git (fd , hostandport , path , prog , version , flags );
1232
1235
} else {
1233
1236
struct strbuf cmd = STRBUF_INIT ;
1234
1237
const char * const * var ;
@@ -1271,12 +1274,12 @@ struct child_process *git_connect(int fd[2], const char *url,
1271
1274
strbuf_release (& cmd );
1272
1275
return NULL ;
1273
1276
}
1274
- fill_ssh_args (conn , ssh_host , port , flags );
1277
+ fill_ssh_args (conn , ssh_host , port , version , flags );
1275
1278
} else {
1276
1279
transport_check_allowed ("file" );
1277
- if (get_protocol_version_config () > 0 ) {
1280
+ if (version > 0 ) {
1278
1281
argv_array_pushf (& conn -> env_array , GIT_PROTOCOL_ENVIRONMENT "=version=%d" ,
1279
- get_protocol_version_config () );
1282
+ version );
1280
1283
}
1281
1284
}
1282
1285
argv_array_push (& conn -> args , cmd .buf );
0 commit comments