Skip to content

Commit

Permalink
Drop usage of names prior to libgit2 v0.99.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stewid committed Oct 5, 2024
1 parent e274f68 commit ce1a10d
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 81 deletions.
26 changes: 0 additions & 26 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2300,32 +2300,6 @@ if test "x${have_sys_subfolder}" = xyes; then
PKG_CFLAGS="${PKG_CFLAGS} -DGIT2R_HAVE_SYS_SUBFOLDER"
fi

# libgit v0.99.0: Several structures, enums and values have been
# renamed in libgit version 0.99.0. The former names are
# deprecated. See
# https://github.com/libgit2/libgit2/releases/tag/v0.99.0
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the libgit2 function git_oid_is_zero is available" >&5
printf %s "checking whether the libgit2 function git_oid_is_zero is available... " >&6; }
have_git_oid_is_zero=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <git2.h>
int
main (void)
{
git_oid_is_zero(NULL);
;
return 0;
}
_ACEOF
PKG_CFLAGS="${PKG_CFLAGS} -Werror" "$RBIN" CMD SHLIB conftest.c \
1>&5 2>&5 && have_git_oid_is_zero=yes
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${have_git_oid_is_zero}" >&5
printf "%s\n" "${have_git_oid_is_zero}" >&6; }
if test "x${have_git_oid_is_zero}" = xyes; then
PKG_CFLAGS="${PKG_CFLAGS} -DGIT2R_LIBGIT2_V0_99_0_RENAMES"
fi

# libgit v1.8.0 requires code changes around functions taking
# git_commit. See
# https://github.com/libgit2/libgit2/issues/6793
Expand Down
16 changes: 0 additions & 16 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,6 @@ if test "x${have_sys_subfolder}" = xyes; then
PKG_CFLAGS="${PKG_CFLAGS} -DGIT2R_HAVE_SYS_SUBFOLDER"
fi

# libgit v0.99.0: Several structures, enums and values have been
# renamed in libgit version 0.99.0. The former names are
# deprecated. See
# https://github.com/libgit2/libgit2/releases/tag/v0.99.0
AC_MSG_CHECKING([whether the libgit2 function git_oid_is_zero is available])
have_git_oid_is_zero=no
AC_LANG_CONFTEST([AC_LANG_PROGRAM(
[[#include <git2.h>]],
[[git_oid_is_zero(NULL);]])])
PKG_CFLAGS="${PKG_CFLAGS} -Werror" "$RBIN" CMD SHLIB conftest.c \
1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD && have_git_oid_is_zero=yes
AC_MSG_RESULT([${have_git_oid_is_zero}])
if test "x${have_git_oid_is_zero}" = xyes; then
PKG_CFLAGS="${PKG_CFLAGS} -DGIT2R_LIBGIT2_V0_99_0_RENAMES"
fi

# libgit v1.8.0 requires code changes around functions taking
# git_commit. See
# https://github.com/libgit2/libgit2/issues/6793
Expand Down
7 changes: 2 additions & 5 deletions src/Makevars.win
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@

PKG_CPPFLAGS = \
-DR_NO_REMAP -DSTRICT_R_HEADERS \
-DGIT2R_HAVE_OBJECT_ANY \
-DGIT2R_LIBGIT2_V0_99_0_RENAMES
PKG_CPPFLAGS = -DR_NO_REMAP -DSTRICT_R_HEADERS

PKG_LIBS = \
-lgit2 -lpcre -lssh2 -lz -lssl -lcrypto -lgcrypt -lgpg-error \
-lwinhttp -lws2_32 -lcrypt32 -lole32 -lrpcrt4

all: clean

clean:
Expand Down
34 changes: 17 additions & 17 deletions src/git2r_cred.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* git2r, R bindings to the libgit2 library.
* Copyright (C) 2013-2020 The git2r contributors
* Copyright (C) 2013-2024 The git2r contributors
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2,
Expand Down Expand Up @@ -84,12 +84,12 @@ git2r_getenv(
*/
static int
git2r_cred_ssh_key(
GIT2R_CREDENTIAL **cred,
git_credential **cred,
const char *username_from_url,
unsigned int allowed_types,
SEXP credentials)
{
if (GIT2R_CREDENTIAL_SSH_KEY & allowed_types) {
if (GIT_CREDENTIAL_SSH_KEY & allowed_types) {
SEXP elem;
const char *publickey;
const char *privatekey = NULL;
Expand All @@ -102,7 +102,7 @@ git2r_cred_ssh_key(
if (Rf_length(elem) && (NA_STRING != STRING_ELT(elem, 0)))
passphrase = CHAR(STRING_ELT(elem, 0));

if (GIT2R_CREDENTIAL_SSH_KEY_NEW(
if (git_credential_ssh_key_new(
cred, username_from_url, publickey, privatekey, passphrase))
return -1;

Expand All @@ -122,11 +122,11 @@ git2r_cred_ssh_key(
*/
static int
git2r_cred_env(
GIT2R_CREDENTIAL **cred,
git_credential **cred,
unsigned int allowed_types,
SEXP credentials)
{
if (GIT2R_CREDENTIAL_USERPASS_PLAINTEXT & allowed_types) {
if (GIT_CREDENTIAL_USERPASS_PLAINTEXT & allowed_types) {
int error;
char *username = NULL;
char *password = NULL;
Expand All @@ -141,7 +141,7 @@ git2r_cred_env(
if (error)
goto cleanup;

error = GIT2R_CREDENTIAL_USERPASS_PLAINTEXT_NEW(
error = git_credential_userpass_plaintext_new(
cred, username, password);

cleanup:
Expand All @@ -167,11 +167,11 @@ git2r_cred_env(
*/
static int
git2r_cred_token(
GIT2R_CREDENTIAL **cred,
git_credential **cred,
unsigned int allowed_types,
SEXP credentials)
{
if (GIT2R_CREDENTIAL_USERPASS_PLAINTEXT & allowed_types) {
if (GIT_CREDENTIAL_USERPASS_PLAINTEXT & allowed_types) {
int error;
char *token = NULL;

Expand All @@ -181,7 +181,7 @@ git2r_cred_token(
if (error)
goto cleanup;

error = GIT2R_CREDENTIAL_USERPASS_PLAINTEXT_NEW(cred, " ", token);
error = git_credential_userpass_plaintext_new(cred, " ", token);

cleanup:
free(token);
Expand All @@ -205,17 +205,17 @@ git2r_cred_token(
*/
static int
git2r_cred_user_pass(
GIT2R_CREDENTIAL **cred,
git_credential **cred,
unsigned int allowed_types,
SEXP credentials)
{
if (GIT2R_CREDENTIAL_USERPASS_PLAINTEXT & allowed_types) {
if (GIT_CREDENTIAL_USERPASS_PLAINTEXT & allowed_types) {
const char *username;
const char *password;

username = CHAR(STRING_ELT(git2r_get_list_element(credentials, "username"), 0));
password = CHAR(STRING_ELT(git2r_get_list_element(credentials, "password"), 0));
if (GIT2R_CREDENTIAL_USERPASS_PLAINTEXT_NEW(cred, username, password))
if (git_credential_userpass_plaintext_new(cred, username, password))
return -1;

return 0;
Expand Down Expand Up @@ -357,7 +357,7 @@ git2r_cred_user_pass(
/* } */

/* static int git2r_cred_default_ssh_key( */
/* GIT2R_CREDENTIAL **cred, */
/* git_credential **cred, */
/* const char *username_from_url) */
/* { */
/* #ifdef WIN32 */
Expand Down Expand Up @@ -442,7 +442,7 @@ git2r_cred_user_pass(
*/
int attribute_hidden
git2r_cred_acquire_cb(
GIT2R_CREDENTIAL **cred,
git_credential **cred,
const char *url,
const char *username_from_url,
unsigned int allowed_types,
Expand All @@ -459,11 +459,11 @@ git2r_cred_acquire_cb(
td = (git2r_transfer_data*)payload;
credentials = td->credentials;
if (Rf_isNull(credentials)) {
if (GIT2R_CREDENTIAL_SSH_KEY & allowed_types) {
if (GIT_CREDENTIAL_SSH_KEY & allowed_types) {
if (td->use_ssh_agent) {
/* Try to get credentials from the ssh-agent. */
td->use_ssh_agent = 0;
if (GIT2R_CREDENTIAL_SSH_KEY_FROM_AGENT(cred, username_from_url) == 0)
if (git_credential_ssh_key_from_agent(cred, username_from_url) == 0)
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions src/git2r_cred.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* git2r, R bindings to the libgit2 library.
* Copyright (C) 2013-2020 The git2r contributors
* Copyright (C) 2013-2024 The git2r contributors
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2,
Expand All @@ -23,7 +23,7 @@
#include "git2r_deprecated.h"

int git2r_cred_acquire_cb(
GIT2R_CREDENTIAL **out,
git_credential **out,
const char *url,
const char *username_from_url,
unsigned int allowed_types,
Expand Down
14 changes: 0 additions & 14 deletions src/git2r_deprecated.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,11 @@
#define INCLUDE_git2r_deprecated_h

#if defined(GIT2R_LIBGIT2_V0_99_0_RENAMES)
# define GIT2R_CREDENTIAL git_credential
# define GIT2R_CREDENTIAL_SSH_KEY GIT_CREDENTIAL_SSH_KEY
# define GIT2R_CREDENTIAL_SSH_KEY_NEW git_credential_ssh_key_new
# define GIT2R_CREDENTIAL_USERPASS_PLAINTEXT_NEW git_credential_userpass_plaintext_new
# define GIT2R_CREDENTIAL_SSH_KEY_FROM_AGENT git_credential_ssh_key_from_agent
# define GIT2R_CREDENTIAL_USERPASS_PLAINTEXT GIT_CREDENTIAL_USERPASS_PLAINTEXT
# define GIT2R_INDEXER_PROGRESS git_indexer_progress
# define GIT2R_OID_IS_ZERO git_oid_is_zero
# define GIT2R_BLOB_CREATE_FROM_DISK git_blob_create_from_disk
# define GIT2R_BLOB_CREATE_FROM_WORKDIR git_blob_create_from_workdir
#else
# define GIT2R_CREDENTIAL git_cred
# define GIT2R_CREDENTIAL_SSH_KEY GIT_CREDTYPE_SSH_KEY
# define GIT2R_CREDENTIAL_SSH_KEY_NEW git_cred_ssh_key_new
# define GIT2R_CREDENTIAL_USERPASS_PLAINTEXT_NEW git_cred_userpass_plaintext_new
# define GIT2R_CREDENTIAL_SSH_KEY_FROM_AGENT git_cred_ssh_key_from_agent
# define GIT2R_CREDENTIAL_USERPASS_PLAINTEXT GIT_CREDTYPE_USERPASS_PLAINTEXT
# define GIT2R_INDEXER_PROGRESS git_transfer_progress
# define GIT2R_OID_IS_ZERO git_oid_iszero
# define GIT2R_BLOB_CREATE_FROM_DISK git_blob_create_fromdisk
# define GIT2R_BLOB_CREATE_FROM_WORKDIR git_blob_create_fromworkdir
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/git2r_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ git2r_update_tips_cb(
git_oid_fmt(b_str, b);
b_str[GIT_OID_HEXSZ] = '\0';

if (GIT2R_OID_IS_ZERO(a)) {
if (git_oid_is_zero(a)) {
Rprintf("[new] %.20s %s\n", b_str, refname);
} else {
char a_str[GIT_OID_HEXSZ + 1];
Expand Down

0 comments on commit ce1a10d

Please sign in to comment.