From 90fcfb5ed0c666ad977c6a7fce93528212b9da8f Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 23 Jan 2023 16:52:07 +0100 Subject: libgit2: Update to v1.2.0 --- etc/import/include/git2/TARGETS.git2 | 4 +- etc/import/src/TARGETS.git2 | 41 ++++--- etc/patches/libgit2_v1.1.0_fix-fake-repo.patch | 146 ------------------------ etc/patches/libgit2_v1.2.0_fix-fake-repo.patch | 148 +++++++++++++++++++++++++ etc/repos.json | 10 +- 5 files changed, 183 insertions(+), 166 deletions(-) delete mode 100644 etc/patches/libgit2_v1.1.0_fix-fake-repo.patch create mode 100644 etc/patches/libgit2_v1.2.0_fix-fake-repo.patch diff --git a/etc/import/include/git2/TARGETS.git2 b/etc/import/include/git2/TARGETS.git2 index a9dad131..00d78cb0 100644 --- a/etc/import/include/git2/TARGETS.git2 +++ b/etc/import/include/git2/TARGETS.git2 @@ -146,7 +146,7 @@ , "sys/repository.h": { "type": ["@", "rules", "patch", "file"] , "src": [["FILE", null, "sys/repository.h"]] - , "patch": [["@", "patches", "", "libgit2_v1.1.0_fix-fake-repo.patch"]] + , "patch": [["@", "patches", "", "libgit2_v1.2.0_fix-fake-repo.patch"]] , "patch-part": ["a", "include", "git2", "sys", "repository.h"] } , "TREE": @@ -221,6 +221,7 @@ , "worktree.h" , "sys/alloc.h" , "sys/commit.h" + , "sys/commit_graph.h" , "sys/config.h" , "sys/credential.h" , "sys/cred.h" @@ -230,6 +231,7 @@ , "sys/index.h" , "sys/mempack.h" , "sys/merge.h" + , "sys/midx.h" , "sys/odb_backend.h" , "sys/openssl.h" , "sys/path.h" diff --git a/etc/import/src/TARGETS.git2 b/etc/import/src/TARGETS.git2 index ef98f2ca..bfa3543c 100644 --- a/etc/import/src/TARGETS.git2 +++ b/etc/import/src/TARGETS.git2 @@ -15,12 +15,12 @@ , "blob.h" , "branch.h" , "buffer.h" - , "buf_text.h" , "cache.h" , "cc-compat.h" , "checkout.h" , "clone.h" , "commit.h" + , "commit_graph.h" , "commit_list.h" , "common.h" , "config_backend.h" @@ -41,7 +41,6 @@ , "filebuf.h" , "filter.h" , "futils.h" - , "global.h" , "hash.h" , "idxmap.h" , "ignore.h" @@ -50,6 +49,7 @@ , "integer.h" , "iterator.h" , "khash.h" + , "libgit2.h" , "mailmap.h" , "map.h" , "merge_driver.h" @@ -89,6 +89,8 @@ , "repository.h" , "repo_template.h" , "revwalk.h" + , "runtime.h" + , "settings.h" , "signature.h" , "sortedcache.h" , "status.h" @@ -98,28 +100,36 @@ , "submodule.h" , "sysdir.h" , "tag.h" - , "thread-utils.h" + , "thread.h" + , "threadstate.h" , "trace.h" , "transaction.h" , "tree-cache.h" , "tree.h" , "userdiff.h" + , "utf8.h" , "util.h" , "varint.h" , "vector.h" , "wildmatch.h" , "worktree.h" , "zstream.h" + , "allocators/failalloc.h" , "allocators/stdalloc.h" - , "allocators/win32_crtdbg.h" + , "allocators/win32_leakcheck.h" , "hash/sha1.h" + , "hash/sha1/collisiondetect.h" , "hash/sha1/common_crypto.h" , "hash/sha1/generic.h" , "hash/sha1/mbedtls.h" , "hash/sha1/openssl.h" , "hash/sha1/win32.h" + , "hash/sha1/sha1dc/sha1.h" + , "hash/sha1/sha1dc/ubc_check.h" , "streams/mbedtls.h" , "streams/openssl.h" + , "streams/openssl_dynamic.h" + , "streams/openssl_legacy.h" , "streams/registry.h" , "streams/socket.h" , "streams/stransport.h" @@ -147,8 +157,7 @@ , "win32/version.h" , "win32/w32_buffer.h" , "win32/w32_common.h" - , "win32/w32_crtdbg_stacktrace.h" - , "win32/w32_stack.h" + , "win32/w32_leakcheck.h" , "win32/w32_util.h" , "win32/win32-compat.h" , "xdiff/xdiff.h" @@ -202,8 +211,7 @@ , "win32/thread.c" , "win32/utf-conv.c" , "win32/w32_buffer.c" - , "win32/w32_crtdbg_stacktrace.c" - , "win32/w32_stack.c" + , "win32/w32_leakcheck.c" , "win32/w32_util.c" ] , "private-hdrs": ["git2_private_headers"] @@ -519,7 +527,7 @@ , "repository.c": { "type": ["@", "rules", "patch", "file"] , "src": [["FILE", null, "repository.c"]] - , "patch": [["@", "patches", "", "libgit2_v1.1.0_fix-fake-repo.patch"]] + , "patch": [["@", "patches", "", "libgit2_v1.2.0_fix-fake-repo.patch"]] , "patch-part": ["a", "src", "repository.c"] } , "git2internal": @@ -558,12 +566,12 @@ , "blob.c" , "branch.c" , "buffer.c" - , "buf_text.c" , "cache.c" , "checkout.c" , "cherrypick.c" , "clone.c" , "commit.c" + , "commit_graph.c" , "commit_list.c" , "config.c" , "config_cache.c" @@ -591,7 +599,6 @@ , "filebuf.c" , "filter.c" , "futils.c" - , "global.c" , "graph.c" , "hash.c" , "hashsig.c" @@ -601,6 +608,7 @@ , "index.c" , "indexer.c" , "iterator.c" + , "libgit2.c" , "mailmap.c" , "merge.c" , "merge_driver.c" @@ -648,7 +656,7 @@ , "revert.c" , "revparse.c" , "revwalk.c" - , "settings.c" + , "runtime.c" , "signature.c" , "sortedcache.c" , "stash.c" @@ -658,7 +666,8 @@ , "submodule.c" , "sysdir.c" , "tag.c" - , "thread-utils.c" + , "thread.c" + , "threadstate.c" , "trace.c" , "trailer.c" , "transaction.c" @@ -666,16 +675,20 @@ , "tree.c" , "tree-cache.c" , "tsort.c" + , "utf8.c" , "util.c" , "varint.c" , "vector.c" , "wildmatch.c" , "worktree.c" , "zstream.c" + , "allocators/failalloc.c" , "allocators/stdalloc.c" - , "allocators/win32_crtdbg.c" + , "allocators/win32_leakcheck.c" , "streams/mbedtls.c" , "streams/openssl.c" + , "streams/openssl_dynamic.c" + , "streams/openssl_legacy.c" , "streams/registry.c" , "streams/socket.c" , "streams/stransport.c" diff --git a/etc/patches/libgit2_v1.1.0_fix-fake-repo.patch b/etc/patches/libgit2_v1.1.0_fix-fake-repo.patch deleted file mode 100644 index 85bab5a6..00000000 --- a/etc/patches/libgit2_v1.1.0_fix-fake-repo.patch +++ /dev/null @@ -1,146 +0,0 @@ -From bf27a288adce36e2a57e26146d18c224ebc745be Mon Sep 17 00:00:00 2001 -From: Oliver Reiche -Date: Wed, 3 Aug 2022 16:27:58 +0200 -Subject: [PATCH] Do not register fake repository as owner of ODB - -Accessing ODB is guaranteed to be thread-safe. Registering a -fake repository (created via git_repository_wrap_odb()) may -not register itself as owner of the ODB in order to maintain -that guarantee. Otherwise, accessing objects from ODB will -try to obtain the cache from the owning repository (via -odb_cache()) and produce a race if this ODB is concurrently -used to create fake repositories in other threads. -Consequently, operations on fake repositories will interact -with the ODB's cache instead of the repository's cache. ---- - include/git2/sys/repository.h | 3 ++- - src/repository.c | 16 +++++++++------- - tests/odb/backend/nobackend.c | 2 +- - tests/repo/setters.c | 23 ++++++++++++++++++++++- - 4 files changed, 34 insertions(+), 10 deletions(-) - -diff --git a/include/git2/sys/repository.h b/include/git2/sys/repository.h -index 892be6692..33bc5051f 100644 ---- a/include/git2/sys/repository.h -+++ b/include/git2/sys/repository.h -@@ -97,9 +97,10 @@ GIT_EXTERN(int) git_repository_set_config(git_repository *repo, git_config *conf - * - * @param repo A repository object - * @param odb An ODB object -+ * @param set_owner Register repository as owner of ODB - * @return 0 on success, or an error code - */ --GIT_EXTERN(int) git_repository_set_odb(git_repository *repo, git_odb *odb); -+GIT_EXTERN(int) git_repository_set_odb(git_repository *repo, git_odb *odb, bool set_owner); - - /** - * Set the Reference Database Backend for this repository -diff --git a/src/repository.c b/src/repository.c -index 513dbd61f..9e5aa6a16 100644 ---- a/src/repository.c -+++ b/src/repository.c -@@ -86,10 +86,12 @@ git_buf git_repository__reserved_names_posix[] = { - }; - size_t git_repository__reserved_names_posix_len = 1; - --static void set_odb(git_repository *repo, git_odb *odb) -+static void set_odb(git_repository *repo, git_odb *odb, bool set_owner) - { - if (odb) { -- GIT_REFCOUNT_OWN(odb, repo); -+ if (set_owner) { -+ GIT_REFCOUNT_OWN(odb, repo); -+ } - GIT_REFCOUNT_INC(odb); - } - -@@ -150,7 +152,7 @@ int git_repository__cleanup(git_repository *repo) - - set_config(repo, NULL); - set_index(repo, NULL); -- set_odb(repo, NULL); -+ set_odb(repo, NULL, /*set_owner=*/true); - set_refdb(repo, NULL); - - return 0; -@@ -722,7 +724,7 @@ static int _git_repository_open_ext_from_env( - goto error; - - if (odb) -- git_repository_set_odb(repo, odb); -+ git_repository_set_odb(repo, odb, /*set_owner=*/true); - - error = git__getenv(&alts_buf, "GIT_ALTERNATE_OBJECT_DIRECTORIES"); - if (error == GIT_ENOTFOUND) { -@@ -932,7 +934,7 @@ int git_repository_wrap_odb(git_repository **repo_out, git_odb *odb) - repo = repository_alloc(); - GIT_ERROR_CHECK_ALLOC(repo); - -- git_repository_set_odb(repo, odb); -+ git_repository_set_odb(repo, odb, /*set_owner=*/false); - *repo_out = repo; - - return 0; -@@ -1139,10 +1141,10 @@ int git_repository_odb(git_odb **out, git_repository *repo) - return 0; - } - --int git_repository_set_odb(git_repository *repo, git_odb *odb) -+int git_repository_set_odb(git_repository *repo, git_odb *odb, bool set_owner) - { - assert(repo && odb); -- set_odb(repo, odb); -+ set_odb(repo, odb, set_owner); - return 0; - } - -diff --git a/tests/odb/backend/nobackend.c b/tests/odb/backend/nobackend.c -index 7484d423b..d46a7fed9 100644 ---- a/tests/odb/backend/nobackend.c -+++ b/tests/odb/backend/nobackend.c -@@ -16,7 +16,7 @@ void test_odb_backend_nobackend__initialize(void) - cl_git_pass(git_refdb_new(&refdb, _repo)); - - git_repository_set_config(_repo, config); -- git_repository_set_odb(_repo, odb); -+ git_repository_set_odb(_repo, odb, /*set_owner=*/true); - git_repository_set_refdb(_repo, refdb); - - /* The set increases the refcount and we don't want them anymore */ -diff --git a/tests/repo/setters.c b/tests/repo/setters.c -index 1fac627f6..bf1b31783 100644 ---- a/tests/repo/setters.c -+++ b/tests/repo/setters.c -@@ -94,7 +94,28 @@ void test_repo_setters__setting_a_new_odb_on_a_repo_which_already_loaded_one_pro - cl_git_pass(git_odb_open(&new_odb, "./testrepo.git/objects")); - cl_assert(((git_refcount *)new_odb)->refcount.val == 1); - -- git_repository_set_odb(repo, new_odb); -+ git_repository_set_odb(repo, new_odb, /*set_owner=*/true); -+ cl_assert(((git_refcount *)new_odb)->refcount.val == 2); -+ -+ git_repository_free(repo); -+ cl_assert(((git_refcount *)new_odb)->refcount.val == 1); -+ -+ git_odb_free(new_odb); -+ -+ /* -+ * Ensure the cleanup method won't try to free the repo as it's already been taken care of -+ */ -+ repo = NULL; -+} -+ -+void test_repo_setters__setting_a_new_odb_on_a_non_owner_repo_which_already_loaded_one_properly_honors_the_refcount(void) -+{ -+ git_odb *new_odb; -+ -+ cl_git_pass(git_odb_open(&new_odb, "./testrepo.git/objects")); -+ cl_assert(((git_refcount *)new_odb)->refcount.val == 1); -+ -+ git_repository_set_odb(repo, new_odb, /*set_owner=*/false); - cl_assert(((git_refcount *)new_odb)->refcount.val == 2); - - git_repository_free(repo); --- -2.25.1 - diff --git a/etc/patches/libgit2_v1.2.0_fix-fake-repo.patch b/etc/patches/libgit2_v1.2.0_fix-fake-repo.patch new file mode 100644 index 00000000..22490c12 --- /dev/null +++ b/etc/patches/libgit2_v1.2.0_fix-fake-repo.patch @@ -0,0 +1,148 @@ +From 1a4497d0aa05b48c40d939713a48bdf78dfa29e9 Mon Sep 17 00:00:00 2001 +From: Oliver Reiche +Date: Wed, 3 Aug 2022 16:27:58 +0200 +Subject: [PATCH] Do not register fake repository as owner of ODB + +Accessing ODB is guaranteed to be thread-safe. Registering a +fake repository (created via git_repository_wrap_odb()) may +not register itself as owner of the ODB in order to maintain +that guarantee. Otherwise, accessing objects from ODB will +try to obtain the cache from the owning repository (via +odb_cache()) and produce a race if this ODB is concurrently +used to create fake repositories in other threads. +Consequently, operations on fake repositories will interact +with the ODB's cache instead of the repository's cache. +--- + include/git2/sys/repository.h | 3 ++- + src/repository.c | 16 +++++++++------- + tests/odb/backend/nobackend.c | 2 +- + tests/repo/setters.c | 23 ++++++++++++++++++++++- + 4 files changed, 34 insertions(+), 10 deletions(-) + +diff --git a/include/git2/sys/repository.h b/include/git2/sys/repository.h +index 892be6692..33bc5051f 100644 +--- a/include/git2/sys/repository.h ++++ b/include/git2/sys/repository.h +@@ -97,9 +97,10 @@ GIT_EXTERN(int) git_repository_set_config(git_repository *repo, git_config *conf + * + * @param repo A repository object + * @param odb An ODB object ++ * @param set_owner Register repository as owner of ODB + * @return 0 on success, or an error code + */ +-GIT_EXTERN(int) git_repository_set_odb(git_repository *repo, git_odb *odb); ++GIT_EXTERN(int) git_repository_set_odb(git_repository *repo, git_odb *odb, bool set_owner); + + /** + * Set the Reference Database Backend for this repository +diff --git a/src/repository.c b/src/repository.c +index aae0c910b..13e1ca29e 100644 +--- a/src/repository.c ++++ b/src/repository.c +@@ -86,10 +86,12 @@ git_buf git_repository__reserved_names_posix[] = { + }; + size_t git_repository__reserved_names_posix_len = 1; + +-static void set_odb(git_repository *repo, git_odb *odb) ++static void set_odb(git_repository *repo, git_odb *odb, bool set_owner) + { + if (odb) { +- GIT_REFCOUNT_OWN(odb, repo); ++ if (set_owner) { ++ GIT_REFCOUNT_OWN(odb, repo); ++ } + GIT_REFCOUNT_INC(odb); + } + +@@ -150,7 +152,7 @@ int git_repository__cleanup(git_repository *repo) + + set_config(repo, NULL); + set_index(repo, NULL); +- set_odb(repo, NULL); ++ set_odb(repo, NULL, /*set_owner=*/true); + set_refdb(repo, NULL); + + return 0; +@@ -762,7 +764,7 @@ static int _git_repository_open_ext_from_env( + goto error; + + if (odb) +- git_repository_set_odb(repo, odb); ++ git_repository_set_odb(repo, odb, /*set_owner=*/true); + + error = git__getenv(&alts_buf, "GIT_ALTERNATE_OBJECT_DIRECTORIES"); + if (error == GIT_ENOTFOUND) { +@@ -973,7 +975,7 @@ int git_repository_wrap_odb(git_repository **repo_out, git_odb *odb) + repo = repository_alloc(); + GIT_ERROR_CHECK_ALLOC(repo); + +- git_repository_set_odb(repo, odb); ++ git_repository_set_odb(repo, odb, /*set_owner=*/false); + *repo_out = repo; + + return 0; +@@ -1184,12 +1186,12 @@ int git_repository_odb(git_odb **out, git_repository *repo) + return 0; + } + +-int git_repository_set_odb(git_repository *repo, git_odb *odb) ++int git_repository_set_odb(git_repository *repo, git_odb *odb, bool set_owner) + { + GIT_ASSERT_ARG(repo); + GIT_ASSERT_ARG(odb); + +- set_odb(repo, odb); ++ set_odb(repo, odb, set_owner); + return 0; + } + +diff --git a/tests/odb/backend/nobackend.c b/tests/odb/backend/nobackend.c +index 7484d423b..d46a7fed9 100644 +--- a/tests/odb/backend/nobackend.c ++++ b/tests/odb/backend/nobackend.c +@@ -16,7 +16,7 @@ void test_odb_backend_nobackend__initialize(void) + cl_git_pass(git_refdb_new(&refdb, _repo)); + + git_repository_set_config(_repo, config); +- git_repository_set_odb(_repo, odb); ++ git_repository_set_odb(_repo, odb, /*set_owner=*/true); + git_repository_set_refdb(_repo, refdb); + + /* The set increases the refcount and we don't want them anymore */ +diff --git a/tests/repo/setters.c b/tests/repo/setters.c +index 1fac627f6..e0e0d3696 100644 +--- a/tests/repo/setters.c ++++ b/tests/repo/setters.c +@@ -94,7 +94,28 @@ void test_repo_setters__setting_a_new_odb_on_a_repo_which_already_loaded_one_pro + cl_git_pass(git_odb_open(&new_odb, "./testrepo.git/objects")); + cl_assert(((git_refcount *)new_odb)->refcount.val == 1); + +- git_repository_set_odb(repo, new_odb); ++ git_repository_set_odb(repo, new_odb, /*set_owner=*/true); ++ cl_assert(((git_refcount *)new_odb)->refcount.val == 2); ++ ++ git_repository_free(repo); ++ cl_assert(((git_refcount *)new_odb)->refcount.val == 1); ++ ++ git_odb_free(new_odb); ++ ++ /* ++ * Ensure the cleanup method won't try to free the repo as it's already been taken care of ++ */ ++ repo = NULL; ++} ++ ++void test_repo_setters__setting_a_new_odb_on_a_non_owner_repo_which_already_loaded_one_properly_honors_the_refcount(void) ++{ ++ git_odb *new_odb; ++ ++ cl_git_pass(git_odb__open(&new_odb, "./testrepo.git/objects", NULL)); ++ cl_assert(((git_refcount *)new_odb)->refcount.val == 1); ++ ++ git_repository_set_odb(repo, new_odb, /*set_owner=*/false); + cl_assert(((git_refcount *)new_odb)->refcount.val == 2); + + git_repository_free(repo); +-- +2.30.2 + diff --git a/etc/repos.json b/etc/repos.json index 5937cebd..b9725e13 100644 --- a/etc/repos.json +++ b/etc/repos.json @@ -381,11 +381,11 @@ , "com_github_libgit2_libgit2": { "repository": { "type": "archive" - , "content": "15b9b9ac0236534922b46c301b0f791413ac8bae" - , "fetch": "https://github.com/libgit2/libgit2/releases/download/v1.1.0/libgit2-1.1.0.tar.gz" - , "sha256": "ad73f845965cfd528e70f654e428073121a3fa0dc23caac81a1b1300277d4dba" - , "sha512": "a5226fbb11648168611a6daab978df59b68a3b5d809410d3e5dac6c04de5d962cdbabfbec7b0b6528bed94fe321d94c546748b7a180949f2ab30bb7c3487c9bc" - , "subdir": "libgit2-1.1.0" + , "content": "8e2e6a6faa3708b448ad891fbd3aa7673c65bcd2" + , "fetch": "https://github.com/libgit2/libgit2/archive/refs/tags/v1.2.0.tar.gz" + , "sha256": "701a5086a968a46f25e631941b99fc23e4755ca2c56f59371ce1d94b9a0cc643" + , "sha512": "428188de153fdf8ff5bf78949f4a3a89fba57b87a8b641f92fed501df6a8cfdb72e0ffe0bf61a98adf210a2867134eb4421ea4b8d8219331aabc3daddd92f5fc" + , "subdir": "libgit2-1.2.0" } , "target_root": "import targets" , "target_file_name": "TARGETS.git2" -- cgit v1.2.3