forked from libgit2/pygit2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.h
More file actions
216 lines (178 loc) · 4.54 KB
/
types.h
File metadata and controls
216 lines (178 loc) · 4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
* Copyright 2010-2017 The pygit2 contributors
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2,
* as published by the Free Software Foundation.
*
* In addition to the permissions in the GNU General Public License,
* the authors give you unlimited permission to link the compiled
* version of this file into combinations with other programs,
* and to distribute those combinations without any restriction
* coming from the use of this file. (The General Public License
* restrictions do apply in other respects; for example, they cover
* modification of the file, and distribution when not linked into
* a combined executable.)
*
* This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDE_pygit2_objects_h
#define INCLUDE_pygit2_objects_h
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <git2.h>
#if !(LIBGIT2_VER_MAJOR == 0 && LIBGIT2_VER_MINOR == 27)
#error You need a compatible libgit2 version (v0.27.x)
#endif
/*
* Python objects
*
**/
/* git_repository */
typedef struct {
PyObject_HEAD
git_repository *repo;
PyObject *index; /* It will be None for a bare repository */
PyObject *config; /* It will be None for a bare repository */
int owned; /* _from_c() sometimes means we don't own the C pointer */
} Repository;
typedef struct {
PyObject_HEAD
git_oid oid;
} Oid;
#define SIMPLE_TYPE(_name, _ptr_type, _ptr_name) \
typedef struct {\
PyObject_HEAD\
Repository *repo;\
_ptr_type *_ptr_name;\
} _name;
/* git object types
*
* The structs for some of the object subtypes are identical except for
* the type of their object pointers. */
SIMPLE_TYPE(Object, git_object, obj)
SIMPLE_TYPE(Commit, git_commit, commit)
SIMPLE_TYPE(Tree, git_tree, tree)
SIMPLE_TYPE(Blob, git_blob, blob)
SIMPLE_TYPE(Tag, git_tag, tag)
/* git_worktree */
typedef struct {
PyObject_HEAD
Repository *repo;
git_worktree *worktree;
} Worktree;
/* git_note */
typedef struct {
PyObject_HEAD
Repository *repo;
git_note *note;
PyObject* annotated_id;
} Note;
typedef struct {
PyObject_HEAD
Repository *repo;
git_note_iterator* iter;
char* ref;
} NoteIter;
/* git_patch */
typedef struct {
PyObject_HEAD
git_patch *patch;
Blob* oldblob;
Blob* newblob;
} Patch;
/* git_diff */
SIMPLE_TYPE(Diff, git_diff, diff)
typedef struct {
PyObject_HEAD
Diff *diff;
size_t i;
size_t n;
} DeltasIter;
typedef struct {
PyObject_HEAD
Diff *diff;
size_t i;
size_t n;
} DiffIter;
typedef struct {
PyObject_HEAD
PyObject *id;
char *path;
PyObject *raw_path;
git_off_t size;
uint32_t flags;
uint16_t mode;
} DiffFile;
typedef struct {
PyObject_HEAD
git_delta_t status;
uint32_t flags;
uint16_t similarity;
uint16_t nfiles;
PyObject *old_file;
PyObject *new_file;
} DiffDelta;
typedef struct {
PyObject_HEAD
Patch *patch;
const git_diff_hunk *hunk;
size_t idx;
size_t n_lines;
} DiffHunk;
typedef struct {
PyObject_HEAD
DiffHunk *hunk;
const git_diff_line *line;
} DiffLine;
SIMPLE_TYPE(DiffStats, git_diff_stats, stats);
/* git_tree_walk , git_treebuilder*/
SIMPLE_TYPE(TreeBuilder, git_treebuilder, bld)
typedef struct {
PyObject_HEAD
const git_tree_entry *entry;
} TreeEntry;
typedef struct {
PyObject_HEAD
Tree *owner;
int i;
} TreeIter;
/* git_index */
SIMPLE_TYPE(Index, git_index, index)
typedef struct {
PyObject_HEAD
git_index_entry entry;
} IndexEntry;
/* git_reference, git_reflog */
SIMPLE_TYPE(Walker, git_revwalk, walk)
SIMPLE_TYPE(Reference, git_reference, reference)
typedef Reference Branch;
typedef struct {
PyObject_HEAD
git_signature *signature;
PyObject *oid_old;
PyObject *oid_new;
char *message;
} RefLogEntry;
typedef struct {
PyObject_HEAD
git_reflog *reflog;
size_t i;
size_t size;
} RefLogIter;
/* git_signature */
typedef struct {
PyObject_HEAD
Object *obj;
const git_signature *signature;
char *encoding;
} Signature;
#endif