Skip to content

Commit e55f435

Browse files
committed
Handle renamed structures, enums and values in libgit2 v0.99
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 Signed-off-by: Stefan Widgren <stefan.widgren@gmail.com>
1 parent 24a3c74 commit e55f435

File tree

8 files changed

+62
-33
lines changed

8 files changed

+62
-33
lines changed

src/git2r_blob.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* git2r, R bindings to the libgit2 library.
3-
* Copyright (C) 2013-2019 The git2r contributors
3+
* Copyright (C) 2013-2020 The git2r contributors
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License, version 2,
@@ -100,7 +100,7 @@ SEXP git2r_blob_create_fromdisk(SEXP repo, SEXP path)
100100
git_blob *blob = NULL;
101101
SEXP item;
102102

103-
error = git_blob_create_fromdisk(
103+
error = GIT2R_BLOB_CREATE_FROM_DISK(
104104
&oid,
105105
repository,
106106
CHAR(STRING_ELT(path, i)));
@@ -167,7 +167,7 @@ SEXP git2r_blob_create_fromworkdir(SEXP repo, SEXP relative_path)
167167
git_blob *blob = NULL;
168168
SEXP item;
169169

170-
error = git_blob_create_fromworkdir(
170+
error = GIT2R_BLOB_CREATE_FROM_WORKDIR(
171171
&oid,
172172
repository,
173173
CHAR(STRING_ELT(relative_path, i)));

src/git2r_clone.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* git2r, R bindings to the libgit2 library.
3-
* Copyright (C) 2013-2019 The git2r contributors
3+
* Copyright (C) 2013-2020 The git2r contributors
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License, version 2,
@@ -34,7 +34,7 @@
3434
* @return 0
3535
*/
3636
static int git2r_clone_progress(
37-
const git_transfer_progress *progress,
37+
const GIT2R_INDEXER_PROGRESS *progress,
3838
void *payload)
3939
{
4040
int kbytes = progress->received_bytes / 1024;

src/git2r_cred.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* git2r, R bindings to the libgit2 library.
3-
* Copyright (C) 2013-2019 The git2r contributors
3+
* Copyright (C) 2013-2020 The git2r contributors
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License, version 2,
@@ -35,6 +35,7 @@
3535

3636
#include "git2r_arg.h"
3737
#include "git2r_cred.h"
38+
#include "git2r_deprecated.h"
3839
#include "git2r_S3.h"
3940
#include "git2r_transfer.h"
4041

@@ -78,12 +79,12 @@ static int git2r_getenv(char **out, SEXP obj, const char *slot)
7879
* @return 0 on success, else -1.
7980
*/
8081
static int git2r_cred_ssh_key(
81-
git_cred **cred,
82+
GIT2R_CREDENTIAL **cred,
8283
const char *username_from_url,
8384
unsigned int allowed_types,
8485
SEXP credentials)
8586
{
86-
if (GIT_CREDTYPE_SSH_KEY & allowed_types) {
87+
if (GIT2R_CREDENTIAL_SSH_KEY & allowed_types) {
8788
SEXP elem;
8889
const char *publickey;
8990
const char *privatekey = NULL;
@@ -96,7 +97,7 @@ static int git2r_cred_ssh_key(
9697
if (Rf_length(elem) && (NA_STRING != STRING_ELT(elem, 0)))
9798
passphrase = CHAR(STRING_ELT(elem, 0));
9899

99-
if (git_cred_ssh_key_new(
100+
if (GIT2R_CREDENTIAL_SSH_KEY_NEW(
100101
cred, username_from_url, publickey, privatekey, passphrase))
101102
return -1;
102103

@@ -115,11 +116,11 @@ static int git2r_cred_ssh_key(
115116
* @return 0 on success, else -1.
116117
*/
117118
static int git2r_cred_env(
118-
git_cred **cred,
119+
GIT2R_CREDENTIAL **cred,
119120
unsigned int allowed_types,
120121
SEXP credentials)
121122
{
122-
if (GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) {
123+
if (GIT2R_CREDENTIAL_USERPASS_PLAINTEXT & allowed_types) {
123124
int error;
124125
char *username = NULL;
125126
char *password = NULL;
@@ -134,7 +135,8 @@ static int git2r_cred_env(
134135
if (error)
135136
goto cleanup;
136137

137-
error = git_cred_userpass_plaintext_new(cred, username, password);
138+
error = GIT2R_CREDENTIAL_USERPASS_PLAINTEXT_NEW(
139+
cred, username, password);
138140

139141
cleanup:
140142
free(username);
@@ -158,11 +160,11 @@ static int git2r_cred_env(
158160
* @return 0 on success, else -1.
159161
*/
160162
static int git2r_cred_token(
161-
git_cred **cred,
163+
GIT2R_CREDENTIAL **cred,
162164
unsigned int allowed_types,
163165
SEXP credentials)
164166
{
165-
if (GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) {
167+
if (GIT2R_CREDENTIAL_USERPASS_PLAINTEXT & allowed_types) {
166168
int error;
167169
char *token = NULL;
168170

@@ -172,7 +174,7 @@ static int git2r_cred_token(
172174
if (error)
173175
goto cleanup;
174176

175-
error = git_cred_userpass_plaintext_new(cred, " ", token);
177+
error = GIT2R_CREDENTIAL_USERPASS_PLAINTEXT_NEW(cred, " ", token);
176178

177179
cleanup:
178180
free(token);
@@ -195,17 +197,17 @@ static int git2r_cred_token(
195197
* @return 0 on success, else -1.
196198
*/
197199
static int git2r_cred_user_pass(
198-
git_cred **cred,
200+
GIT2R_CREDENTIAL **cred,
199201
unsigned int allowed_types,
200202
SEXP credentials)
201203
{
202-
if (GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) {
204+
if (GIT2R_CREDENTIAL_USERPASS_PLAINTEXT & allowed_types) {
203205
const char *username;
204206
const char *password;
205207

206208
username = CHAR(STRING_ELT(git2r_get_list_element(credentials, "username"), 0));
207209
password = CHAR(STRING_ELT(git2r_get_list_element(credentials, "password"), 0));
208-
if (git_cred_userpass_plaintext_new(cred, username, password))
210+
if (GIT2R_CREDENTIAL_USERPASS_PLAINTEXT_NEW(cred, username, password))
209211
return -1;
210212

211213
return 0;
@@ -347,7 +349,7 @@ static int git2r_cred_user_pass(
347349
/* } */
348350

349351
/* static int git2r_cred_default_ssh_key( */
350-
/* git_cred **cred, */
352+
/* GIT2R_CREDENTIAL **cred, */
351353
/* const char *username_from_url) */
352354
/* { */
353355
/* #ifdef WIN32 */
@@ -431,7 +433,7 @@ static int git2r_cred_user_pass(
431433
* @return 0 on success, else -1.
432434
*/
433435
int git2r_cred_acquire_cb(
434-
git_cred **cred,
436+
GIT2R_CREDENTIAL **cred,
435437
const char *url,
436438
const char *username_from_url,
437439
unsigned int allowed_types,
@@ -448,11 +450,11 @@ int git2r_cred_acquire_cb(
448450
td = (git2r_transfer_data*)payload;
449451
credentials = td->credentials;
450452
if (Rf_isNull(credentials)) {
451-
if (GIT_CREDTYPE_SSH_KEY & allowed_types) {
453+
if (GIT2R_CREDENTIAL_SSH_KEY & allowed_types) {
452454
if (td->use_ssh_agent) {
453455
/* Try to get credentials from the ssh-agent. */
454456
td->use_ssh_agent = 0;
455-
if (git_cred_ssh_key_from_agent(cred, username_from_url) == 0)
457+
if (GIT2R_CREDENTIAL_SSH_KEY_FROM_AGENT(cred, username_from_url) == 0)
456458
return 0;
457459
}
458460

src/git2r_cred.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* git2r, R bindings to the libgit2 library.
3-
* Copyright (C) 2013-2015 The git2r contributors
3+
* Copyright (C) 2013-2020 The git2r contributors
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License, version 2,
@@ -20,9 +20,10 @@
2020
#define INCLUDE_git2r_cred_h
2121

2222
#include <git2.h>
23+
#include "git2r_deprecated.h"
2324

2425
int git2r_cred_acquire_cb(
25-
git_cred **out,
26+
GIT2R_CREDENTIAL **out,
2627
const char *url,
2728
const char *username_from_url,
2829
unsigned int allowed_types,

src/git2r_deprecated.h

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* git2r, R bindings to the libgit2 library.
3-
* Copyright (C) 2013-2019 The git2r contributors
3+
* Copyright (C) 2013-2020 The git2r contributors
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License, version 2,
@@ -70,4 +70,28 @@
7070
# define GIT2R_OBJECT_T git_otype
7171
#endif
7272

73+
#if defined(GIT2R_LIBGIT2_V0_99_0_RENAMES)
74+
# define GIT2R_CREDENTIAL git_credential
75+
# define GIT2R_CREDENTIAL_SSH_KEY GIT_CREDENTIAL_SSH_KEY
76+
# define GIT2R_CREDENTIAL_SSH_KEY_NEW git_credential_ssh_key_new
77+
# define GIT2R_CREDENTIAL_USERPASS_PLAINTEXT_NEW git_credential_userpass_plaintext_new
78+
# define GIT2R_CREDENTIAL_SSH_KEY_FROM_AGENT git_credential_ssh_key_from_agent
79+
# define GIT2R_CREDENTIAL_USERPASS_PLAINTEXT GIT_CREDENTIAL_USERPASS_PLAINTEXT
80+
# define GIT2R_INDEXER_PROGRESS git_indexer_progress
81+
# define GIT2R_OID_IS_ZERO git_oid_is_zero
82+
# define GIT2R_BLOB_CREATE_FROM_DISK git_blob_create_from_disk
83+
# define GIT2R_BLOB_CREATE_FROM_WORKDIR git_blob_create_from_workdir
84+
#else
85+
# define GIT2R_CREDENTIAL git_cred
86+
# define GIT2R_CREDENTIAL_SSH_KEY GIT_CREDTYPE_SSH_KEY
87+
# define GIT2R_CREDENTIAL_SSH_KEY_NEW git_cred_ssh_key_new
88+
# define GIT2R_CREDENTIAL_USERPASS_PLAINTEXT_NEW git_cred_userpass_plaintext_new
89+
# define GIT2R_CREDENTIAL_SSH_KEY_FROM_AGENT git_cred_ssh_key_from_agent
90+
# define GIT2R_CREDENTIAL_USERPASS_PLAINTEXT GIT_CREDTYPE_USERPASS_PLAINTEXT
91+
# define GIT2R_INDEXER_PROGRESS git_transfer_progress
92+
# define GIT2R_OID_IS_ZERO git_oid_iszero
93+
# define GIT2R_BLOB_CREATE_FROM_DISK git_blob_create_fromdisk
94+
# define GIT2R_BLOB_CREATE_FROM_WORKDIR git_blob_create_fromworkdir
95+
#endif
96+
7397
#endif

src/git2r_remote.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* git2r, R bindings to the libgit2 library.
3-
* Copyright (C) 2013-2019 The git2r contributors
3+
* Copyright (C) 2013-2020 The git2r contributors
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License, version 2,
@@ -95,7 +95,7 @@ static int git2r_update_tips_cb(
9595
git_oid_fmt(b_str, b);
9696
b_str[GIT_OID_HEXSZ] = '\0';
9797

98-
if (git_oid_iszero(a)) {
98+
if (GIT2R_OID_IS_ZERO(a)) {
9999
Rprintf("[new] %.20s %s\n", b_str, refname);
100100
} else {
101101
char a_str[GIT_OID_HEXSZ + 1];
@@ -130,7 +130,7 @@ SEXP git2r_remote_fetch(
130130
{
131131
int error, nprotect = 0;
132132
SEXP result = R_NilValue;
133-
const git_transfer_progress *stats;
133+
const GIT2R_INDEXER_PROGRESS *stats;
134134
git_remote *remote = NULL;
135135
git_repository *repository = NULL;
136136
git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT;

src/git2r_transfer.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* git2r, R bindings to the libgit2 library.
3-
* Copyright (C) 2013-2018 The git2r contributors
3+
* Copyright (C) 2013-2020 The git2r contributors
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License, version 2,
@@ -16,18 +16,19 @@
1616
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1717
*/
1818

19+
#include "git2r_deprecated.h"
1920
#include "git2r_S3.h"
2021
#include "git2r_transfer.h"
2122

2223
/**
2324
* Init slots in S3 class git_transfer_progress
2425
*
25-
* @param source A git_transfer_progress object
26+
* @param source A GIT2R_INDEXER_PROGRESS object
2627
* @param dest S3 class git_transfer_progress to initialize
2728
* @return void
2829
*/
2930
void git2r_transfer_progress_init(
30-
const git_transfer_progress *source,
31+
const GIT2R_INDEXER_PROGRESS *source,
3132
SEXP dest)
3233
{
3334
SET_VECTOR_ELT(

src/git2r_transfer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* git2r, R bindings to the libgit2 library.
3-
* Copyright (C) 2013-2018 The git2r contributors
3+
* Copyright (C) 2013-2020 The git2r contributors
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License, version 2,
@@ -22,6 +22,7 @@
2222
#include <R.h>
2323
#include <Rinternals.h>
2424
#include <git2.h>
25+
#include "git2r_deprecated.h"
2526

2627
/**
2728
* Data structure to hold information when performing a clone, fetch
@@ -54,7 +55,7 @@ typedef struct {
5455
#endif
5556

5657
void git2r_transfer_progress_init(
57-
const git_transfer_progress *source,
58+
const GIT2R_INDEXER_PROGRESS *source,
5859
SEXP dest);
5960

6061
#endif

0 commit comments

Comments
 (0)