summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2017-04-13 18:23:42 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2017-04-13 18:23:42 +0100
commitf24fd246048dae2e494a2f4c16b5927b521328e2 (patch)
treec21ffd18b2850c0e138ab4a3ca997bb1f7af59de
parentUpdate change log along with package tree (diff)
downloadgentoobrowse-api-f24fd246048dae2e494a2f4c16b5927b521328e2.tar.bz2
gentoobrowse-api-f24fd246048dae2e494a2f4c16b5927b521328e2.tar.xz
gentoobrowse-api-f24fd246048dae2e494a2f4c16b5927b521328e2.zip
Initialize git library once on startup
-rw-r--r--gentoobrowse-api/service/main.cpp5
-rw-r--r--gentoobrowse-api/service/maintenanceGitOperations.cpp4
-rw-r--r--gentoobrowse-api/service/utils/git.cpp10
-rw-r--r--gentoobrowse-api/service/utils/git.h6
4 files changed, 4 insertions, 21 deletions
diff --git a/gentoobrowse-api/service/main.cpp b/gentoobrowse-api/service/main.cpp
index ce32be0..3221e4c 100644
--- a/gentoobrowse-api/service/main.cpp
+++ b/gentoobrowse-api/service/main.cpp
@@ -9,6 +9,7 @@
#include <libexslt/exslt.h>
#include <libxslt/transform.h>
+#include <git2.h>
namespace Gentoo {
namespace Service {
@@ -17,13 +18,15 @@ class Api : public IceTray::Service {
Api()
{
xmlInitParser();
- // exsltRegisterAll();
+ exsltRegisterAll();
+ git_libgit2_init();
}
~Api()
{
xsltCleanupGlobals();
xmlCleanupParser();
+ git_libgit2_shutdown();
}
void addObjects(const std::string &, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &, const Ice::ObjectAdapterPtr & adp) override
diff --git a/gentoobrowse-api/service/maintenanceGitOperations.cpp b/gentoobrowse-api/service/maintenanceGitOperations.cpp
index 8941dc2..0b909b9 100644
--- a/gentoobrowse-api/service/maintenanceGitOperations.cpp
+++ b/gentoobrowse-api/service/maintenanceGitOperations.cpp
@@ -95,8 +95,6 @@ namespace Gentoo {
void
Maintenance::updateRepositories(const Ice::Current &)
{
- libgit2 git;
-
auto dbc = db->get();
sql::maintenance::reposToUpdate.select(dbc.get())->forEachRow<std::string, std::string, std::string>(&updateRepository);
}
@@ -165,8 +163,6 @@ namespace Gentoo {
void
Maintenance::refreshPackageTreeGit(const Ice::Current & c)
{
- libgit2 git;
-
auto properties = c.adapter->getCommunicator()->getProperties();
auto repoRoot = boost::filesystem::path(properties->getPropertyWithDefault("GentooBrowseAPI.RepoRoot", "/"));
auto dbc = db->get();
diff --git a/gentoobrowse-api/service/utils/git.cpp b/gentoobrowse-api/service/utils/git.cpp
index bbd69a3..ce1556a 100644
--- a/gentoobrowse-api/service/utils/git.cpp
+++ b/gentoobrowse-api/service/utils/git.cpp
@@ -16,16 +16,6 @@ namespace Gentoo {
throw ::Gentoo::GitError(*fn, err, e->klass, e->message);
}
- libgit2::libgit2()
- {
- git_libgit2_init();
- }
-
- libgit2::~libgit2()
- {
- git_libgit2_shutdown();
- }
-
AdHocFormatter(RefSpec, "refs/heads/%?:refs/remotes/%?/%?");
std::unique_ptr<git_annotated_commit, void (*)(git_annotated_commit*)>
gitFetch(git_repository * repo, git_remote * remote, const char * remoteBranchName)
diff --git a/gentoobrowse-api/service/utils/git.h b/gentoobrowse-api/service/utils/git.h
index 6900435..ec3afad 100644
--- a/gentoobrowse-api/service/utils/git.h
+++ b/gentoobrowse-api/service/utils/git.h
@@ -33,12 +33,6 @@ namespace Gentoo {
return r;
}
- class libgit2 {
- public:
- libgit2();
- ~libgit2();
- };
-
std::unique_ptr<git_annotated_commit, void (*)(git_annotated_commit*)>
gitFetch(git_repository * repo, git_remote * remote, const char * branch);