summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--cmake/SelectSSH.cmake31
-rw-r--r--src/libgit2/libgit2.c2
-rw-r--r--src/libgit2/transport.c3
-rw-r--r--src/libgit2/transports/credential.c2
-rw-r--r--src/libgit2/transports/ssh.c4
-rw-r--r--src/libgit2/transports/ssh_libssh2.c6
-rw-r--r--src/util/git2_features.h.in3
8 files changed, 28 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cfb5a7d6f..bcd3af75c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,7 +30,7 @@ option(USE_THREADS "Use threads for parallel processing when possibl
option(USE_NSEC "Support nanosecond precision file mtimes and ctimes" ON)
# Backend selection
-option(USE_SSH "Link with libssh2 to enable SSH support" OFF)
+option(USE_SSH "Enable SSH support. Can be set to a specific backend" OFF)
option(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON)
option(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS" ON)
option(USE_SHA256 "Enable SHA256. Can be set to HTTPS/Builtin" ON)
diff --git a/cmake/SelectSSH.cmake b/cmake/SelectSSH.cmake
index 23dfc9785..684116200 100644
--- a/cmake/SelectSSH.cmake
+++ b/cmake/SelectSSH.cmake
@@ -1,5 +1,5 @@
-# Optional external dependency: libssh2
-if(USE_SSH)
+# find libssh2
+if(USE_SSH STREQUAL ON OR USE_SSH STREQUAL "libssh2")
find_pkglibraries(LIBSSH2 libssh2)
if(NOT LIBSSH2_FOUND)
find_package(LibSSH2)
@@ -12,30 +12,29 @@ if(USE_SSH)
if(NOT LIBSSH2_FOUND)
message(FATAL_ERROR "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
endif()
-endif()
-if(LIBSSH2_FOUND)
- set(GIT_SSH 1)
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
list(APPEND LIBGIT2_SYSTEM_LIBS ${LIBSSH2_LIBRARIES})
list(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
check_library_exists("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
if(HAVE_LIBSSH2_MEMORY_CREDENTIALS)
- set(GIT_SSH_MEMORY_CREDENTIALS 1)
+ set(GIT_SSH_LIBSSH2_MEMORY_CREDENTIALS 1)
endif()
-else()
- message(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
-endif()
-if(WIN32 AND EMBED_SSH_PATH)
- file(GLOB SSH_SRC "${EMBED_SSH_PATH}/src/*.c")
- list(SORT SSH_SRC)
- list(APPEND LIBGIT2_DEPENDENCY_OBJECTS ${SSH_SRC})
+ if(WIN32 AND EMBED_SSH_PATH)
+ file(GLOB SSH_SRC "${EMBED_SSH_PATH}/src/*.c")
+ list(SORT SSH_SRC)
+ list(APPEND LIBGIT2_DEPENDENCY_OBJECTS ${SSH_SRC})
+
+ list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${EMBED_SSH_PATH}/include")
+ file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
+ endif()
- list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${EMBED_SSH_PATH}/include")
- file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
set(GIT_SSH 1)
+ set(GIT_SSH_LIBSSH2 1)
+ add_feature_info(SSH ON "using libssh2")
+else()
+ add_feature_info(SSH OFF "SSH transport support")
endif()
-add_feature_info(SSH GIT_SSH "SSH transport support")
diff --git a/src/libgit2/libgit2.c b/src/libgit2/libgit2.c
index 56b90321f..6f0925fa6 100644
--- a/src/libgit2/libgit2.c
+++ b/src/libgit2/libgit2.c
@@ -126,7 +126,7 @@ int git_libgit2_features(void)
#ifdef GIT_HTTPS
| GIT_FEATURE_HTTPS
#endif
-#if defined(GIT_SSH)
+#if defined(GIT_SSH_LIBSSH2)
| GIT_FEATURE_SSH
#endif
#if defined(GIT_USE_NSEC)
diff --git a/src/libgit2/transport.c b/src/libgit2/transport.c
index 640ccacae..c61d0a68b 100644
--- a/src/libgit2/transport.c
+++ b/src/libgit2/transport.c
@@ -22,6 +22,7 @@ typedef struct transport_definition {
static git_smart_subtransport_definition http_subtransport_definition = { git_smart_subtransport_http, 1, NULL };
static git_smart_subtransport_definition git_subtransport_definition = { git_smart_subtransport_git, 0, NULL };
+
#ifdef GIT_SSH
static git_smart_subtransport_definition ssh_subtransport_definition = { git_smart_subtransport_ssh, 0, NULL };
#endif
@@ -33,11 +34,13 @@ static transport_definition transports[] = {
{ "http://", git_transport_smart, &http_subtransport_definition },
{ "https://", git_transport_smart, &http_subtransport_definition },
{ "file://", git_transport_local, NULL },
+
#ifdef GIT_SSH
{ "ssh://", git_transport_smart, &ssh_subtransport_definition },
{ "ssh+git://", git_transport_smart, &ssh_subtransport_definition },
{ "git+ssh://", git_transport_smart, &ssh_subtransport_definition },
#endif
+
{ NULL, 0, 0 }
};
diff --git a/src/libgit2/transports/credential.c b/src/libgit2/transports/credential.c
index 6e00b0282..b47bd63a1 100644
--- a/src/libgit2/transports/credential.c
+++ b/src/libgit2/transports/credential.c
@@ -204,7 +204,7 @@ int git_credential_ssh_key_memory_new(
const char *privatekey,
const char *passphrase)
{
-#ifdef GIT_SSH_MEMORY_CREDENTIALS
+#ifdef GIT_SSH_LIBSSH2_MEMORY_CREDENTIALS
return git_credential_ssh_key_type_new(
cred,
username,
diff --git a/src/libgit2/transports/ssh.c b/src/libgit2/transports/ssh.c
index bef0b1440..7171e9cb3 100644
--- a/src/libgit2/transports/ssh.c
+++ b/src/libgit2/transports/ssh.c
@@ -14,7 +14,7 @@ int git_smart_subtransport_ssh(
git_transport *owner,
void *param)
{
-#ifdef GIT_SSH
+#ifdef GIT_SSH_LIBSSH2
return git_smart_subtransport_ssh_libssh2(out, owner, param);
#else
GIT_UNUSED(out);
@@ -31,7 +31,7 @@ int git_transport_ssh_with_paths(
git_remote *owner,
void *payload)
{
-#ifdef GIT_SSH
+#ifdef GIT_SSH_LIBSSH2
git_strarray *paths = (git_strarray *) payload;
git_transport *transport;
transport_smart *smart;
diff --git a/src/libgit2/transports/ssh_libssh2.c b/src/libgit2/transports/ssh_libssh2.c
index 78deac24a..8a9ca31fc 100644
--- a/src/libgit2/transports/ssh_libssh2.c
+++ b/src/libgit2/transports/ssh_libssh2.c
@@ -7,7 +7,7 @@
#include "ssh_libssh2.h"
-#ifdef GIT_SSH
+#ifdef GIT_SSH_LIBSSH2
#include <libssh2.h>
@@ -342,7 +342,7 @@ static int _git_ssh_authenticate_session(
session, c->username, c->prompt_callback);
break;
}
-#ifdef GIT_SSH_MEMORY_CREDENTIALS
+#ifdef GIT_SSH_LIBSSH2_MEMORY_CREDENTIALS
case GIT_CREDENTIAL_SSH_MEMORY: {
git_credential_ssh_key *c = (git_credential_ssh_key *)cred;
@@ -1019,7 +1019,7 @@ static int list_auth_methods(int *out, LIBSSH2_SESSION *session, const char *use
if (!git__prefixcmp(ptr, SSH_AUTH_PUBLICKEY)) {
*out |= GIT_CREDENTIAL_SSH_KEY;
*out |= GIT_CREDENTIAL_SSH_CUSTOM;
-#ifdef GIT_SSH_MEMORY_CREDENTIALS
+#ifdef GIT_SSH_LIBSSH2_MEMORY_CREDENTIALS
*out |= GIT_CREDENTIAL_SSH_MEMORY;
#endif
ptr += strlen(SSH_AUTH_PUBLICKEY);
diff --git a/src/util/git2_features.h.in b/src/util/git2_features.h.in
index a84ea8956..21399116d 100644
--- a/src/util/git2_features.h.in
+++ b/src/util/git2_features.h.in
@@ -30,7 +30,8 @@
#cmakedefine GIT_QSORT_MSC
#cmakedefine GIT_SSH 1
-#cmakedefine GIT_SSH_MEMORY_CREDENTIALS 1
+#cmakedefine GIT_SSH_LIBSSH2 1
+#cmakedefine GIT_SSH_LIBSSH2_MEMORY_CREDENTIALS 1
#cmakedefine GIT_NTLM 1
#cmakedefine GIT_GSSAPI 1