diff --git a/CMakeLists.txt b/CMakeLists.txt index bb6cdf02d..8dfc6a8c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.5.1) -project(libgit2 VERSION "1.9.3" LANGUAGES C) +project(libgit2 VERSION "1.9.4" LANGUAGES C) # Add find modules to the path set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") diff --git a/deps/xdiff/CMakeLists.txt b/deps/xdiff/CMakeLists.txt index 743ac636f..82af0fad5 100644 --- a/deps/xdiff/CMakeLists.txt +++ b/deps/xdiff/CMakeLists.txt @@ -6,7 +6,7 @@ add_library(xdiff OBJECT ${SRC_XDIFF}) target_include_directories(xdiff SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/src/util" - "${PROJECT_BINARY_DIR}/src/util" + "${PROJECT_BINARY_DIR}/gen_headers" ${LIBGIT2_SYSTEM_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES}) diff --git a/docs/changelog.md b/docs/changelog.md index 0615565a4..a35e9068d 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,3 +1,17 @@ +v1.9.4 +------ + +This release includes a few small but important bugfixes. + +* cmake: separate generated headers from translated headers by + @ethomson in https://github.com/libgit2/libgit2/pull/7263 +* Avoid uninitialized variable warnings in gcc by @ethomson in + https://github.com/libgit2/libgit2/pull/7258 +* fix: Recognize relative worktrees extension by @cwill747 in + https://github.com/libgit2/libgit2/pull/7254 +* fix(sha256): thread-safety bug in builtin SHA-256 by @weihanglo in + https://github.com/libgit2/libgit2/pull/7266 + v1.9.3 ------ diff --git a/include/git2/version.h b/include/git2/version.h index 8b3d76c23..0df5418b8 100644 --- a/include/git2/version.h +++ b/include/git2/version.h @@ -21,7 +21,7 @@ GIT_BEGIN_DECL * The version string for libgit2. This string follows semantic * versioning (v2) guidelines. */ -#define LIBGIT2_VERSION "1.9.3" +#define LIBGIT2_VERSION "1.9.4" /** The major version number for this version of libgit2. */ #define LIBGIT2_VERSION_MAJOR 1 @@ -30,7 +30,7 @@ GIT_BEGIN_DECL #define LIBGIT2_VERSION_MINOR 9 /** The revision ("teeny") version number for this version of libgit2. */ -#define LIBGIT2_VERSION_REVISION 3 +#define LIBGIT2_VERSION_REVISION 4 /** The Windows DLL patch number for this version of libgit2. */ #define LIBGIT2_VERSION_PATCH 0 diff --git a/package.json b/package.json index 8740e9bd5..6c4fa6ac9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libgit2", - "version": "1.9.3", + "version": "1.9.4", "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/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index d121c588a..517ede8ca 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -1,9 +1,8 @@ set(CLI_INCLUDES - "${libgit2_BINARY_DIR}/src/util" - "${libgit2_BINARY_DIR}/include" "${libgit2_SOURCE_DIR}/src/util" "${libgit2_SOURCE_DIR}/src/cli" "${libgit2_SOURCE_DIR}/include" + "${libgit2_BINARY_DIR}/gen_headers" "${LIBGIT2_DEPENDENCY_INCLUDES}" "${LIBGIT2_SYSTEM_INCLUDES}") diff --git a/src/cli/opt.c b/src/cli/opt.c index c0880248e..c5def1930 100644 --- a/src/cli/opt.c +++ b/src/cli/opt.c @@ -359,7 +359,7 @@ GIT_INLINE(const cli_opt_spec *) spec_for_sort( const char *arg) { int is_negated, has_value = 0; - const char *value; + const char *value = NULL; const cli_opt_spec *spec = NULL; size_t idx = 0; diff --git a/src/libgit2/CMakeLists.txt b/src/libgit2/CMakeLists.txt index 6b76afbe6..8045ddef9 100644 --- a/src/libgit2/CMakeLists.txt +++ b/src/libgit2/CMakeLists.txt @@ -7,11 +7,10 @@ include(PkgBuildConfig) include(CMakePackageConfigHelpers) set(LIBGIT2_INCLUDES - "${PROJECT_BINARY_DIR}/src/util" - "${PROJECT_BINARY_DIR}/include" "${PROJECT_SOURCE_DIR}/src/libgit2" "${PROJECT_SOURCE_DIR}/src/util" - "${PROJECT_SOURCE_DIR}/include") + "${PROJECT_SOURCE_DIR}/include" + "${PROJECT_BINARY_DIR}/gen_headers") # Collect sourcefiles file(GLOB SRC_H @@ -41,7 +40,11 @@ ide_split_sources(libgit2) list(APPEND LIBGIT2_OBJECTS $ $ ${LIBGIT2_DEPENDENCY_OBJECTS}) list(APPEND LIBGIT2_INCLUDES ${LIBGIT2_DEPENDENCY_INCLUDES}) -target_include_directories(libgit2 PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES} PUBLIC ${PROJECT_SOURCE_DIR}/include) +target_include_directories(libgit2 + PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES} + PUBLIC $ + $) + target_include_directories(libgit2 SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES}) set(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE) @@ -55,6 +58,12 @@ set(LIBGIT2_SYSTEM_LIBS ${LIBGIT2_SYSTEM_LIBS} PARENT_SCOPE) # Compile and link libgit2 # +if (NOT BUILD_SHARED_LIBS AND XCODE_VERSION) + # This is required for Xcode to actually create the static libgit2 library + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.c "") + list(APPEND LIBGIT2_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/dummy.c) +endif() + add_library(libgit2package ${SRC_RC} ${LIBGIT2_OBJECTS}) target_link_libraries(libgit2package ${LIBGIT2_SYSTEM_LIBS}) target_include_directories(libgit2package SYSTEM PRIVATE ${LIBGIT2_INCLUDES}) @@ -94,15 +103,23 @@ endif() # support experimental features and functionality -configure_file(experimental.h.in "${PROJECT_BINARY_DIR}/include/git2/experimental.h") +configure_file(experimental.h.in "${PROJECT_BINARY_DIR}/gen_headers/experimental.h") -# translate filenames in the git2.h so that they match the install directory +# translate filenames in the headers so that they match the install directory # (allows for side-by-side installs of libgit2 and libgit2-experimental.) -file(READ "${PROJECT_SOURCE_DIR}/include/git2.h" LIBGIT2_INCLUDE) -string(REGEX REPLACE "#include \"git2\/" "#include \"${LIBGIT2_FILENAME}/" LIBGIT2_INCLUDE "${LIBGIT2_INCLUDE}") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${LIBGIT2_FILENAME}.h.tmp" ${LIBGIT2_INCLUDE}) -configure_file("${CMAKE_CURRENT_BINARY_DIR}/${LIBGIT2_FILENAME}.h.tmp" "${PROJECT_BINARY_DIR}/include/${LIBGIT2_FILENAME}.h" COPYONLY) +foreach(HEADER_SOURCE ${SRC_H}) + file(RELATIVE_PATH HEADER_RELATIVE ${PROJECT_SOURCE_DIR} ${HEADER_SOURCE}) + string(REGEX REPLACE "^include\/git2" "include/${LIBGIT2_FILENAME}" HEADER_RELATIVE ${HEADER_RELATIVE}) + + file(READ "${HEADER_SOURCE}" HEADER_CONTENTS) + string(REGEX REPLACE "#include \"git2\/" "#include \"${LIBGIT2_FILENAME}/" HEADER_CONTENTS "${HEADER_CONTENTS}") + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${HEADER_RELATIVE}.tmp" "${HEADER_CONTENTS}") + configure_file("${CMAKE_CURRENT_BINARY_DIR}/${HEADER_RELATIVE}.tmp" "${PROJECT_BINARY_DIR}/${HEADER_RELATIVE}" COPYONLY) +endforeach() + +configure_file("${PROJECT_BINARY_DIR}/gen_headers/experimental.h" "${PROJECT_BINARY_DIR}/include/${LIBGIT2_FILENAME}/experimental.h" COPYONLY) # cmake package targets @@ -133,9 +150,7 @@ install(TARGETS libgit2package RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/git2/ - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBGIT2_FILENAME}") -install(FILES ${PROJECT_BINARY_DIR}/include/git2/experimental.h - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBGIT2_FILENAME}") install(FILES "${PROJECT_BINARY_DIR}/include/${LIBGIT2_FILENAME}.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(DIRECTORY "${PROJECT_BINARY_DIR}/include/${LIBGIT2_FILENAME}" + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/src/libgit2/index.c b/src/libgit2/index.c index 2ea8f0c4b..9b0c746ca 100644 --- a/src/libgit2/index.c +++ b/src/libgit2/index.c @@ -1225,7 +1225,7 @@ static int canonicalize_directory_path( { const git_index_entry *match, *best = NULL; char *search, *sep; - size_t pos, search_len, best_len; + size_t pos, search_len, best_len = 0; if (!index->ignore_case) return 0; diff --git a/src/libgit2/midx.c b/src/libgit2/midx.c index 939e667be..6d90e4af6 100644 --- a/src/libgit2/midx.c +++ b/src/libgit2/midx.c @@ -460,7 +460,7 @@ int git_midx_foreach_entry( { git_oid oid; size_t oid_size, i; - int error; + int error = 0; GIT_ASSERT_ARG(idx); diff --git a/src/libgit2/repository.c b/src/libgit2/repository.c index 6c86c2de5..9fed12cd7 100644 --- a/src/libgit2/repository.c +++ b/src/libgit2/repository.c @@ -1865,7 +1865,8 @@ static const char *builtin_extensions[] = { "noop", "objectformat", "worktreeconfig", - "preciousobjects" + "preciousobjects", + "relativeworktrees" }; static git_vector user_extensions = { 0, git__strcmp_cb }; diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 3692dc3d3..062e0c6c8 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -2,13 +2,12 @@ add_library(util OBJECT) -configure_file(git2_features.h.in git2_features.h) +configure_file(git2_features.h.in "${PROJECT_BINARY_DIR}/gen_headers/git2_features.h") set(UTIL_INCLUDES - "${PROJECT_BINARY_DIR}/src/util" - "${PROJECT_BINARY_DIR}/include" "${PROJECT_SOURCE_DIR}/src/util" - "${PROJECT_SOURCE_DIR}/include") + "${PROJECT_SOURCE_DIR}/include" + "${PROJECT_BINARY_DIR}/gen_headers") file(GLOB UTIL_SRC *.c *.h allocators/*.c allocators/*.h hash.h) list(SORT UTIL_SRC) diff --git a/src/util/hash/rfc6234/sha224-256.c b/src/util/hash/rfc6234/sha224-256.c index c8e0cf854..ad965347f 100644 --- a/src/util/hash/rfc6234/sha224-256.c +++ b/src/util/hash/rfc6234/sha224-256.c @@ -83,12 +83,14 @@ * Add "length" to the length. * Set Corrupted when overflow has occurred. */ -static uint32_t addTemp; -#define SHA224_256AddLength(context, length) \ - (addTemp = (context)->Length_Low, (context)->Corrupted = \ - (((context)->Length_Low += (length)) < addTemp) && \ - (++(context)->Length_High == 0) ? shaInputTooLong : \ - (context)->Corrupted ) +static int SHA224_256AddLength(SHA256Context *context, unsigned int length) +{ + uint32_t addTemp = context->Length_Low; + context->Length_Low += length; + if (context->Length_Low < addTemp && ++context->Length_High == 0) + context->Corrupted = shaInputTooLong; + return context->Corrupted; +} /* Local Function Prototypes */ static int SHA224_256Reset(SHA256Context *context, uint32_t *H0); diff --git a/src/util/hashmap.h b/src/util/hashmap.h index c29844f38..e34052776 100644 --- a/src/util/hashmap.h +++ b/src/util/hashmap.h @@ -107,6 +107,7 @@ typedef uint32_t git_hashmap_iter_t; } \ GIT_INLINE(int) name##__idx(uint32_t *out, name *h, key_t key) \ { \ + *out = UINT32_MAX; \ if (h->n_buckets) { \ uint32_t k, i, last, mask, step = 0; \ GIT_ASSERT((h)->flags); \ diff --git a/src/util/runtime.c b/src/util/runtime.c index a7711ffc4..ff3037bb6 100644 --- a/src/util/runtime.c +++ b/src/util/runtime.c @@ -16,7 +16,7 @@ static git_atomic32 init_count; static int init_common(git_runtime_init_fn init_fns[], size_t cnt) { size_t i; - int ret; + int ret = 0; /* Initialize subsystems that have global state */ for (i = 0; i < cnt; i++) { @@ -110,7 +110,7 @@ GIT_INLINE(int) init_unlock(void) int git_runtime_init(git_runtime_init_fn init_fns[], size_t cnt) { - int ret; + int ret = 0; if (init_lock() < 0) return -1; diff --git a/tests/libgit2/core/opts.c b/tests/libgit2/core/opts.c index 1580fb2f5..9fc94f96f 100644 --- a/tests/libgit2/core/opts.c +++ b/tests/libgit2/core/opts.c @@ -34,11 +34,12 @@ void test_core_opts__extensions_query(void) cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out)); - cl_assert_equal_sz(out.count, 4); + cl_assert_equal_sz(out.count, 5); cl_assert_equal_s("noop", out.strings[0]); cl_assert_equal_s("objectformat", out.strings[1]); cl_assert_equal_s("preciousobjects", out.strings[2]); - cl_assert_equal_s("worktreeconfig", out.strings[3]); + cl_assert_equal_s("relativeworktrees", out.strings[3]); + cl_assert_equal_s("worktreeconfig", out.strings[4]); git_strarray_dispose(&out); } @@ -51,12 +52,13 @@ void test_core_opts__extensions_add(void) cl_git_pass(git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, in, ARRAY_SIZE(in))); cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out)); - cl_assert_equal_sz(out.count, 5); + cl_assert_equal_sz(out.count, 6); cl_assert_equal_s("foo", out.strings[0]); cl_assert_equal_s("noop", out.strings[1]); cl_assert_equal_s("objectformat", out.strings[2]); cl_assert_equal_s("preciousobjects", out.strings[3]); - cl_assert_equal_s("worktreeconfig", out.strings[4]); + cl_assert_equal_s("relativeworktrees", out.strings[4]); + cl_assert_equal_s("worktreeconfig", out.strings[5]); git_strarray_dispose(&out); } @@ -69,12 +71,13 @@ void test_core_opts__extensions_remove(void) cl_git_pass(git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, in, ARRAY_SIZE(in))); cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out)); - cl_assert_equal_sz(out.count, 5); + cl_assert_equal_sz(out.count, 6); cl_assert_equal_s("bar", out.strings[0]); cl_assert_equal_s("baz", out.strings[1]); cl_assert_equal_s("objectformat", out.strings[2]); cl_assert_equal_s("preciousobjects", out.strings[3]); - cl_assert_equal_s("worktreeconfig", out.strings[4]); + cl_assert_equal_s("relativeworktrees", out.strings[4]); + cl_assert_equal_s("worktreeconfig", out.strings[5]); git_strarray_dispose(&out); } @@ -87,13 +90,14 @@ void test_core_opts__extensions_uniq(void) cl_git_pass(git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, in, ARRAY_SIZE(in))); cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out)); - cl_assert_equal_sz(out.count, 6); + cl_assert_equal_sz(out.count, 7); cl_assert_equal_s("bar", out.strings[0]); cl_assert_equal_s("foo", out.strings[1]); cl_assert_equal_s("noop", out.strings[2]); cl_assert_equal_s("objectformat", out.strings[3]); cl_assert_equal_s("preciousobjects", out.strings[4]); - cl_assert_equal_s("worktreeconfig", out.strings[5]); + cl_assert_equal_s("relativeworktrees", out.strings[5]); + cl_assert_equal_s("worktreeconfig", out.strings[6]); git_strarray_dispose(&out); } diff --git a/tests/libgit2/repo/extensions.c b/tests/libgit2/repo/extensions.c index cb62c53a8..5b70c8bff 100644 --- a/tests/libgit2/repo/extensions.c +++ b/tests/libgit2/repo/extensions.c @@ -80,3 +80,13 @@ void test_repo_extensions__preciousobjects(void) cl_git_pass(git_repository_open(&extended, "empty_bare.git")); git_repository_free(extended); } + +void test_repo_extensions__relativeworktrees(void) +{ + git_repository *extended = NULL; + + cl_repo_set_string(repo, "extensions.relativeWorktrees", "true"); + + cl_git_pass(git_repository_open(&extended, "empty_bare.git")); + git_repository_free(extended); +}