MCPcopy Index your code
hub / github.com/git/git / fill_ssh_args

Function fill_ssh_args

connect.c:1342–1388  ·  view source on GitHub ↗

Prepare a child_process for use by Git's SSH-tunneled transport. */

Source from the content-addressed store, hash-verified

1340
1341/* Prepare a child_process for use by Git's SSH-tunneled transport. */
1342static void fill_ssh_args(struct child_process *conn, const char *ssh_host,
1343 const char *port, enum protocol_version version,
1344 int flags)
1345{
1346 const char *ssh;
1347 enum ssh_variant variant;
1348
1349 if (looks_like_command_line_option(ssh_host))
1350 die(_("strange hostname '%s' blocked"), ssh_host);
1351
1352 ssh = get_ssh_command();
1353 if (ssh) {
1354 variant = determine_ssh_variant(ssh, 1);
1355 } else {
1356 /*
1357 * GIT_SSH is the no-shell version of
1358 * GIT_SSH_COMMAND (and must remain so for
1359 * historical compatibility).
1360 */
1361 conn->use_shell = 0;
1362
1363 ssh = getenv("GIT_SSH");
1364 if (!ssh)
1365 ssh = "ssh";
1366 variant = determine_ssh_variant(ssh, 0);
1367 }
1368
1369 if (variant == VARIANT_AUTO) {
1370 struct child_process detect = CHILD_PROCESS_INIT;
1371
1372 detect.use_shell = conn->use_shell;
1373 detect.no_stdin = detect.no_stdout = detect.no_stderr = 1;
1374
1375 strvec_push(&detect.args, ssh);
1376 strvec_push(&detect.args, "-G");
1377 push_ssh_options(&detect.args, &detect.env,
1378 VARIANT_SSH, port, version, flags);
1379 strvec_push(&detect.args, ssh_host);
1380
1381 variant = run_command(&detect) ? VARIANT_SIMPLE : VARIANT_SSH;
1382 }
1383
1384 strvec_push(&conn->args, ssh);
1385 push_ssh_options(&conn->args, &conn->env, variant, port, version,
1386 flags);
1387 strvec_push(&conn->args, ssh_host);
1388}
1389
1390/*
1391 * This returns the dummy child_process `no_fork` if the transport protocol

Callers 1

git_connectFunction · 0.85

Calls 7

get_ssh_commandFunction · 0.85
determine_ssh_variantFunction · 0.85
strvec_pushFunction · 0.85
push_ssh_optionsFunction · 0.85
run_commandFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected