Skip to content

Commit 290e147

Browse files
committed
Add GIT_CAP_SSH if library was built with SSH
This also adds a test that actually calls git_libgit2_capabilities and git_libgit2_version.
1 parent a445692 commit 290e147

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

include/git2/common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev);
105105
*/
106106
typedef enum {
107107
GIT_CAP_THREADS = ( 1 << 0 ),
108-
GIT_CAP_HTTPS = ( 1 << 1 )
108+
GIT_CAP_HTTPS = ( 1 << 1 ),
109+
GIT_CAP_SSH = ( 1 << 2 ),
109110
} git_cap_t;
110111

111112
/**

src/util.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ int git_libgit2_capabilities()
3232
#endif
3333
#if defined(GIT_SSL) || defined(GIT_WINHTTP)
3434
| GIT_CAP_HTTPS
35+
#endif
36+
#if defined(GIT_SSH)
37+
| GIT_CAP_SSH
3538
#endif
3639
;
3740
}

tests-clar/core/caps.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "clar_libgit2.h"
2+
3+
void test_core_caps__0(void)
4+
{
5+
int major, minor, rev, caps;
6+
7+
git_libgit2_version(&major, &minor, &rev);
8+
cl_assert_equal_i(LIBGIT2_VER_MAJOR, major);
9+
cl_assert_equal_i(LIBGIT2_VER_MINOR, minor);
10+
cl_assert_equal_i(LIBGIT2_VER_REVISION, rev);
11+
12+
caps = git_libgit2_capabilities();
13+
14+
#ifdef GIT_THREADS
15+
cl_assert((caps & GIT_CAP_THREADS) != 0);
16+
#else
17+
cl_assert((caps & GIT_CAP_THREADS) == 0);
18+
#endif
19+
20+
#if defined(GIT_SSL) || defined(GIT_WINHTTP)
21+
cl_assert((caps & GIT_CAP_HTTPS) != 0);
22+
#else
23+
cl_assert((caps & GIT_CAP_HTTPS) == 0);
24+
#endif
25+
26+
#if defined(GIT_SSH)
27+
cl_assert((caps & GIT_CAP_SSH) != 0);
28+
#else
29+
cl_assert((caps & GIT_CAP_SSH) == 0);
30+
#endif
31+
}

0 commit comments

Comments
 (0)