Line data Source code
1 : /*
2 : * Copyright (C) 2004-2026 Savoir-faire Linux Inc.
3 : *
4 : * This program is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 3 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * This program is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : * GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License
15 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 : */
17 : #pragma once
18 :
19 : #include <memory>
20 : #include <git2.h>
21 :
22 : namespace jami {
23 :
24 : struct GitPackBuilderDeleter
25 : {
26 1618 : inline void operator()(git_packbuilder* p) const { git_packbuilder_free(p); }
27 : };
28 : using GitPackBuilder = std::unique_ptr<git_packbuilder, GitPackBuilderDeleter>;
29 :
30 : struct GitRepositoryDeleter
31 : {
32 67518 : inline void operator()(git_repository* p) const { git_repository_free(p); }
33 : };
34 : using GitRepository = std::unique_ptr<git_repository, GitRepositoryDeleter>;
35 :
36 : struct GitOdbDeleter
37 : {
38 1618 : inline void operator()(git_odb* p) const { git_odb_free(p); }
39 : };
40 : using GitOdb = std::unique_ptr<git_odb, GitOdbDeleter>;
41 :
42 : struct GitRevWalkerDeleter
43 : {
44 8330 : inline void operator()(git_revwalk* p) const { git_revwalk_free(p); }
45 : };
46 : using GitRevWalker = std::unique_ptr<git_revwalk, GitRevWalkerDeleter>;
47 :
48 : struct GitCommitDeleter
49 : {
50 50948 : inline void operator()(git_commit* p) const { git_commit_free(p); }
51 : };
52 : using GitCommit = std::unique_ptr<git_commit, GitCommitDeleter>;
53 :
54 : struct GitAnnotatedCommitDeleter
55 : {
56 1198 : inline void operator()(git_annotated_commit* p) const { git_annotated_commit_free(p); }
57 : };
58 : using GitAnnotatedCommit = std::unique_ptr<git_annotated_commit, GitAnnotatedCommitDeleter>;
59 :
60 : struct GitIndexDeleter
61 : {
62 3089 : inline void operator()(git_index* p) const { git_index_free(p); }
63 : };
64 : using GitIndex = std::unique_ptr<git_index, GitIndexDeleter>;
65 :
66 : struct GitTreeDeleter
67 : {
68 23482 : inline void operator()(git_tree* p) const { git_tree_free(p); }
69 : };
70 : using GitTree = std::unique_ptr<git_tree, GitTreeDeleter>;
71 :
72 : struct GitRemoteDeleter
73 : {
74 6127 : inline void operator()(git_remote* p) const { git_remote_free(p); }
75 : };
76 : using GitRemote = std::unique_ptr<git_remote, GitRemoteDeleter>;
77 :
78 : struct GitReferenceDeleter
79 : {
80 1168 : inline void operator()(git_reference* p) const { git_reference_free(p); }
81 : };
82 : using GitReference = std::unique_ptr<git_reference, GitReferenceDeleter>;
83 :
84 : struct GitSignatureDeleter
85 : {
86 1509 : inline void operator()(git_signature* p) const { git_signature_free(p); }
87 : };
88 : using GitSignature = std::unique_ptr<git_signature, GitSignatureDeleter>;
89 :
90 : struct GitObjectDeleter
91 : {
92 24998 : inline void operator()(git_object* p) const { git_object_free(p); }
93 : };
94 : using GitObject = std::unique_ptr<git_object, GitObjectDeleter>;
95 :
96 : struct GitDiffDeleter
97 : {
98 3806 : inline void operator()(git_diff* p) const { git_diff_free(p); }
99 : };
100 : using GitDiff = std::unique_ptr<git_diff, GitDiffDeleter>;
101 :
102 : struct GitDiffStatsDeleter
103 : {
104 3786 : inline void operator()(git_diff_stats* p) const { git_diff_stats_free(p); }
105 : };
106 : using GitDiffStats = std::unique_ptr<git_diff_stats, GitDiffStatsDeleter>;
107 :
108 : struct GitIndexConflictIteratorDeleter
109 : {
110 1 : inline void operator()(git_index_conflict_iterator* p) const { git_index_conflict_iterator_free(p); }
111 : };
112 : using GitIndexConflictIterator = std::unique_ptr<git_index_conflict_iterator, GitIndexConflictIteratorDeleter>;
113 :
114 : struct GitBufDeleter
115 : {
116 5310 : inline void operator()(git_buf* b) const { git_buf_dispose(b); }
117 : };
118 : using GitBuf = std::unique_ptr<git_buf, GitBufDeleter>;
119 :
120 : } // namespace jami
|