diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-07-31 20:25:31 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-07-31 20:25:31 +0100 |
commit | 742b8213fe1298dd2c7152969d229e5dadd82a23 (patch) | |
tree | 06731380fa82943b828b1d383ee623bf0f09516d | |
parent | Always build testProcessAll as an exe (diff) | |
download | gentoobrowse-api-742b8213fe1298dd2c7152969d229e5dadd82a23.tar.bz2 gentoobrowse-api-742b8213fe1298dd2c7152969d229e5dadd82a23.tar.xz gentoobrowse-api-742b8213fe1298dd2c7152969d229e5dadd82a23.zip |
Tidier git pointer typedefs
-rw-r--r-- | gentoobrowse-api/service/utils/git.cpp | 2 | ||||
-rw-r--r-- | gentoobrowse-api/service/utils/git.h | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/gentoobrowse-api/service/utils/git.cpp b/gentoobrowse-api/service/utils/git.cpp index 71856d8..9a1cae2 100644 --- a/gentoobrowse-api/service/utils/git.cpp +++ b/gentoobrowse-api/service/utils/git.cpp @@ -31,7 +31,7 @@ namespace Gentoo { } AdHocFormatter(RefSpec, "refs/heads/%?:refs/remotes/%?/%?"); - std::unique_ptr<git_annotated_commit, void (*)(git_annotated_commit*)> + GitAnnotatedCommitPtr gitFetch(git_repository * repo, git_remote * remote, const char * remoteBranchName) { auto opts = gitSafeGet(git_fetch_init_options, GIT_FETCH_OPTIONS_VERSION); diff --git a/gentoobrowse-api/service/utils/git.h b/gentoobrowse-api/service/utils/git.h index 59f06f0..20e8755 100644 --- a/gentoobrowse-api/service/utils/git.h +++ b/gentoobrowse-api/service/utils/git.h @@ -19,13 +19,16 @@ namespace Gentoo { } } + template<typename T> + using GitTPtr = std::unique_ptr<T, void(*)(T*)>; + template<typename R, typename ... P, typename ... A> - std::unique_ptr<R, void(*)(R*)> + GitTPtr<R> gitSafeGet(int(*get)(R**, P...), void(*release)(R*), A ... p) { R * r = nullptr; gitSafe(get, &r, p...); - return std::unique_ptr<R, void(*)(R*)>(r, release); + return GitTPtr<R>(r, release); } template<typename R, typename ... P, typename ... A> @@ -39,7 +42,8 @@ namespace Gentoo { std::string operator*(const git_oid &); - std::unique_ptr<git_annotated_commit, void (*)(git_annotated_commit*)> + using GitAnnotatedCommitPtr = GitTPtr<git_annotated_commit>; + GitAnnotatedCommitPtr gitFetch(git_repository * repo, git_remote * remote, const char * branch); git_oid |