diff --git a/src/libfetchers-tests/git-utils.cc b/src/libfetchers-tests/git-utils.cc index 9c0174e16..be70db9a7 100644 --- a/src/libfetchers-tests/git-utils.cc +++ b/src/libfetchers-tests/git-utils.cc @@ -1,5 +1,6 @@ #include "nix/fetchers/git-utils.hh" #include "nix/util/file-system.hh" +#include #include #include #include @@ -66,6 +67,21 @@ void writeString(CreateRegularFileSink & fileSink, std::string contents, bool ex fileSink(contents); } +TEST_F(GitUtilsTest, opens_shopify_patched_git_repository) +{ + git_repository * rawRepo = nullptr; + ASSERT_EQ(git_repository_open(&rawRepo, tmpDir.string().c_str()), 0); + + git_config * config = nullptr; + ASSERT_EQ(git_repository_config(&config, rawRepo), 0); + ASSERT_EQ(git_config_set_int32(config, "core.repositoryformatversion", 1), 0); + ASSERT_EQ(git_config_set_bool(config, "extensions.shopifyPatchedGit", true), 0); + git_config_free(config); + git_repository_free(rawRepo); + + ASSERT_NO_THROW(openRepo()); +} + TEST_F(GitUtilsTest, sink_basic) { auto repo = openRepo(); diff --git a/src/libfetchers/git-utils.cc b/src/libfetchers/git-utils.cc index 795f3b373..b90f9095e 100644 --- a/src/libfetchers/git-utils.cc +++ b/src/libfetchers/git-utils.cc @@ -137,9 +137,9 @@ static void initLibGit2() // Register support for additional git extensions. // This allows opening repos with extensions that libgit2 doesn't natively support, // as long as we don't actually need the extension's functionality. - // "refstorage" is used by reftables - we can ignore it since we only access objects by SHA. - const char * extensions[] = {"refstorage"}; - git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, extensions, 1); + // "refstorage" is used by reftables; both extensions are safe to ignore when accessing objects by SHA. + const char * extensions[] = {"refstorage", "shopifypatchedgit"}; + git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, extensions, 2); }); }