Skip to content

Commit d2a62c5

Browse files
committed
Merge remote-tracking branch 'carlos/cffi-index'
2 parents 5fad06a + 7f922ae commit d2a62c5

14 files changed

+785
-965
lines changed

docs/working-copy.rst

+4-15
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,14 @@ tree. You can use it independently of the index file, e.g.
3737
The Index type
3838
====================
3939

40-
.. automethod:: pygit2.Index.add
41-
.. automethod:: pygit2.Index.remove
42-
.. automethod:: pygit2.Index.clear
43-
.. automethod:: pygit2.Index.read
44-
.. automethod:: pygit2.Index.write
45-
.. automethod:: pygit2.Index.read_tree
46-
.. automethod:: pygit2.Index.write_tree
47-
.. automethod:: pygit2.Index.diff_to_tree
48-
.. automethod:: pygit2.Index.diff_to_workdir
49-
40+
.. autoclass:: pygit2.Index
41+
:members:
5042

5143
The IndexEntry type
5244
--------------------
5345

54-
.. autoattribute:: pygit2.IndexEntry.id
55-
.. autoattribute:: pygit2.IndexEntry.hex
56-
.. autoattribute:: pygit2.IndexEntry.path
57-
.. autoattribute:: pygit2.IndexEntry.mode
58-
46+
.. autoclass:: pygit2.IndexEntry
47+
:members:
5948

6049
Status
6150
====================

pygit2/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from .credentials import *
3939
from .remote import Remote, get_credentials
4040
from .config import Config
41+
from .index import Index, IndexEntry
4142
from .errors import check_error
4243
from .ffi import ffi, C, to_str
4344

pygit2/decl.h

+131-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ typedef ... git_remote;
33
typedef ... git_refspec;
44
typedef ... git_push;
55
typedef ... git_cred;
6-
typedef ... git_diff_file;
76
typedef ... git_tree;
87
typedef ... git_signature;
8+
typedef ... git_index;
9+
typedef ... git_diff;
10+
typedef ... git_index_conflict_iterator;
911

1012
#define GIT_OID_RAWSZ ...
1113
#define GIT_PATH_MAX ...
@@ -25,6 +27,7 @@ typedef struct git_strarray {
2527
size_t count;
2628
} git_strarray;
2729

30+
typedef int64_t git_off_t;
2831

2932
typedef enum {
3033
GIT_OK = 0,
@@ -181,6 +184,76 @@ int git_cred_ssh_key_new(
181184
const char *privatekey,
182185
const char *passphrase);
183186

187+
/*
188+
* git_diff
189+
*/
190+
191+
typedef enum {
192+
GIT_SUBMODULE_IGNORE_RESET = -1,
193+
194+
GIT_SUBMODULE_IGNORE_NONE = 1,
195+
GIT_SUBMODULE_IGNORE_UNTRACKED = 2,
196+
GIT_SUBMODULE_IGNORE_DIRTY = 3,
197+
GIT_SUBMODULE_IGNORE_ALL = 4,
198+
GIT_SUBMODULE_IGNORE_DEFAULT = 0
199+
} git_submodule_ignore_t;
200+
201+
typedef enum {
202+
GIT_DELTA_UNMODIFIED = 0,
203+
GIT_DELTA_ADDED = 1,
204+
GIT_DELTA_DELETED = 2,
205+
GIT_DELTA_MODIFIED = 3,
206+
GIT_DELTA_RENAMED = 4,
207+
GIT_DELTA_COPIED = 5,
208+
GIT_DELTA_IGNORED = 6,
209+
GIT_DELTA_UNTRACKED = 7,
210+
GIT_DELTA_TYPECHANGE = 8,
211+
} git_delta_t;
212+
213+
typedef struct {
214+
git_oid id;
215+
const char *path;
216+
git_off_t size;
217+
uint32_t flags;
218+
uint16_t mode;
219+
} git_diff_file;
220+
221+
typedef struct {
222+
git_delta_t status;
223+
uint32_t flags;
224+
uint16_t similarity;
225+
uint16_t nfiles;
226+
git_diff_file old_file;
227+
git_diff_file new_file;
228+
} git_diff_delta;
229+
230+
typedef int (*git_diff_notify_cb)(
231+
const git_diff *diff_so_far,
232+
const git_diff_delta *delta_to_add,
233+
const char *matched_pathspec,
234+
void *payload);
235+
236+
typedef struct {
237+
unsigned int version;
238+
uint32_t flags;
239+
240+
git_submodule_ignore_t ignore_submodules;
241+
git_strarray pathspec;
242+
git_diff_notify_cb notify_cb;
243+
void *notify_payload;
244+
245+
uint16_t context_lines;
246+
uint16_t interhunk_lines;
247+
uint16_t id_abbrev;
248+
git_off_t max_size;
249+
const char *old_prefix;
250+
const char *new_prefix;
251+
} git_diff_options;
252+
253+
int git_diff_init_options(git_diff_options *opts, unsigned int version);
254+
int git_diff_index_to_workdir(git_diff **diff, git_repository *repo, git_index *index, const git_diff_options *opts);
255+
int git_diff_tree_to_index(git_diff **diff, git_repository *repo, git_tree *old_tree, git_index *index, const git_diff_options *opts);
256+
184257
/*
185258
* git_checkout
186259
*/
@@ -369,3 +442,60 @@ int git_repository_init_ext(
369442
git_repository **out,
370443
const char *repo_path,
371444
git_repository_init_options *opts);
445+
446+
/*
447+
* git_index
448+
*/
449+
typedef int64_t git_time_t;
450+
451+
typedef struct {
452+
git_time_t seconds;
453+
unsigned int nanoseconds;
454+
} git_index_time;
455+
456+
typedef struct git_index_entry {
457+
git_index_time ctime;
458+
git_index_time mtime;
459+
460+
unsigned int dev;
461+
unsigned int ino;
462+
unsigned int mode;
463+
unsigned int uid;
464+
unsigned int gid;
465+
git_off_t file_size;
466+
467+
git_oid id;
468+
469+
unsigned short flags;
470+
unsigned short flags_extended;
471+
472+
const char *path;
473+
} git_index_entry;
474+
475+
typedef int (*git_index_matched_path_cb)(
476+
const char *path, const char *matched_pathspec, void *payload);
477+
478+
void git_index_free(git_index *index);
479+
int git_repository_index(git_index **out, git_repository *repo);
480+
int git_index_open(git_index **out, const char *index_path);
481+
int git_index_read(git_index *index, int force);
482+
int git_index_write(git_index *index);
483+
size_t git_index_entrycount(const git_index *index);
484+
int git_index_find(size_t *at_pos, git_index *index, const char *path);
485+
int git_index_add_bypath(git_index *index, const char *path);
486+
int git_index_add(git_index *index, const git_index_entry *source_entry);
487+
int git_index_remove(git_index *index, const char *path, int stage);
488+
int git_index_read_tree(git_index *index, const git_tree *tree);
489+
int git_index_clear(git_index *index);
490+
int git_index_write_tree(git_oid *out, git_index *index);
491+
int git_index_write_tree_to(git_oid *out, git_index *index, git_repository *repo);
492+
const git_index_entry *git_index_get_bypath(git_index *index, const char *path, int stage);
493+
const git_index_entry *git_index_get_byindex(git_index *index, size_t n);
494+
int git_index_add_all(git_index *index, const git_strarray *pathspec, unsigned int flags,
495+
git_index_matched_path_cb callback, void *payload);
496+
int git_index_has_conflicts(const git_index *index);
497+
void git_index_conflict_iterator_free(git_index_conflict_iterator *iterator);
498+
int git_index_conflict_iterator_new(git_index_conflict_iterator **iterator_out, git_index *index);
499+
int git_index_conflict_get(const git_index_entry **ancestor_out, const git_index_entry **our_out, const git_index_entry **their_out, git_index *index, const char *path);
500+
int git_index_conflict_next(const git_index_entry **ancestor_out, const git_index_entry **our_out, const git_index_entry **their_out, git_index_conflict_iterator *iterator);
501+
int git_index_conflict_remove(git_index *index, const char *path);

0 commit comments

Comments
 (0)