Fixed compilation issues when libssh2 is missing
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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
diff --git a/include/git2/transport.h b/include/git2/transport.h
index cc29f8b..c455e9e 100644
--- a/include/git2/transport.h
+++ b/include/git2/transport.h
@@ -11,7 +11,9 @@
#include "net.h"
#include "types.h"
+#ifdef GIT_SSH
#include <libssh2.h>
+#endif
/**
* @file git2/transport.h
@@ -47,6 +49,7 @@ typedef struct git_cred_userpass_plaintext {
char *password;
} git_cred_userpass_plaintext;
+#ifdef GIT_SSH
/* A ssh key file and passphrase */
typedef struct git_cred_ssh_keyfile_passphrase {
git_cred parent;
@@ -63,6 +66,7 @@ typedef struct git_cred_ssh_publickey {
void *sign_callback;
void *sign_data;
} git_cred_ssh_publickey;
+#endif
/**
* Creates a new plain-text username and password credential object.
@@ -78,6 +82,7 @@ GIT_EXTERN(int) git_cred_userpass_plaintext_new(
const char *username,
const char *password);
+#ifdef GIT_SSH
/**
* Creates a new ssh key file and passphrase credential object.
* The supplied credential parameter will be internally duplicated.
@@ -111,6 +116,7 @@ GIT_EXTERN(int) git_cred_ssh_publickey_new(
size_t publickey_len,
LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC((*sign_callback)),
void *sign_data);
+#endif
/**
* Signature of a function which acquires a credential object.
diff --git a/src/transport.c b/src/transport.c
index 6a8e67d..37c244c 100644
--- a/src/transport.c
+++ b/src/transport.c
@@ -20,20 +20,25 @@ typedef struct transport_definition {
static git_smart_subtransport_definition http_subtransport_definition = { git_smart_subtransport_http, 1 };
static git_smart_subtransport_definition git_subtransport_definition = { git_smart_subtransport_git, 0 };
+#ifdef GIT_SSH
static git_smart_subtransport_definition ssh_subtransport_definition = { git_smart_subtransport_ssh, 0 };
+#endif
static transport_definition local_transport_definition = { "file://", 1, git_transport_local, NULL };
-#ifdef GIT_WIN32
+#ifdef GIT_SSH
+static transport_definition ssh_transport_definition = { "ssh://", 1, git_transport_smart, &ssh_subtransport_definition };
+#else
static transport_definition dummy_transport_definition = { NULL, 1, git_transport_dummy, NULL };
#endif
-static transport_definition ssh_transport_definition = { "ssh://", 1, git_transport_smart, &ssh_subtransport_definition };
static transport_definition transports[] = {
{"git://", 1, git_transport_smart, &git_subtransport_definition},
{"http://", 1, git_transport_smart, &http_subtransport_definition},
{"https://", 1, git_transport_smart, &http_subtransport_definition},
{"file://", 1, git_transport_local, NULL},
+#ifdef GIT_SSH
{"ssh://", 1, git_transport_smart, &ssh_subtransport_definition},
+#endif
{NULL, 0, 0}
};
@@ -76,7 +81,11 @@ static int transport_find_fn(const char *url, git_transport_cb *callback, void *
/* It could be a SSH remote path. Check to see if there's a :
* SSH is an unsupported transport mechanism in this version of libgit2 */
if (!definition && strrchr(url, ':'))
+#ifdef GIT_SSH
definition = &ssh_transport_definition;
+#else
+ definition = &dummy_transport_definition;
+#endif
/* Check to see if the path points to a file on the local file system */
if (!definition && git_path_exists(url) && git_path_isdir(url))
diff --git a/src/transports/cred.c b/src/transports/cred.c
index 5d5e745..e4d205e 100644
--- a/src/transports/cred.c
+++ b/src/transports/cred.c
@@ -59,6 +59,7 @@ int git_cred_userpass_plaintext_new(
return 0;
}
+#ifdef GIT_SSH
static void ssh_keyfile_passphrase_free(struct git_cred *cred)
{
git_cred_ssh_keyfile_passphrase *c = (git_cred_ssh_keyfile_passphrase *)cred;
@@ -184,3 +185,4 @@ int git_cred_ssh_publickey_new(
*cred = &c->parent;
return 0;
}
+#endif
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index a1df6c4..167df03 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -5,6 +5,8 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
+#ifdef GIT_SSH
+
#include "git2.h"
#include "buffer.h"
#include "netops.h"
@@ -520,3 +522,5 @@ int git_smart_subtransport_ssh(git_smart_subtransport **out, git_transport *owne
*out = (git_smart_subtransport *) t;
return 0;
}
+
+#endif