1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#include "ssh_libssh2.h"
#include "transports/smart.h"
int git_smart_subtransport_ssh(
git_smart_subtransport **out,
git_transport *owner,
void *param)
{
#ifdef GIT_SSH
return git_smart_subtransport_ssh_libssh2(out, owner, param);
#else
GIT_UNUSED(out);
GIT_UNUSED(owner);
GIT_UNUSED(param);
git_error_set(GIT_ERROR_INVALID, "cannot create SSH transport. Library was built without SSH support");
return -1;
#endif
}
int git_transport_ssh_with_paths(
git_transport **out,
git_remote *owner,
void *payload)
{
#ifdef GIT_SSH
git_strarray *paths = (git_strarray *) payload;
git_transport *transport;
transport_smart *smart;
int error;
git_smart_subtransport_definition ssh_definition = {
git_smart_subtransport_ssh,
0, /* no RPC */
NULL,
};
if (paths->count != 2) {
git_error_set(GIT_ERROR_SSH, "invalid ssh paths, must be two strings");
return GIT_EINVALIDSPEC;
}
if ((error = git_transport_smart(&transport, owner, &ssh_definition)) < 0)
return error;
smart = (transport_smart *) transport;
if ((error = git_smart_subtransport_ssh_libssh2_set_paths(
(git_smart_subtransport *)smart->wrapped,
paths->strings[0],
paths->strings[1])) < 0)
return error;
*out = transport;
return 0;
#else
GIT_UNUSED(out);
GIT_UNUSED(owner);
GIT_UNUSED(payload);
git_error_set(GIT_ERROR_INVALID, "cannot create SSH transport. Library was built without SSH support");
return -1;
#endif
}
|