1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Handle "-p port" flag in ssh-connect

Summary:
The documentation is explicit that Git does not pass this flag:

  The $GIT_SSH command will be given exactly two arguments: the username@host (or just host) from the URL and the shell command to execute on that remote system.

This isn't true; it does. Accommodate it.

I'll see if I can fix this in the upstream, too.

Test Plan: Ran various `ssh-connect` commands with -p, etc.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D7680
This commit is contained in:
epriestley 2013-12-02 11:25:46 -08:00
parent e19ad8ab8a
commit d59722321f

View file

@ -7,6 +7,20 @@
$root = dirname(dirname(dirname(__FILE__))); $root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php'; require_once $root.'/scripts/__init_script__.php';
// Contrary to the documentation, Git may pass a "-p" flag. If it does, respect
// it and move it before the "--" argument.
$args = new PhutilArgumentParser($argv);
$args->parsePartial(
array(
array(
'name' => 'port',
'short' => 'p',
'param' => pht('port'),
'help' => pht('Port number to connect to.'),
),
));
$unconsumed_argv = $args->getUnconsumedArgumentVector();
$pattern = array(); $pattern = array();
$arguments = array(); $arguments = array();
@ -31,9 +45,15 @@ if ($credential_phid) {
$arguments[] = $key->getKeyfileEnvelope(); $arguments[] = $key->getKeyfileEnvelope();
} }
$port = $args->getArg('port');
if ($port) {
$pattern[] = '-p %d';
$arguments[] = $port;
}
$pattern[] = '--'; $pattern[] = '--';
$passthru_args = array_slice($argv, 1); $passthru_args = $unconsumed_argv;
foreach ($passthru_args as $passthru_arg) { foreach ($passthru_args as $passthru_arg) {
$pattern[] = '%s'; $pattern[] = '%s';
$arguments[] = $passthru_arg; $arguments[] = $passthru_arg;