diff --git a/pygit2/decl.h b/pygit2/decl.h index 58676ac..f3aec29 100644 --- a/pygit2/decl.h +++ b/pygit2/decl.h @@ -803,6 +803,56 @@ int git_merge_trees(git_index **out, git_repository *repo, const git_tree *ances int git_merge_file_from_index(git_merge_file_result *out, git_repository *repo, const git_index_entry *ancestor, const git_index_entry *ours, const git_index_entry *theirs, const git_merge_file_options *opts); void git_merge_file_result_free(git_merge_file_result *result); +/* + * git_stash + */ + +typedef int (*git_stash_cb)( + size_t index, const char* message, const git_oid *stash_id, void *payload); + +typedef enum { + GIT_STASH_APPLY_PROGRESS_NONE = 0, + GIT_STASH_APPLY_PROGRESS_LOADING_STASH = 1, + GIT_STASH_APPLY_PROGRESS_ANALYZE_INDEX = 2, + GIT_STASH_APPLY_PROGRESS_ANALYZE_MODIFIED = 3, + GIT_STASH_APPLY_PROGRESS_ANALYZE_UNTRACKED = 4, + GIT_STASH_APPLY_PROGRESS_CHECKOUT_UNTRACKED = 5, + GIT_STASH_APPLY_PROGRESS_CHECKOUT_MODIFIED = 6, + GIT_STASH_APPLY_PROGRESS_DONE = 7, +} git_stash_apply_progress_t; + +typedef int (*git_stash_apply_progress_cb)( + git_stash_apply_progress_t progress, void *payload); + +typedef enum { + GIT_STASH_DEFAULT = 0, + GIT_STASH_KEEP_INDEX = 1, + GIT_STASH_INCLUDE_UNTRACKED = 2, + GIT_STASH_INCLUDE_IGNORED = 4, +} git_stash_flags; + +typedef enum { + GIT_STASH_APPLY_DEFAULT = 0, + GIT_STASH_APPLY_REINSTATE_INDEX = 1, +} git_stash_apply_flags; + +typedef struct git_stash_apply_options { + unsigned int version; + git_stash_apply_flags flags; + git_checkout_options checkout_options; + git_stash_apply_progress_cb progress_cb; + void *progress_payload; +} git_stash_apply_options; + +#define GIT_STASH_APPLY_OPTIONS_VERSION ... + +int git_stash_save(git_oid *out, git_repository *repo, const git_signature *stasher, const char *message, uint32_t flags); +int git_stash_apply_init_options(git_stash_apply_options *opts, unsigned int version); +int git_stash_apply(git_repository *repo, size_t index, const git_stash_apply_options *options); +int git_stash_foreach(git_repository *repo, git_stash_cb callback, void *payload); +int git_stash_drop(git_repository *repo, size_t index); +int git_stash_pop(git_repository *repo, size_t index, const git_stash_apply_options *options); + /* * Describe */ diff --git a/src/pygit2.c b/src/pygit2.c index f8fbe9a..eca5aa2 100644 --- a/src/pygit2.c +++ b/src/pygit2.c @@ -428,6 +428,14 @@ moduleinit(PyObject* m) ADD_CONSTANT_INT(m, GIT_DESCRIBE_TAGS); ADD_CONSTANT_INT(m, GIT_DESCRIBE_ALL); + /* Stash */ + ADD_CONSTANT_INT(m, GIT_STASH_DEFAULT); + ADD_CONSTANT_INT(m, GIT_STASH_KEEP_INDEX); + ADD_CONSTANT_INT(m, GIT_STASH_INCLUDE_UNTRACKED); + ADD_CONSTANT_INT(m, GIT_STASH_INCLUDE_IGNORED); + ADD_CONSTANT_INT(m, GIT_STASH_APPLY_DEFAULT); + ADD_CONSTANT_INT(m, GIT_STASH_APPLY_REINSTATE_INDEX); + /* Global initialization of libgit2 */ git_libgit2_init();