2013-03-05 13:53:04 -06:00
|
|
|
#include "_cgo_export.h"
|
2015-01-04 11:05:11 -06:00
|
|
|
#include <git2.h>
|
|
|
|
#include <git2/sys/odb_backend.h>
|
|
|
|
#include <git2/sys/refdb_backend.h>
|
2013-03-05 14:05:19 -06:00
|
|
|
|
|
|
|
typedef int (*gogit_submodule_cbk)(git_submodule *sm, const char *name, void *payload);
|
|
|
|
|
2015-08-12 05:44:58 -05:00
|
|
|
void _go_git_populate_remote_cb(git_clone_options *opts)
|
|
|
|
{
|
|
|
|
opts->remote_cb = (git_remote_create_cb)remoteCreateCallback;
|
|
|
|
}
|
|
|
|
|
2016-05-29 06:33:53 -05:00
|
|
|
void _go_git_populate_checkout_cb(git_checkout_options *opts)
|
|
|
|
{
|
|
|
|
opts->notify_cb = (git_checkout_notify_cb)checkoutNotifyCallback;
|
|
|
|
opts->progress_cb = (git_checkout_progress_cb)checkoutProgressCallback;
|
|
|
|
}
|
|
|
|
|
2013-03-05 14:05:19 -06:00
|
|
|
int _go_git_visit_submodule(git_repository *repo, void *fct)
|
|
|
|
{
|
|
|
|
return git_submodule_foreach(repo, (gogit_submodule_cbk)&SubmoduleVisitor, fct);
|
|
|
|
}
|
2013-03-05 13:53:04 -06:00
|
|
|
|
|
|
|
int _go_git_treewalk(git_tree *tree, git_treewalk_mode mode, void *ptr)
|
|
|
|
{
|
|
|
|
return git_tree_walk(tree, mode, (git_treewalk_cb)&CallbackGitTreeWalk, ptr);
|
|
|
|
}
|
|
|
|
|
2013-05-16 06:56:07 -05:00
|
|
|
int _go_git_packbuilder_foreach(git_packbuilder *pb, void *payload)
|
|
|
|
{
|
|
|
|
return git_packbuilder_foreach(pb, (git_packbuilder_foreach_cb)&packbuilderForEachCb, payload);
|
|
|
|
}
|
|
|
|
|
2013-05-21 14:37:08 -05:00
|
|
|
int _go_git_odb_foreach(git_odb *db, void *payload)
|
|
|
|
{
|
|
|
|
return git_odb_foreach(db, (git_odb_foreach_cb)&odbForEachCb, payload);
|
|
|
|
}
|
2014-01-03 18:40:21 -06:00
|
|
|
|
2014-01-29 17:55:17 -06:00
|
|
|
void _go_git_odb_backend_free(git_odb_backend *backend)
|
|
|
|
{
|
|
|
|
if (backend->free)
|
|
|
|
backend->free(backend);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2014-02-24 02:01:47 -06:00
|
|
|
|
|
|
|
void _go_git_refdb_backend_free(git_refdb_backend *backend)
|
|
|
|
{
|
|
|
|
if (backend->free)
|
|
|
|
backend->free(backend);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2014-04-03 15:41:43 -05:00
|
|
|
|
2014-02-20 00:25:30 -06:00
|
|
|
int _go_git_diff_foreach(git_diff *diff, int eachFile, int eachHunk, int eachLine, void *payload)
|
|
|
|
{
|
2014-08-19 07:51:18 -05:00
|
|
|
git_diff_file_cb fcb = NULL;
|
2014-02-20 00:25:30 -06:00
|
|
|
git_diff_hunk_cb hcb = NULL;
|
|
|
|
git_diff_line_cb lcb = NULL;
|
|
|
|
|
|
|
|
if (eachFile) {
|
|
|
|
fcb = (git_diff_file_cb)&diffForEachFileCb;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eachHunk) {
|
|
|
|
hcb = (git_diff_hunk_cb)&diffForEachHunkCb;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eachLine) {
|
|
|
|
lcb = (git_diff_line_cb)&diffForEachLineCb;
|
|
|
|
}
|
|
|
|
|
2015-06-27 17:34:54 -05:00
|
|
|
return git_diff_foreach(diff, fcb, NULL, hcb, lcb, payload);
|
2014-03-21 00:54:18 -05:00
|
|
|
}
|
2014-03-22 00:16:26 -05:00
|
|
|
|
2015-06-12 12:10:00 -05:00
|
|
|
int _go_git_diff_blobs(git_blob *old, const char *old_path, git_blob *new, const char *new_path, git_diff_options *opts, int eachFile, int eachHunk, int eachLine, void *payload)
|
|
|
|
{
|
|
|
|
git_diff_file_cb fcb = NULL;
|
|
|
|
git_diff_hunk_cb hcb = NULL;
|
|
|
|
git_diff_line_cb lcb = NULL;
|
|
|
|
|
|
|
|
if (eachFile) {
|
|
|
|
fcb = (git_diff_file_cb)&diffForEachFileCb;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eachHunk) {
|
|
|
|
hcb = (git_diff_hunk_cb)&diffForEachHunkCb;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eachLine) {
|
|
|
|
lcb = (git_diff_line_cb)&diffForEachLineCb;
|
|
|
|
}
|
|
|
|
|
2015-07-01 09:07:02 -05:00
|
|
|
return git_diff_blobs(old, old_path, new, new_path, opts, fcb, NULL, hcb, lcb, payload);
|
2015-06-12 12:10:00 -05:00
|
|
|
}
|
|
|
|
|
2014-03-22 00:16:26 -05:00
|
|
|
void _go_git_setup_diff_notify_callbacks(git_diff_options *opts) {
|
|
|
|
opts->notify_cb = (git_diff_notify_cb)diffNotifyCb;
|
|
|
|
}
|
|
|
|
|
2014-01-06 10:55:29 -06:00
|
|
|
void _go_git_setup_callbacks(git_remote_callbacks *callbacks) {
|
2014-01-03 18:40:21 -06:00
|
|
|
typedef int (*completion_cb)(git_remote_completion_type type, void *data);
|
|
|
|
typedef int (*update_tips_cb)(const char *refname, const git_oid *a, const git_oid *b, void *data);
|
2014-12-18 17:02:53 -06:00
|
|
|
typedef int (*push_update_reference_cb)(const char *refname, const char *status, void *data);
|
2014-12-12 18:23:40 -06:00
|
|
|
|
2014-04-26 11:43:22 -05:00
|
|
|
callbacks->sideband_progress = (git_transport_message_cb)sidebandProgressCallback;
|
2014-01-03 18:40:21 -06:00
|
|
|
callbacks->completion = (completion_cb)completionCallback;
|
2014-10-15 08:43:02 -05:00
|
|
|
callbacks->credentials = (git_cred_acquire_cb)credentialsCallback;
|
|
|
|
callbacks->transfer_progress = (git_transfer_progress_cb)transferProgressCallback;
|
2014-01-03 18:40:21 -06:00
|
|
|
callbacks->update_tips = (update_tips_cb)updateTipsCallback;
|
2014-10-15 08:43:02 -05:00
|
|
|
callbacks->certificate_check = (git_transport_certificate_check_cb) certificateCheckCallback;
|
2014-12-12 18:23:40 -06:00
|
|
|
callbacks->pack_progress = (git_packbuilder_progress) packProgressCallback;
|
|
|
|
callbacks->push_transfer_progress = (git_push_transfer_progress) pushTransferProgressCallback;
|
|
|
|
callbacks->push_update_reference = (push_update_reference_cb) pushUpdateReferenceCallback;
|
2014-01-03 18:40:21 -06:00
|
|
|
}
|
|
|
|
|
2014-10-21 17:23:12 -05:00
|
|
|
int _go_git_index_add_all(git_index *index, const git_strarray *pathspec, unsigned int flags, void *callback) {
|
|
|
|
git_index_matched_path_cb cb = callback ? (git_index_matched_path_cb) &indexMatchedPathCallback : NULL;
|
|
|
|
return git_index_add_all(index, pathspec, flags, cb, callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
int _go_git_index_update_all(git_index *index, const git_strarray *pathspec, void *callback) {
|
|
|
|
git_index_matched_path_cb cb = callback ? (git_index_matched_path_cb) &indexMatchedPathCallback : NULL;
|
|
|
|
return git_index_update_all(index, pathspec, cb, callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
int _go_git_index_remove_all(git_index *index, const git_strarray *pathspec, void *callback) {
|
|
|
|
git_index_matched_path_cb cb = callback ? (git_index_matched_path_cb) &indexMatchedPathCallback : NULL;
|
|
|
|
return git_index_remove_all(index, pathspec, cb, callback);
|
|
|
|
}
|
|
|
|
|
2015-07-31 03:07:26 -05:00
|
|
|
int _go_git_tag_foreach(git_repository *repo, void *payload)
|
|
|
|
{
|
|
|
|
return git_tag_foreach(repo, (git_tag_foreach_cb)&gitTagForeachCb, payload);
|
|
|
|
}
|
|
|
|
|
2016-02-16 23:34:43 -06:00
|
|
|
int _go_git_merge_file(git_merge_file_result* out, char* ancestorContents, size_t ancestorLen, char* ancestorPath, unsigned int ancestorMode, char* oursContents, size_t oursLen, char* oursPath, unsigned int oursMode, char* theirsContents, size_t theirsLen, char* theirsPath, unsigned int theirsMode, git_merge_file_options* copts) {
|
|
|
|
git_merge_file_input ancestor = GIT_MERGE_FILE_INPUT_INIT;
|
|
|
|
git_merge_file_input ours = GIT_MERGE_FILE_INPUT_INIT;
|
|
|
|
git_merge_file_input theirs = GIT_MERGE_FILE_INPUT_INIT;
|
|
|
|
|
|
|
|
ancestor.ptr = ancestorContents;
|
|
|
|
ancestor.size = ancestorLen;
|
|
|
|
ancestor.path = ancestorPath;
|
|
|
|
ancestor.mode = ancestorMode;
|
|
|
|
|
|
|
|
ours.ptr = oursContents;
|
|
|
|
ours.size = oursLen;
|
|
|
|
ours.path = oursPath;
|
|
|
|
ours.mode = oursMode;
|
|
|
|
|
|
|
|
theirs.ptr = theirsContents;
|
|
|
|
theirs.size = theirsLen;
|
|
|
|
theirs.path = theirsPath;
|
|
|
|
theirs.mode = theirsMode;
|
|
|
|
|
|
|
|
return git_merge_file(out, &ancestor, &ours, &theirs, copts);
|
|
|
|
}
|
|
|
|
|
2015-09-21 06:50:57 -05:00
|
|
|
void _go_git_setup_stash_apply_progress_callbacks(git_stash_apply_options *opts) {
|
|
|
|
opts->progress_cb = (git_stash_apply_progress_cb)stashApplyProgressCb;
|
|
|
|
}
|
|
|
|
|
|
|
|
int _go_git_stash_foreach(git_repository *repo, void *payload) {
|
|
|
|
return git_stash_foreach(repo, (git_stash_cb)&stashForeachCb, payload);
|
|
|
|
}
|
|
|
|
|
2016-04-21 09:34:51 -05:00
|
|
|
int _go_git_writestream_write(git_writestream *stream, const char *buffer, size_t len)
|
|
|
|
{
|
|
|
|
return stream->write(stream, buffer, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
int _go_git_writestream_close(git_writestream *stream)
|
|
|
|
{
|
|
|
|
return stream->close(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _go_git_writestream_free(git_writestream *stream)
|
|
|
|
{
|
|
|
|
stream->free(stream);
|
|
|
|
}
|
|
|
|
|
2013-03-05 13:53:04 -06:00
|
|
|
/* EOF */
|