Skip to content

Commit

Permalink
Drop usage of error functions and enumaration values that have been d…
Browse files Browse the repository at this point in the history
…eprecated in libgit2
  • Loading branch information
stewid committed Oct 5, 2024
1 parent b0b60f2 commit e274f68
Show file tree
Hide file tree
Showing 32 changed files with 150 additions and 208 deletions.
24 changes: 0 additions & 24 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2300,30 +2300,6 @@ if test "x${have_sys_subfolder}" = xyes; then
PKG_CFLAGS="${PKG_CFLAGS} -DGIT2R_HAVE_SYS_SUBFOLDER"
fi

# Several libgit2 error functions and enumaration values have been
# deprecated, use newer versions.
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the libgit2 function git_error_last is available" >&5
printf %s "checking whether the libgit2 function git_error_last is available... " >&6; }
have_git_error_last=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <git2.h>
int
main (void)
{
git_error_last();
;
return 0;
}
_ACEOF
PKG_CFLAGS="${PKG_CFLAGS} -Werror" "$RBIN" CMD SHLIB conftest.c \
1>&5 2>&5 && have_git_error_last=yes
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${have_git_error_last}" >&5
printf "%s\n" "${have_git_error_last}" >&6; }
if test "x${have_git_error_last}" = xyes; then
PKG_CFLAGS="${PKG_CFLAGS} -DGIT2R_HAVE_GIT_ERROR"
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
Expand Down
16 changes: 1 addition & 15 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# git2r, R bindings to the libgit2 library.
# Copyright (C) 2013-2023 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 @@ -148,20 +148,6 @@ if test "x${have_sys_subfolder}" = xyes; then
PKG_CFLAGS="${PKG_CFLAGS} -DGIT2R_HAVE_SYS_SUBFOLDER"
fi

# Several libgit2 error functions and enumaration values have been
# deprecated, use newer versions.
AC_MSG_CHECKING([whether the libgit2 function git_error_last is available])
have_git_error_last=no
AC_LANG_CONFTEST([AC_LANG_PROGRAM(
[[#include <git2.h>]],
[[git_error_last();]])])
PKG_CFLAGS="${PKG_CFLAGS} -Werror" "$RBIN" CMD SHLIB conftest.c \
1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD && have_git_error_last=yes
AC_MSG_RESULT([${have_git_error_last}])
if test "x${have_git_error_last}" = xyes; then
PKG_CFLAGS="${PKG_CFLAGS} -DGIT2R_HAVE_GIT_ERROR"
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
Expand Down
4 changes: 2 additions & 2 deletions src/git2r_arg.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 @@ -514,7 +514,7 @@ git2r_copy_string_vec(
/* Allocate the strings in dst */
dst->strings = malloc(dst->count * sizeof(char*));
if (!dst->strings) {
GIT2R_ERROR_SET_STR(GIT2R_ERROR_NONE, git2r_err_alloc_memory_buffer);
git_error_set_str(GIT_ERROR_NONE, git2r_err_alloc_memory_buffer);
return GIT_ERROR;
}

Expand Down
4 changes: 2 additions & 2 deletions src/git2r_blame.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 @@ -192,7 +192,7 @@ git2r_blame_file(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
12 changes: 6 additions & 6 deletions src/git2r_blob.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-2023 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 @@ -85,7 +85,7 @@ git2r_blob_content(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -151,7 +151,7 @@ git2r_blob_create_fromdisk(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -221,7 +221,7 @@ git2r_blob_create_fromworkdir(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -295,7 +295,7 @@ git2r_blob_is_binary(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -338,7 +338,7 @@ git2r_blob_rawsize(
git_repository_free(repository);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return Rf_ScalarInteger(size);
}
34 changes: 17 additions & 17 deletions src/git2r_branch.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 @@ -164,7 +164,7 @@ git2r_branch_create(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -205,7 +205,7 @@ git2r_branch_delete(
git_repository_free(repository);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return R_NilValue;
}
Expand Down Expand Up @@ -259,7 +259,7 @@ git2r_branch_is_head(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -339,7 +339,7 @@ git2r_branch_list(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -386,7 +386,7 @@ git2r_branch_canonical_name(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -442,14 +442,14 @@ git2r_branch_upstream_canonical_name(
buf_len = branch_name_len + sizeof("branch." ".merge");
buf = malloc(buf_len);
if (!buf) {
GIT2R_ERROR_SET_OOM();
error = GIT2R_ERROR_NOMEMORY;
git_error_set_oom();
error = GIT_ERROR_NOMEMORY;
goto cleanup;
}
error = snprintf(buf, buf_len, "branch.%.*s.merge", (int)branch_name_len, branch_name);
if (error < 0 || (size_t)error >= buf_len) {
GIT2R_ERROR_SET_STR(GIT2R_ERROR_OS, "Failed to snprintf branch config.");
error = GIT2R_ERROR_OS;
git_error_set_str(GIT_ERROR_OS, "Failed to snprintf branch config.");
error = GIT_ERROR_OS;
goto cleanup;
}

Expand All @@ -471,7 +471,7 @@ git2r_branch_upstream_canonical_name(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -530,7 +530,7 @@ git2r_branch_remote_name(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -601,7 +601,7 @@ git2r_branch_remote_url(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -671,7 +671,7 @@ git2r_branch_rename(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -725,7 +725,7 @@ git2r_branch_target(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -783,7 +783,7 @@ git2r_branch_get_upstream(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -836,7 +836,7 @@ git2r_branch_set_upstream(
git_repository_free(repository);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return R_NilValue;
}
10 changes: 5 additions & 5 deletions src/git2r_checkout.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 @@ -62,7 +62,7 @@ git2r_checkout_path(
/* Allocate the strings in pathspec */
opts.paths.strings = malloc(opts.paths.count * sizeof(char*));
if (!opts.paths.strings) {
GIT2R_ERROR_SET_STR(GIT2R_ERROR_NONE, git2r_err_alloc_memory_buffer);
git_error_set_str(GIT_ERROR_NONE, git2r_err_alloc_memory_buffer);
error = GIT_ERROR;
goto cleanup;
}
Expand All @@ -80,7 +80,7 @@ git2r_checkout_path(
git_repository_free(repository);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return R_NilValue;
}
Expand Down Expand Up @@ -126,7 +126,7 @@ git2r_checkout_tree(
error = GIT_OK;
break;
default:
GIT2R_ERROR_SET_STR(GIT2R_ERROR_NONE, git2r_err_checkout_tree);
git_error_set_str(GIT_ERROR_NONE, git2r_err_checkout_tree);
error = GIT_ERROR;
break;
}
Expand All @@ -145,7 +145,7 @@ git2r_checkout_tree(
git_repository_free(repository);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return R_NilValue;
}
4 changes: 2 additions & 2 deletions src/git2r_clone.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 @@ -141,7 +141,7 @@ git2r_clone(
if (error)
git2r_error(
__func__,
GIT2R_ERROR_LAST(),
git_error_last(),
git2r_err_unable_to_authenticate,
NULL);

Expand Down
12 changes: 6 additions & 6 deletions src/git2r_commit.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-2019 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 @@ -73,7 +73,7 @@ git2r_any_changes_in_index(
}

if (!changes_in_index) {
GIT2R_ERROR_SET_STR(GIT2R_ERROR_NONE, git2r_err_nothing_added_to_commit);
git_error_set_str(GIT_ERROR_NONE, git2r_err_nothing_added_to_commit);
error = GIT_ERROR;
}

Expand Down Expand Up @@ -182,7 +182,7 @@ git2r_retrieve_parents(

*parents = calloc(cb_data.n + 1, sizeof(git_commit*));
if (!parents) {
GIT2R_ERROR_SET_STR(GIT2R_ERROR_NONE, git2r_err_alloc_memory_buffer);
git_error_set_str(GIT_ERROR_NONE, git2r_err_alloc_memory_buffer);
return GIT_ERROR;
}
*n_parents = cb_data.n + 1;
Expand Down Expand Up @@ -358,7 +358,7 @@ git2r_commit(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -433,7 +433,7 @@ git2r_commit_tree(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return result;
}
Expand Down Expand Up @@ -562,7 +562,7 @@ git2r_commit_parent_list(
UNPROTECT(nprotect);

if (error)
git2r_error(__func__, GIT2R_ERROR_LAST(), NULL, NULL);
git2r_error(__func__, git_error_last(), NULL, NULL);

return list;
}
Loading

0 comments on commit e274f68

Please sign in to comment.