Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/libfetchers-tests/git-utils.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "nix/fetchers/git-utils.hh"
#include "nix/util/file-system.hh"
#include <git2/config.h>
#include <gmock/gmock.h>
#include <git2/global.h>
#include <git2/repository.h>
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/libfetchers/git-utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

Expand Down
Loading