Skip to content

Commit

Permalink
Simplify build configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
stewid committed Oct 6, 2024
1 parent 84ab8a5 commit 50069bb
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 65 deletions.
24 changes: 0 additions & 24 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2237,30 +2237,6 @@ as_fn_error $? "package dependency requirement 'libgit2 >= ${LIBGIT2_MIN_VERSION
See 'config.log' for more details" "$LINENO" 5; }
fi

################# Begin configuration to use system libgit2 ##################
# Check for new sys subfolfder in libgit2.
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether libgit2 includes new sys subfolder" >&5
printf %s "checking whether libgit2 includes new sys subfolder... " >&6; }
have_sys_subfolder=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <git2/sys/errors.h>
int
main (void)
{
git_error_set_str(0, NULL);
;
return 0;
}
_ACEOF
PKG_CFLAGS="${PKG_CFLAGS}" "$RBIN" CMD SHLIB conftest.c \
1>&5 2>&5 && have_sys_subfolder=yes
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${have_sys_subfolder}" >&5
printf "%s\n" "${have_sys_subfolder}" >&6; }
if test "x${have_sys_subfolder}" = xyes; then
PKG_CFLAGS="${PKG_CFLAGS} -DGIT2R_HAVE_SYS_SUBFOLDER"
fi

# For debugging
echo "----- Results of the git2r package configure -----"
echo ""
Expand Down
14 changes: 0 additions & 14 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,6 @@ if test "x${libgit2_ver_ok}" = xno; then
AC_MSG_FAILURE([package dependency requirement 'libgit2 >= ${LIBGIT2_MIN_VERSION}' could not be satisfied.])
fi

################# Begin configuration to use system libgit2 ##################
# Check for new sys subfolfder in libgit2.
AC_MSG_CHECKING([whether libgit2 includes new sys subfolder])
have_sys_subfolder=no
AC_LANG_CONFTEST([AC_LANG_PROGRAM(
[[#include <git2/sys/errors.h>]],
[[git_error_set_str(0, NULL);]])])
PKG_CFLAGS="${PKG_CFLAGS}" "$RBIN" CMD SHLIB conftest.c \
1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD && have_sys_subfolder=yes
AC_MSG_RESULT([${have_sys_subfolder}])
if test "x${have_sys_subfolder}" = xyes; then
PKG_CFLAGS="${PKG_CFLAGS} -DGIT2R_HAVE_SYS_SUBFOLDER"
fi

# For debugging
echo "----- Results of the git2r package configure -----"
echo ""
Expand Down
2 changes: 1 addition & 1 deletion src/git2r_arg.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ git2r_copy_string_vec(
/* Allocate the strings in dst */
dst->strings = malloc(dst->count * sizeof(char*));
if (!dst->strings) {
git_error_set_str(GIT_ERROR_NONE, git2r_err_alloc_memory_buffer);
giterr_set_str(GIT_ERROR_NONE, git2r_err_alloc_memory_buffer);
return GIT_ERROR;
}

Expand Down
4 changes: 2 additions & 2 deletions src/git2r_branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,13 @@ git2r_branch_upstream_canonical_name(
buf_len = branch_name_len + sizeof("branch." ".merge");
buf = malloc(buf_len);
if (!buf) {
git_error_set_oom();
giterr_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) {
git_error_set_str(GIT_ERROR_OS, "Failed to snprintf branch config.");
giterr_set_str(GIT_ERROR_OS, "Failed to snprintf branch config.");
error = GIT_ERROR_OS;
goto cleanup;
}
Expand Down
4 changes: 2 additions & 2 deletions src/git2r_checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ git2r_checkout_path(
/* Allocate the strings in pathspec */
opts.paths.strings = malloc(opts.paths.count * sizeof(char*));
if (!opts.paths.strings) {
git_error_set_str(GIT_ERROR_NONE, git2r_err_alloc_memory_buffer);
giterr_set_str(GIT_ERROR_NONE, git2r_err_alloc_memory_buffer);
error = GIT_ERROR;
goto cleanup;
}
Expand Down Expand Up @@ -125,7 +125,7 @@ git2r_checkout_tree(
error = GIT_OK;
break;
default:
git_error_set_str(GIT_ERROR_NONE, git2r_err_checkout_tree);
giterr_set_str(GIT_ERROR_NONE, git2r_err_checkout_tree);
error = GIT_ERROR;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/git2r_commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ git2r_any_changes_in_index(
}

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

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

*parents = calloc(cb_data.n + 1, sizeof(git_commit*));
if (!parents) {
git_error_set_str(GIT_ERROR_NONE, git2r_err_alloc_memory_buffer);
giterr_set_str(GIT_ERROR_NONE, git2r_err_alloc_memory_buffer);
return GIT_ERROR;
}
*n_parents = cb_data.n + 1;
Expand Down
4 changes: 2 additions & 2 deletions src/git2r_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ git2r_config_count_variables(
n_level[6]++;
break;
default:
git_error_set_str(GIT_ERROR_CONFIG,
giterr_set_str(GIT_ERROR_CONFIG,
git2r_err_unexpected_config_level);
error = GIT_ERROR;
goto cleanup;
Expand Down Expand Up @@ -221,7 +221,7 @@ git2r_config_list_variables(
git2r_config_list_add_entry(list, 6, i_level, i_list, entry);
break;
default:
git_error_set_str(GIT_ERROR_CONFIG,
giterr_set_str(GIT_ERROR_CONFIG,
git2r_err_unexpected_config_level);
error = GIT_ERROR;
goto cleanup;
Expand Down
5 changes: 1 addition & 4 deletions src/git2r_error.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-2018 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 @@ -20,9 +20,6 @@
#define INCLUDE_git2r_error_h

#include <git2.h>
#ifdef GIT2R_HAVE_SYS_SUBFOLDER
#include <git2/sys/errors.h>
#endif

/**
* Error messages
Expand Down
20 changes: 10 additions & 10 deletions src/git2r_merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ git2r_fast_forward_merge(
buf_len = strlen(log_message) + sizeof(": Fast-forward");
buf = malloc(buf_len);
if (!buf) {
git_error_set_oom();
giterr_set_oom();
error = GIT_ERROR_NOMEMORY;
goto cleanup;
}
error = snprintf(buf, buf_len, "%s: Fast-forward", log_message);
if (error < 0 || (size_t)error >= buf_len) {
git_error_set_str(GIT_ERROR_OS, "Failed to snprintf log message.");
giterr_set_str(GIT_ERROR_OS, "Failed to snprintf log message.");
error = GIT_ERROR_OS;
goto cleanup;
}
Expand Down Expand Up @@ -404,7 +404,7 @@ git2r_merge(
case GIT_MERGE_PREFERENCE_NONE:
if (merge_analysis & GIT_MERGE_ANALYSIS_FASTFORWARD) {
if (1 != n) {
git_error_set_str(
giterr_set_str(
GIT_ERROR_NONE,
"Unable to perform Fast-Forward merge "
"with mith multiple merge heads.");
Expand Down Expand Up @@ -446,7 +446,7 @@ git2r_merge(
case GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY:
if (merge_analysis & GIT_MERGE_ANALYSIS_FASTFORWARD) {
if (1 != n) {
git_error_set_str(
giterr_set_str(
GIT_ERROR_NONE,
"Unable to perform Fast-Forward merge "
"with mith multiple merge heads.");
Expand All @@ -459,12 +459,12 @@ git2r_merge(
repository,
name);
} else {
git_error_set_str(GIT_ERROR_NONE, "Unable to perform Fast-Forward merge.");
giterr_set_str(GIT_ERROR_NONE, "Unable to perform Fast-Forward merge.");
return GIT_ERROR;
}
break;
default:
git_error_set_str(GIT_ERROR_NONE, "Unknown merge option");
giterr_set_str(GIT_ERROR_NONE, "Unknown merge option");
return GIT_ERROR;
}

Expand Down Expand Up @@ -548,7 +548,7 @@ git2r_merge_branch(

merge_heads = calloc(1, sizeof(git_annotated_commit*));
if (NULL == merge_heads) {
git_error_set_str(GIT_ERROR_NONE, git2r_err_alloc_memory_buffer);
giterr_set_str(GIT_ERROR_NONE, git2r_err_alloc_memory_buffer);
goto cleanup;
}

Expand All @@ -562,13 +562,13 @@ git2r_merge_branch(
buf_len = strlen(name) + sizeof("merge ");
buf = malloc(buf_len);
if (!buf) {
git_error_set_oom();
giterr_set_oom();
error = GIT_ERROR_NOMEMORY;
goto cleanup;
}
error = snprintf(buf, buf_len, "merge %s", name);
if (error < 0 || (size_t)error >= buf_len) {
git_error_set_str(GIT_ERROR_OS, "Failed to snprintf log message.");
giterr_set_str(GIT_ERROR_OS, "Failed to snprintf log message.");
error = GIT_ERROR_OS;
goto cleanup;
}
Expand Down Expand Up @@ -627,7 +627,7 @@ git2r_merge_heads_from_fetch_heads(

*merge_heads = calloc(n, sizeof(git_annotated_commit*));
if (!(*merge_heads)) {
git_error_set_str(GIT_ERROR_NONE, git2r_err_alloc_memory_buffer);
giterr_set_str(GIT_ERROR_NONE, git2r_err_alloc_memory_buffer);
return GIT_ERROR;
}

Expand Down
4 changes: 2 additions & 2 deletions src/git2r_odb.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ git2r_odb_tree_blobs(
buf = malloc(buf_len);
if (!buf) {
git_tree_free(sub_tree);
git_error_set_oom();
giterr_set_oom();
return GIT_ERROR_NOMEMORY;
}
if (path_len) {
Expand All @@ -400,7 +400,7 @@ git2r_odb_tree_blobs(
when,
data);
} else {
git_error_set_str(GIT_ERROR_OS, "Failed to snprintf tree path.");
giterr_set_str(GIT_ERROR_OS, "Failed to snprintf tree path.");
error = GIT_ERROR_OS;
}

Expand Down
2 changes: 1 addition & 1 deletion src/git2r_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ git2r_remote_fetch(
/* Allocate the strings in refs */
refs.strings = malloc(refs.count * sizeof(char*));
if (!refs.strings) {
git_error_set_str(GIT_ERROR_NONE, git2r_err_alloc_memory_buffer);
giterr_set_str(GIT_ERROR_NONE, git2r_err_alloc_memory_buffer);
error = GIT_ERROR;
goto cleanup;
}
Expand Down
2 changes: 1 addition & 1 deletion src/git2r_revparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ git2r_revparse_single(
git2r_tree_init((git_tree*)treeish, repo, result);
break;
default:
git_error_set_str(GIT_ERROR_NONE, git2r_err_revparse_single);
giterr_set_str(GIT_ERROR_NONE, git2r_err_revparse_single);
error = GIT_ERROR;
break;
}
Expand Down

0 comments on commit 50069bb

Please sign in to comment.