Skip to content

Commit 686aafa

Browse files
committed
Report regex engine in libgit2_config()
1 parent 5d82b97 commit 686aafa

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ git_strarray *files_to_array(SEXP files);
2323

2424
#define build_tibble(...) list_to_tibble(build_list( __VA_ARGS__))
2525

26-
#define AT_LEAST_LIBGIT2(x,y) (LIBGIT2_VER_MAJOR > x || LIBGIT2_VER_MINOR >= y)
26+
#define AT_LEAST_LIBGIT2(x,y) (LIBGIT2_VER_MAJOR > x || (LIBGIT2_VER_MAJOR >= x && LIBGIT2_VER_MINOR >= y))
2727

2828
/* Workaround for API change in 1.8.0 and 1.8.1 only: https://github.com/libgit2/libgit2/issues/6793 */
2929
#if LIBGIT2_VER_MAJOR == 1 && LIBGIT2_VER_MINOR == 8 && LIBGIT2_VER_REVISION < 2

src/version.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ SEXP R_libgit2_config(void){
2525
SEXP ssh = PROTECT(Rf_ScalarLogical(features & GIT_FEATURE_SSH));
2626
SEXP https = PROTECT(Rf_ScalarLogical(features & GIT_FEATURE_HTTPS));
2727
SEXP threads = PROTECT(Rf_ScalarLogical(features & GIT_FEATURE_THREADS));
28+
const char* c_regex_backend;
29+
#if AT_LEAST_LIBGIT2(1, 9)
30+
c_regex_backend = git_libgit2_feature_backend(GIT_FEATURE_REGEX);
31+
#else
32+
c_regex_backend = "unknown";
33+
#endif
34+
SEXP regex_backend = PROTECT(safe_string(c_regex_backend));
2835
git_buf buf = {0};
2936
git_config_find_global(&buf);
3037
SEXP config_global = PROTECT(safe_string(buf.ptr));
@@ -35,9 +42,10 @@ SEXP R_libgit2_config(void){
3542
git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, &buf);
3643
SEXP config_search_path = PROTECT(safe_string(buf.ptr));
3744
git_buf_free(&buf);
38-
SEXP out = build_list(7, "version", version, "ssh", ssh, "https", https, "threads", threads,
45+
SEXP out = build_list(8, "version", version, "ssh", ssh, "https", https, "threads", threads,
46+
"regex_backend", regex_backend,
3947
"config.global", config_global, "config.system", config_system,
4048
"config.home", config_search_path);
41-
UNPROTECT(7);
49+
UNPROTECT(8);
4250
return out;
4351
}

0 commit comments

Comments
 (0)