New upstream version 1.8.2~rc1+ds

This commit is contained in:
Timo Röhling 2024-09-15 09:52:10 +02:00
parent 3e184db30b
commit 54c37f5d20
31 changed files with 192 additions and 64 deletions

View File

@ -6,7 +6,7 @@
cmake_minimum_required(VERSION 3.5.1)
project(libgit2 VERSION "1.8.1" LANGUAGES C)
project(libgit2 VERSION "1.8.2" LANGUAGES C)
# Add find modules to the path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")

View File

@ -3,10 +3,10 @@ libgit2 - the Git linkable library
| Build Status | |
| ------------ | - |
| **main** branch CI builds | [![CI Build](https://github.com/libgit2/libgit2/workflows/CI%20Build/badge.svg?event=push)](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush) |
| **v1.8 branch** CI builds | [![CI Build](https://github.com/libgit2/libgit2/workflows/CI%20Build/badge.svg?branch=maint%2Fv1.8&event=push)](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush+branch%3Amaint%2Fv1.8) |
| **v1.7 branch** CI builds | [![CI Build](https://github.com/libgit2/libgit2/workflows/CI%20Build/badge.svg?branch=maint%2Fv1.7&event=push)](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush+branch%3Amaint%2Fv1.7) |
| **Nightly** builds | [![Nightly Build](https://github.com/libgit2/libgit2/workflows/Nightly%20Build/badge.svg)](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22Nightly+Build%22) [![Coverity Scan Status](https://scan.coverity.com/projects/639/badge.svg)](https://scan.coverity.com/projects/639) |
| **main** branch builds | [![CI Build](https://github.com/libgit2/libgit2/actions/workflows/main.yml/badge.svg?branch=main&event=push)](https://github.com/libgit2/libgit2/actions/workflows/main.yml?query=event%3Apush+branch%3Amain) [![Experimental Features](https://github.com/libgit2/libgit2/actions/workflows/experimental.yml/badge.svg?branch=main)](https://github.com/libgit2/libgit2/actions/workflows/experimental.yml?query=event%3Apush+branch%3Amain) |
| **v1.8 branch** builds | [![CI Build](https://github.com/libgit2/libgit2/actions/workflows/main.yml/badge.svg?branch=maint%2Fv1.8&event=push)](https://github.com/libgit2/libgit2/actions/workflows/main.yml?query=event%3Apush+branch%3Amaint%2Fv1.8) [![Experimental Features](https://github.com/libgit2/libgit2/actions/workflows/experimental.yml/badge.svg?branch=maint%2Fv1.8)](https://github.com/libgit2/libgit2/actions/workflows/experimental.yml?query=event%3Apush+branch%3Amaint%2Fv1.8) |
| **v1.7 branch** builds | [![CI Build](https://github.com/libgit2/libgit2/actions/workflows/main.yml/badge.svg?branch=maint%2Fv1.8&event=push)](https://github.com/libgit2/libgit2/actions/workflows/main.yml?query=event%3Apush+branch%3Amaint%2Fv1.7) |
| **Nightly** builds | [![Nightly Build](https://github.com/libgit2/libgit2/actions/workflows/nightly.yml/badge.svg?branch=main&event=schedule)](https://github.com/libgit2/libgit2/actions/workflows/nightly.yml) [![Coverity Scan Status](https://scan.coverity.com/projects/639/badge.svg)](https://scan.coverity.com/projects/639) |
`libgit2` is a portable, pure C implementation of the Git core methods
provided as a linkable library with a solid API, allowing to build Git

View File

@ -1,3 +1,29 @@
v1.8.2
------
This release reverts a const-correctness change introduced in
v1.8.0 for the `git_commit_create` functions. We now retain the
const-behavior for the `commits` arguments from prior to v1.8.0.
This change was meant to resolve compatibility issues with bindings
and downstream users.
## What's Changed
### New features
* Introduce a stricter debugging allocator for testing by @ethomson in https://github.com/libgit2/libgit2/pull/6811
### Bug fixes
* Fix constness issue introduced in #6716 by @ethomson in https://github.com/libgit2/libgit2/pull/6829
### Build and CI improvements
* README: add experimental builds to ci table by @ethomson in https://github.com/libgit2/libgit2/pull/6816
**Full Changelog**: https://github.com/libgit2/libgit2/compare/v1.8.1...v1.8.2
v1.8.1
------

View File

@ -263,7 +263,7 @@ static int create_merge_commit(git_repository *repo, git_index *index, struct me
sign, sign,
NULL, msg,
tree,
opts->annotated_count + 1, parents);
opts->annotated_count + 1, (const git_commit **)parents);
check_lg2(err, "failed to create commit", NULL);
/* We're done merging, cleanup the repository state */

View File

@ -366,7 +366,7 @@ GIT_EXTERN(int) git_commit_create(
const char *message,
const git_tree *tree,
size_t parent_count,
git_commit * const parents[]);
const git_commit *parents[]);
/**
* Create new commit in the repository using a variable argument list.
@ -512,7 +512,7 @@ GIT_EXTERN(int) git_commit_create_buffer(
const char *message,
const git_tree *tree,
size_t parent_count,
git_commit * const parents[]);
const git_commit *parents[]);
/**
* Create a commit object from the given buffer and signature
@ -581,7 +581,7 @@ typedef int (*git_commit_create_cb)(
const char *message,
const git_tree *tree,
size_t parent_count,
git_commit * const parents[],
const git_commit *parents[],
void *payload);
/** An array of commits returned from the library */

View File

@ -11,7 +11,7 @@
* The version string for libgit2. This string follows semantic
* versioning (v2) guidelines.
*/
#define LIBGIT2_VERSION "1.8.1"
#define LIBGIT2_VERSION "1.8.2"
/** The major version number for this version of libgit2. */
#define LIBGIT2_VER_MAJOR 1
@ -20,7 +20,7 @@
#define LIBGIT2_VER_MINOR 8
/** The revision ("teeny") version number for this version of libgit2. */
#define LIBGIT2_VER_REVISION 1
#define LIBGIT2_VER_REVISION 2
/** The Windows DLL patch number for this version of libgit2. */
#define LIBGIT2_VER_PATCH 0

View File

@ -1,6 +1,6 @@
{
"name": "libgit2",
"version": "1.8.1",
"version": "1.8.2",
"repo": "https://github.com/libgit2/libgit2",
"description": " A cross-platform, linkable library implementation of Git that you can use in your application.",
"install": "mkdir build && cd build && cmake .. && cmake --build ."

View File

@ -281,7 +281,7 @@ int git_commit_create_from_ids(
typedef struct {
size_t total;
git_commit * const *parents;
const git_commit **parents;
git_repository *repo;
} commit_parent_data;
@ -307,7 +307,7 @@ int git_commit_create(
const char *message,
const git_tree *tree,
size_t parent_count,
git_commit * const parents[])
const git_commit *parents[])
{
commit_parent_data data = { parent_count, parents, repo };
@ -945,7 +945,7 @@ int git_commit_create_buffer(
const char *message,
const git_tree *tree,
size_t parent_count,
git_commit * const parents[])
const git_commit *parents[])
{
GIT_BUF_WRAP_PRIVATE(out, git_commit__create_buffer, repo,
author, committer, message_encoding, message,
@ -961,7 +961,7 @@ int git_commit__create_buffer(
const char *message,
const git_tree *tree,
size_t parent_count,
git_commit * const parents[])
const git_commit *parents[])
{
int error;
commit_parent_data data = { parent_count, parents, repo };
@ -1150,7 +1150,8 @@ int git_commit_create_from_stage(
error = git_commit_create(out, repo, "HEAD", author, committer,
opts.message_encoding, message,
tree, parents.count, parents.commits);
tree, parents.count,
(const git_commit **)parents.commits);
done:
git_commitarray_dispose(&parents);

View File

@ -64,7 +64,7 @@ int git_commit__create_buffer(
const char *message,
const git_tree *tree,
size_t parent_count,
git_commit * const parents[]);
const git_commit *parents[]);
int git_commit__parse(
void *commit,

View File

@ -303,7 +303,7 @@ static int note_write(
error = git_commit_create(&oid, repo, notes_ref, author, committer,
NULL, GIT_NOTES_DEFAULT_MSG_ADD,
tree, *parents == NULL ? 0 : 1, parents);
tree, *parents == NULL ? 0 : 1, (const git_commit **) parents);
if (notes_commit_out)
git_oid_cpy(notes_commit_out, &oid);
@ -394,7 +394,7 @@ static int note_remove(
NULL, GIT_NOTES_DEFAULT_MSG_RM,
tree_after_removal,
*parents == NULL ? 0 : 1,
parents);
(const git_commit **) parents);
if (error < 0)
goto cleanup;

View File

@ -952,7 +952,7 @@ static int create_signed(
const char *message,
git_tree *tree,
size_t parent_count,
git_commit * const *parents)
const git_commit **parents)
{
git_str commit_content = GIT_STR_INIT;
git_buf commit_signature = { NULL, 0, 0 },
@ -1040,7 +1040,8 @@ static int rebase_commit__create(
if (rebase->options.commit_create_cb) {
error = rebase->options.commit_create_cb(&commit_id,
author, committer, message_encoding, message,
tree, 1, &parent_commit, rebase->options.payload);
tree, 1, (const git_commit **)&parent_commit,
rebase->options.payload);
git_error_set_after_callback_function(error,
"commit_create_cb");
@ -1049,14 +1050,14 @@ static int rebase_commit__create(
else if (rebase->options.signing_cb) {
error = create_signed(&commit_id, rebase, author,
committer, message_encoding, message, tree,
1, &parent_commit);
1, (const git_commit **)&parent_commit);
}
#endif
if (error == GIT_PASSTHROUGH)
error = git_commit_create(&commit_id, rebase->repo, NULL,
author, committer, message_encoding, message,
tree, 1, &parent_commit);
tree, 1, (const git_commit **)&parent_commit);
if (error)
goto done;

View File

@ -124,7 +124,7 @@ static int commit_index(
git_index *index,
const git_signature *stasher,
const char *message,
git_commit *parent)
const git_commit *parent)
{
git_tree *i_tree = NULL;
git_oid i_commit_oid;
@ -423,7 +423,7 @@ static int build_stash_commit_from_tree(
git_commit *u_commit,
const git_tree *tree)
{
git_commit *parents[] = { NULL, NULL, NULL };
const git_commit *parents[] = { NULL, NULL, NULL };
parents[0] = b_commit;
parents[1] = i_commit;

View File

@ -8,8 +8,9 @@
#include "alloc.h"
#include "runtime.h"
#include "allocators/failalloc.h"
#include "allocators/stdalloc.h"
#include "allocators/debugalloc.h"
#include "allocators/failalloc.h"
#include "allocators/win32_leakcheck.h"
/* Fail any allocation until git_libgit2_init is called. */
@ -88,6 +89,8 @@ static int setup_default_allocator(void)
{
#if defined(GIT_WIN32_LEAKCHECK)
return git_win32_leakcheck_init_allocator(&git__allocator);
#elif defined(GIT_DEBUG_STRICT_ALLOC)
return git_debugalloc_init_allocator(&git__allocator);
#else
return git_stdalloc_init_allocator(&git__allocator);
#endif

View File

@ -0,0 +1,73 @@
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#include "debugalloc.h"
static void *debugalloc__malloc(size_t len, const char *file, int line)
{
unsigned char *ptr;
size_t total = len + sizeof(size_t);
GIT_UNUSED(file);
GIT_UNUSED(line);
if (!len || (ptr = malloc(total)) == NULL)
return NULL;
memcpy(ptr, &len, sizeof(size_t));
return ptr + sizeof(size_t);
}
static void *debugalloc__realloc(void *_ptr, size_t len, const char *file, int line)
{
unsigned char *ptr = _ptr, *newptr;
size_t original_len;
size_t total = len + sizeof(size_t);
GIT_UNUSED(file);
GIT_UNUSED(line);
if (!len && !ptr)
return NULL;
if (!len) {
free(ptr - sizeof(size_t));
return NULL;
}
if ((newptr = malloc(total)) == NULL)
return NULL;
if (ptr) {
memcpy(&original_len, ptr - sizeof(size_t), sizeof(size_t));
memcpy(newptr + sizeof(size_t), ptr, min(len, original_len));
memset(ptr - sizeof(size_t), 0xfd, original_len + sizeof(size_t));
free(ptr - sizeof(size_t));
}
memcpy(newptr, &len, sizeof(size_t));
return newptr + sizeof(size_t);
}
static void debugalloc__free(void *_ptr)
{
unsigned char *ptr = _ptr;
if (!ptr)
return;
free(ptr - sizeof(size_t));
}
int git_debugalloc_init_allocator(git_allocator *allocator)
{
allocator->gmalloc = debugalloc__malloc;
allocator->grealloc = debugalloc__realloc;
allocator->gfree = debugalloc__free;
return 0;
}

View File

@ -0,0 +1,17 @@
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef INCLUDE_allocators_debugalloc_h__
#define INCLUDE_allocators_debugalloc_h__
#include "git2_util.h"
#include "alloc.h"
int git_debugalloc_init_allocator(git_allocator *allocator);
#endif

View File

@ -12,11 +12,6 @@ static void *stdalloc__malloc(size_t len, const char *file, int line)
GIT_UNUSED(file);
GIT_UNUSED(line);
#ifdef GIT_DEBUG_STRICT_ALLOC
if (!len)
return NULL;
#endif
return malloc(len);
}
@ -25,11 +20,6 @@ static void *stdalloc__realloc(void *ptr, size_t size, const char *file, int lin
GIT_UNUSED(file);
GIT_UNUSED(line);
#ifdef GIT_DEBUG_STRICT_ALLOC
if (!size)
return NULL;
#endif
return realloc(ptr, size);
}

View File

@ -16,17 +16,35 @@
char *p_realpath(const char *pathname, char *resolved)
{
char *ret;
if ((ret = realpath(pathname, resolved)) == NULL)
char *result;
if ((result = realpath(pathname, resolved)) == NULL)
return NULL;
#ifdef __OpenBSD__
/* The OpenBSD realpath function behaves differently,
* figure out if the file exists */
if (access(ret, F_OK) < 0)
ret = NULL;
if (access(ret, F_OK) < 0) {
if (!resolved)
free(result);
return NULL;
}
#endif
return ret;
/*
* If resolved == NULL, the system has allocated the result
* string. We need to strdup this into _our_ allocator pool
* so that callers can free it with git__free.
*/
if (!resolved) {
char *dup = git__strdup(result);
free(result);
result = dup;
}
return result;
}
#endif

View File

@ -104,7 +104,5 @@ void cl_alloc_limit(size_t bytes)
void cl_alloc_reset(void)
{
git_allocator stdalloc;
git_stdalloc_init_allocator(&stdalloc);
git_allocator_setup(&stdalloc);
git_allocator_setup(NULL);
}

View File

@ -1095,7 +1095,7 @@ static void collect_progress(
if (path == NULL)
return;
git_vector_insert(paths, strdup(path));
git_vector_insert(paths, git__strdup(path));
}
void test_checkout_conflict__report_progress(void)

View File

@ -89,7 +89,7 @@ static void assert_name_is(const char *expected)
if (start)
cl_assert_equal_strn("/", actual + (start - 1), 1);
free(actual);
git__free(actual);
}
static int symlink_or_fake(git_repository *repo, const char *a, const char *b)

View File

@ -1235,7 +1235,7 @@ void test_checkout_tree__case_changing_rename(void)
cl_git_pass(git_signature_new(&signature, "Renamer", "rename@contoso.com", time(NULL), 0));
cl_git_pass(git_commit_create(&commit_id, g_repo, "refs/heads/dir", signature, signature, NULL, "case-changing rename", tree, 1, &dir_commit));
cl_git_pass(git_commit_create(&commit_id, g_repo, "refs/heads/dir", signature, signature, NULL, "case-changing rename", tree, 1, (const git_commit **)&dir_commit));
cl_assert(git_fs_path_isfile("testrepo/readme"));
if (case_sensitive)

View File

@ -77,7 +77,7 @@ void test_cherrypick_workdir__automerge(void)
cl_git_pass(git_index_write_tree(&cherrypicked_tree_oid, repo_index));
cl_git_pass(git_tree_lookup(&cherrypicked_tree, repo, &cherrypicked_tree_oid));
cl_git_pass(git_commit_create(&cherrypicked_oid, repo, "HEAD", signature, signature, NULL,
"Cherry picked!", cherrypicked_tree, 1, &head));
"Cherry picked!", cherrypicked_tree, 1, (const git_commit **)&head));
cl_assert(merge_test_index(repo_index, merge_index_entries + i * 3, 3));

View File

@ -36,11 +36,11 @@ void test_commit_commit__create_unexisting_update_ref(void)
cl_git_fail(git_reference_lookup(&ref, _repo, "refs/heads/foo/bar"));
cl_git_pass(git_commit_create(&oid, _repo, "refs/heads/foo/bar", s, s,
NULL, "some msg", tree, 1, &commit));
NULL, "some msg", tree, 1, (const git_commit **) &commit));
/* fail because the parent isn't the tip of the branch anymore */
cl_git_fail(git_commit_create(&oid, _repo, "refs/heads/foo/bar", s, s,
NULL, "some msg", tree, 1, &commit));
NULL, "some msg", tree, 1, (const git_commit **) &commit));
cl_git_pass(git_reference_lookup(&ref, _repo, "refs/heads/foo/bar"));
cl_assert_equal_oid(&oid, git_reference_target(ref));

View File

@ -118,7 +118,7 @@ void test_commit_write__into_buf(void)
cl_git_pass(git_commit_lookup(&parent, g_repo, &parent_id));
cl_git_pass(git_commit_create_buffer(&commit, g_repo, author, committer,
NULL, root_commit_message, tree, 1, &parent));
NULL, root_commit_message, tree, 1, (const git_commit **) &parent));
cl_assert_equal_s(commit.ptr,
"tree 1810dff58d8a660512d4832e740f692884338ccd\n\

View File

@ -424,7 +424,7 @@ void test_diff_rename__test_small_files(void)
cl_git_pass(git_index_write_tree(&oid, index));
cl_git_pass(git_tree_lookup(&commit_tree, g_repo, &oid));
cl_git_pass(git_signature_new(&signature, "Rename", "rename@example.com", 1404157834, 0));
cl_git_pass(git_commit_create(&oid, g_repo, "HEAD", signature, signature, NULL, "Test commit", commit_tree, 1, &head_commit));
cl_git_pass(git_commit_create(&oid, g_repo, "HEAD", signature, signature, NULL, "Test commit", commit_tree, 1, (const git_commit**)&head_commit));
cl_git_mkfile("renames/copy.txt", "Hello World!\n");
cl_git_rmfile("renames/small.txt");

View File

@ -125,7 +125,7 @@ void test_odb_freshen__tree_during_commit(void)
cl_git_pass(git_commit_create(&commit_id, repo, NULL,
signature, signature, NULL, "New commit pointing to old tree",
tree, 1, &parent));
tree, 1, (const git_commit **)&parent));
/* make sure we freshen the tree the commit points to */
cl_must_pass(p_lstat("testrepo.git/objects/" LOOSE_TREE_FN, &after));

View File

@ -26,7 +26,7 @@ static int create_cb_passthrough(
const char *message,
const git_tree *tree,
size_t parent_count,
git_commit * const parents[],
const git_commit *parents[],
void *payload)
{
GIT_UNUSED(out);
@ -94,7 +94,7 @@ static int create_cb_signed_gpg(
const char *message,
const git_tree *tree,
size_t parent_count,
git_commit * const parents[],
const git_commit *parents[],
void *payload)
{
git_buf commit_content = GIT_BUF_INIT;
@ -202,7 +202,7 @@ static int create_cb_error(
const char *message,
const git_tree *tree,
size_t parent_count,
git_commit * const parents[],
const git_commit *parents[],
void *payload)
{
GIT_UNUSED(out);

View File

@ -233,7 +233,7 @@ void test_refs_reflog_messages__show_merge_for_merge_commits(void)
cl_git_pass(git_commit_create(&merge_commit_oid,
g_repo, "HEAD", s, s, NULL,
"Merge commit", tree,
2, parent_commits));
2, (const struct git_commit **) parent_commits));
cl_reflog_check_entry(g_repo, GIT_HEAD_FILE, 0,
NULL,

View File

@ -40,10 +40,10 @@ void test_remote_fetch__cleanup(void) {
git_repository_free(repo2);
cl_git_pass(git_futils_rmdir_r(repo1_path, NULL, GIT_RMDIR_REMOVE_FILES));
free(repo1_path);
git__free(repo1_path);
cl_git_pass(git_futils_rmdir_r(repo2_path, NULL, GIT_RMDIR_REMOVE_FILES));
free(repo2_path);
git__free(repo2_path);
}

View File

@ -188,7 +188,7 @@ void test_revert_workdir__again(void)
cl_git_pass(git_tree_lookup(&reverted_tree, repo, &reverted_tree_oid));
cl_git_pass(git_signature_new(&signature, "Reverter", "reverter@example.org", time(NULL), 0));
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, &orig_head));
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, (const git_commit **)&orig_head));
cl_git_pass(git_revert(repo, orig_head, NULL));
cl_assert(merge_test_index(repo_index, merge_index_entries, 4));
@ -238,7 +238,7 @@ void test_revert_workdir__again_after_automerge(void)
cl_git_pass(git_tree_lookup(&reverted_tree, repo, &reverted_tree_oid));
cl_git_pass(git_signature_new(&signature, "Reverter", "reverter@example.org", time(NULL), 0));
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, &head));
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, (const git_commit **)&head));
cl_git_pass(git_revert(repo, commit, NULL));
cl_assert(merge_test_index(repo_index, second_revert_entries, 6));
@ -287,7 +287,7 @@ void test_revert_workdir__again_after_edit(void)
cl_git_pass(git_tree_lookup(&reverted_tree, repo, &reverted_tree_oid));
cl_git_pass(git_signature_new(&signature, "Reverter", "reverter@example.org", time(NULL), 0));
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, &orig_head));
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, (const git_commit **)&orig_head));
cl_git_pass(git_revert(repo, commit, NULL));
cl_assert(merge_test_index(repo_index, merge_index_entries, 4));

View File

@ -550,7 +550,8 @@ void test_revwalk_basic__big_timestamp(void)
cl_git_pass(git_signature_new(&sig, "Joe", "joe@example.com", INT64_C(2399662595), 0));
cl_git_pass(git_commit_tree(&tree, tip));
cl_git_pass(git_commit_create(&id, _repo, "HEAD", sig, sig, NULL, "some message", tree, 1, &tip));
cl_git_pass(git_commit_create(&id, _repo, "HEAD", sig, sig, NULL, "some message", tree, 1,
(const git_commit **)&tip));
cl_git_pass(git_revwalk_push_head(_walk));