forked from libgit2/pygit2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.h
196 lines (156 loc) · 4.02 KB
/
types.h
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
/*
* Copyright 2010-2013 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>
/*
* 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 */
} 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_config */
typedef struct {
PyObject_HEAD
git_config* config;
} Config;
/* git_note */
typedef struct {
PyObject_HEAD
Repository *repo;
git_note *note;
char* annotated_id;
} Note;
typedef struct {
PyObject_HEAD
Repository *repo;
git_note_iterator* iter;
char* ref;
} NoteIter;
/* git _diff */
SIMPLE_TYPE(Diff, git_diff_list, list)
typedef struct {
PyObject_HEAD
Diff* diff;
size_t i;
size_t n;
} DiffIter;
typedef struct {
PyObject_HEAD
PyObject* hunks;
const char * old_file_path;
const char * new_file_path;
char* old_oid;
char* new_oid;
char status;
unsigned similarity;
unsigned additions;
unsigned deletions;
} Patch;
typedef struct {
PyObject_HEAD
PyObject* lines;
int old_start;
int old_lines;
int new_start;
int new_lines;
} Hunk;
/* 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
const git_index_entry *entry;
} IndexEntry;
typedef struct {
PyObject_HEAD
Index *owner;
int i;
} IndexIter;
/* 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;
char *oid_old;
char *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;
const char *encoding;
} Signature;
/* git_remote */
SIMPLE_TYPE(Remote, git_remote, remote)
#endif