From 54c37f5d207104bd8e39c904a9f75a8279473237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20R=C3=B6hling?= Date: Sun, 15 Sep 2024 09:52:10 +0200 Subject: [PATCH] New upstream version 1.8.2~rc1+ds --- CMakeLists.txt | 2 +- README.md | 8 +-- docs/changelog.md | 26 ++++++++++ examples/merge.c | 2 +- include/git2/commit.h | 6 +-- include/git2/version.h | 4 +- package.json | 2 +- src/libgit2/commit.c | 11 +++-- src/libgit2/commit.h | 2 +- src/libgit2/notes.c | 4 +- src/libgit2/rebase.c | 9 ++-- src/libgit2/stash.c | 4 +- src/util/alloc.c | 5 +- src/util/allocators/debugalloc.c | 73 ++++++++++++++++++++++++++++ src/util/allocators/debugalloc.h | 17 +++++++ src/util/allocators/stdalloc.c | 10 ---- src/util/unix/realpath.c | 28 +++++++++-- tests/clar/clar_libgit2_alloc.c | 4 +- tests/libgit2/checkout/conflict.c | 2 +- tests/libgit2/checkout/icase.c | 2 +- tests/libgit2/checkout/tree.c | 2 +- tests/libgit2/cherrypick/workdir.c | 2 +- tests/libgit2/commit/commit.c | 4 +- tests/libgit2/commit/write.c | 2 +- tests/libgit2/diff/rename.c | 2 +- tests/libgit2/odb/freshen.c | 2 +- tests/libgit2/rebase/sign.c | 6 +-- tests/libgit2/refs/reflog/messages.c | 2 +- tests/libgit2/remote/fetch.c | 4 +- tests/libgit2/revert/workdir.c | 6 +-- tests/libgit2/revwalk/basic.c | 3 +- 31 files changed, 192 insertions(+), 64 deletions(-) create mode 100644 src/util/allocators/debugalloc.c create mode 100644 src/util/allocators/debugalloc.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ca8882a0..578ec1777 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/README.md b/README.md index 77efdd4a6..0f492d144 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/changelog.md b/docs/changelog.md index a35a389a4..fe12271f3 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -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 ------ diff --git a/examples/merge.c b/examples/merge.c index 718c767d0..7a76912cd 100644 --- a/examples/merge.c +++ b/examples/merge.c @@ -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 */ diff --git a/include/git2/commit.h b/include/git2/commit.h index ef38c66e6..88c21e0c9 100644 --- a/include/git2/commit.h +++ b/include/git2/commit.h @@ -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 */ diff --git a/include/git2/version.h b/include/git2/version.h index 33c96254c..60675c88b 100644 --- a/include/git2/version.h +++ b/include/git2/version.h @@ -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 diff --git a/package.json b/package.json index 6c1cb286e..df10dee27 100644 --- a/package.json +++ b/package.json @@ -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 ." diff --git a/src/libgit2/commit.c b/src/libgit2/commit.c index 47f6fed89..10df43623 100644 --- a/src/libgit2/commit.c +++ b/src/libgit2/commit.c @@ -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); diff --git a/src/libgit2/commit.h b/src/libgit2/commit.h index 53128ba5d..c25fee327 100644 --- a/src/libgit2/commit.h +++ b/src/libgit2/commit.h @@ -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, diff --git a/src/libgit2/notes.c b/src/libgit2/notes.c index 2dd194581..13ca3824b 100644 --- a/src/libgit2/notes.c +++ b/src/libgit2/notes.c @@ -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; diff --git a/src/libgit2/rebase.c b/src/libgit2/rebase.c index 2fce3e7bc..77e442e98 100644 --- a/src/libgit2/rebase.c +++ b/src/libgit2/rebase.c @@ -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; diff --git a/src/libgit2/stash.c b/src/libgit2/stash.c index a0a72deac..b49e95cdb 100644 --- a/src/libgit2/stash.c +++ b/src/libgit2/stash.c @@ -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; diff --git a/src/util/alloc.c b/src/util/alloc.c index 6ec173d04..998b0aea1 100644 --- a/src/util/alloc.c +++ b/src/util/alloc.c @@ -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 diff --git a/src/util/allocators/debugalloc.c b/src/util/allocators/debugalloc.c new file mode 100644 index 000000000..44022cd78 --- /dev/null +++ b/src/util/allocators/debugalloc.c @@ -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; +} diff --git a/src/util/allocators/debugalloc.h b/src/util/allocators/debugalloc.h new file mode 100644 index 000000000..dea0ca31c --- /dev/null +++ b/src/util/allocators/debugalloc.h @@ -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 diff --git a/src/util/allocators/stdalloc.c b/src/util/allocators/stdalloc.c index f2d72a7e6..65ec40fbe 100644 --- a/src/util/allocators/stdalloc.c +++ b/src/util/allocators/stdalloc.c @@ -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); } diff --git a/src/util/unix/realpath.c b/src/util/unix/realpath.c index 9e31a63b9..e1d2adb8d 100644 --- a/src/util/unix/realpath.c +++ b/src/util/unix/realpath.c @@ -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 diff --git a/tests/clar/clar_libgit2_alloc.c b/tests/clar/clar_libgit2_alloc.c index e93037923..54eacd543 100644 --- a/tests/clar/clar_libgit2_alloc.c +++ b/tests/clar/clar_libgit2_alloc.c @@ -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); } diff --git a/tests/libgit2/checkout/conflict.c b/tests/libgit2/checkout/conflict.c index b2eb939dc..3539c8b2d 100644 --- a/tests/libgit2/checkout/conflict.c +++ b/tests/libgit2/checkout/conflict.c @@ -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) diff --git a/tests/libgit2/checkout/icase.c b/tests/libgit2/checkout/icase.c index d77c7abd5..3769a9f9b 100644 --- a/tests/libgit2/checkout/icase.c +++ b/tests/libgit2/checkout/icase.c @@ -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) diff --git a/tests/libgit2/checkout/tree.c b/tests/libgit2/checkout/tree.c index 97935aaea..65df00cd8 100644 --- a/tests/libgit2/checkout/tree.c +++ b/tests/libgit2/checkout/tree.c @@ -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) diff --git a/tests/libgit2/cherrypick/workdir.c b/tests/libgit2/cherrypick/workdir.c index 9d9a3f497..c16b7814a 100644 --- a/tests/libgit2/cherrypick/workdir.c +++ b/tests/libgit2/cherrypick/workdir.c @@ -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)); diff --git a/tests/libgit2/commit/commit.c b/tests/libgit2/commit/commit.c index 923740f23..140f87d0c 100644 --- a/tests/libgit2/commit/commit.c +++ b/tests/libgit2/commit/commit.c @@ -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)); diff --git a/tests/libgit2/commit/write.c b/tests/libgit2/commit/write.c index d38b54d20..890f7384b 100644 --- a/tests/libgit2/commit/write.c +++ b/tests/libgit2/commit/write.c @@ -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\ diff --git a/tests/libgit2/diff/rename.c b/tests/libgit2/diff/rename.c index 15dee5c97..61a2f839c 100644 --- a/tests/libgit2/diff/rename.c +++ b/tests/libgit2/diff/rename.c @@ -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"); diff --git a/tests/libgit2/odb/freshen.c b/tests/libgit2/odb/freshen.c index d0e0e3c3c..e337c82b7 100644 --- a/tests/libgit2/odb/freshen.c +++ b/tests/libgit2/odb/freshen.c @@ -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)); diff --git a/tests/libgit2/rebase/sign.c b/tests/libgit2/rebase/sign.c index 45bac29d0..69bb1c6f9 100644 --- a/tests/libgit2/rebase/sign.c +++ b/tests/libgit2/rebase/sign.c @@ -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); diff --git a/tests/libgit2/refs/reflog/messages.c b/tests/libgit2/refs/reflog/messages.c index 4a2ecb02a..647c00d0d 100644 --- a/tests/libgit2/refs/reflog/messages.c +++ b/tests/libgit2/refs/reflog/messages.c @@ -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, diff --git a/tests/libgit2/remote/fetch.c b/tests/libgit2/remote/fetch.c index a5d3272c5..7d2d11e27 100644 --- a/tests/libgit2/remote/fetch.c +++ b/tests/libgit2/remote/fetch.c @@ -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); } diff --git a/tests/libgit2/revert/workdir.c b/tests/libgit2/revert/workdir.c index 6d74254e5..3e790b77f 100644 --- a/tests/libgit2/revert/workdir.c +++ b/tests/libgit2/revert/workdir.c @@ -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)); diff --git a/tests/libgit2/revwalk/basic.c b/tests/libgit2/revwalk/basic.c index 5c5340505..41090a1da 100644 --- a/tests/libgit2/revwalk/basic.c +++ b/tests/libgit2/revwalk/basic.c @@ -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));