diff options
Diffstat (limited to 'include/git2')
-rw-r--r-- | include/git2/common.h | 5 | ||||
-rw-r--r-- | include/git2/errors.h | 1 | ||||
-rw-r--r-- | include/git2/object.h | 11 | ||||
-rw-r--r-- | include/git2/push.h | 80 | ||||
-rw-r--r-- | include/git2/transport.h | 40 | ||||
-rw-r--r-- | include/git2/types.h | 1 |
6 files changed, 127 insertions, 11 deletions
diff --git a/include/git2/common.h b/include/git2/common.h index dd6909f90..ad23d2d34 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -86,6 +86,11 @@ GIT_BEGIN_DECL #define GIT_PATH_MAX 4096 /** + * The string representation of the null object ID. + */ +#define GIT_OID_HEX_ZERO "0000000000000000000000000000000000000000" + +/** * Return the version of the libgit2 library * being currently used. * diff --git a/include/git2/errors.h b/include/git2/errors.h index 45e04578d..9dd42f0c4 100644 --- a/include/git2/errors.h +++ b/include/git2/errors.h @@ -29,6 +29,7 @@ enum { GIT_EBAREREPO = -8, GIT_EORPHANEDHEAD = -9, GIT_EUNMERGED = -10, + GIT_ENONFASTFORWARD = -11, GIT_PASSTHROUGH = -30, GIT_ITEROVER = -31, diff --git a/include/git2/object.h b/include/git2/object.h index fcc56cb27..66d692161 100644 --- a/include/git2/object.h +++ b/include/git2/object.h @@ -95,6 +95,17 @@ GIT_EXTERN(const git_oid *) git_object_id(const git_object *obj); GIT_EXTERN(git_otype) git_object_type(const git_object *obj); /** + * Get the object type of an object id + * + * @param obj the repository object + * @return the object's type + */ +GIT_EXTERN(int) git_object_oid2type( + git_otype *type, + git_repository *repo, + const git_oid *oid); + +/** * Get the repository that owns this object * * Freeing or calling `git_repository_close` on the diff --git a/include/git2/push.h b/include/git2/push.h new file mode 100644 index 000000000..900a1833e --- /dev/null +++ b/include/git2/push.h @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2009-2012 the libgit2 contributors + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_push_h__ +#define INCLUDE_git_push_h__ + +#include "common.h" + +/** + * @file git2/push.h + * @brief Git push management functions + * @defgroup git_push push management functions + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Create a new push object + * + * @param out New push object + * @param remote Remote instance + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_push_new(git_push **out, git_remote *remote); + +/** + * Add a refspec to be pushed + * + * @param push The push object + * @param refspec Refspec string + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_push_add_refspec(git_push *push, const char *refspec); + +/** + * Actually push all given refspecs + * + * @param push The push object + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_push_finish(git_push *push); + +/** + * Check if remote side successfully unpacked + * + * @param push The push object + * + * @return true if equal, false otherwise + */ +GIT_EXTERN(int) git_push_unpack_ok(git_push *push); + +/** + * Call callback `cb' on each status + * + * @param push The push object + * @param cb The callback to call on each object + * + * @return 0 on success, GIT_EUSER on non-zero callback, or error code + */ +GIT_EXTERN(int) git_push_status_foreach(git_push *push, + int (*cb)(const char *ref, const char *msg, void *data), + void *data); + +/** + * Free the given push object + * + * @param push The push object + */ +GIT_EXTERN(void) git_push_free(git_push *push); + +/** @} */ +GIT_END_DECL +#endif diff --git a/include/git2/transport.h b/include/git2/transport.h index 5a27d7f97..61726922f 100644 --- a/include/git2/transport.h +++ b/include/git2/transport.h @@ -9,6 +9,7 @@ #include "indexer.h" #include "net.h" +#include "types.h" /** * @file git2/transport.h @@ -102,8 +103,8 @@ typedef struct git_transport { git_headlist_cb list_cb, void *payload); - /* Reserved until push is implemented. */ - int (*push)(struct git_transport *transport); + /* Executes the push whose context is in the git_push object. */ + int (*push)(struct git_transport *transport, git_push *push); /* This function may be called after a successful call to connect(), when * the direction is FETCH. The function performs a negotiation to calculate @@ -123,7 +124,7 @@ typedef struct git_transport { void *progress_payload); /* Checks to see if the transport is connected */ - int (*is_connected)(struct git_transport *transport, int *connected); + int (*is_connected)(struct git_transport *transport); /* Reads the flags value previously passed into connect() */ int (*read_flags)(struct git_transport *transport, int *flags); @@ -145,10 +146,11 @@ typedef struct git_transport { * git:// or http://) and a transport object is returned to the caller. * * @param out The newly created transport (out) + * @param owner The git_remote which will own this transport * @param url The URL to connect to * @return 0 or an error code */ -GIT_EXTERN(int) git_transport_new(git_transport **out, const char *url); +GIT_EXTERN(int) git_transport_new(git_transport **out, git_remote *owner, const char *url); /** * Function which checks to see if a transport could be created for the @@ -161,7 +163,7 @@ GIT_EXTERN(int) git_transport_new(git_transport **out, const char *url); GIT_EXTERN(int) git_transport_valid_url(const char *url); /* Signature of a function which creates a transport */ -typedef int (*git_transport_cb)(git_transport **out, void *payload); +typedef int (*git_transport_cb)(git_transport **out, git_remote *owner, void *param); /* Transports which come with libgit2 (match git_transport_cb). The expected * value for "param" is listed in-line below. */ @@ -169,34 +171,40 @@ typedef int (*git_transport_cb)(git_transport **out, void *payload); /** * Create an instance of the dummy transport. * - * @param transport The newly created transport (out) + * @param out The newly created transport (out) + * @param owner The git_remote which will own this transport * @param payload You must pass NULL for this parameter. * @return 0 or an error code */ GIT_EXTERN(int) git_transport_dummy( - git_transport **transport, + git_transport **out, + git_remote *owner, /* NULL */ void *payload); /** * Create an instance of the local transport. * - * @param transport The newly created transport (out) + * @param out The newly created transport (out) + * @param owner The git_remote which will own this transport * @param payload You must pass NULL for this parameter. * @return 0 or an error code */ GIT_EXTERN(int) git_transport_local( - git_transport **transport, + git_transport **out, + git_remote *owner, /* NULL */ void *payload); /** * Create an instance of the smart transport. * - * @param transport The newly created transport (out) + * @param out The newly created transport (out) + * @param owner The git_remote which will own this transport * @param payload A pointer to a git_smart_subtransport_definition * @return 0 or an error code */ GIT_EXTERN(int) git_transport_smart( - git_transport **transport, + git_transport **out, + git_remote *owner, /* (git_smart_subtransport_definition *) */ void *payload); /* @@ -221,6 +229,8 @@ GIT_EXTERN(int) git_transport_smart( typedef enum { GIT_SERVICE_UPLOADPACK_LS = 1, GIT_SERVICE_UPLOADPACK = 2, + GIT_SERVICE_RECEIVEPACK_LS = 3, + GIT_SERVICE_RECEIVEPACK = 4, } git_smart_service_t; struct git_smart_subtransport; @@ -255,6 +265,14 @@ typedef struct git_smart_subtransport { const char *url, git_smart_service_t action); + /* Subtransports are guaranteed a call to close() between + * calls to action(), except for the following two "natural" progressions + * of actions against a constant URL. + * + * 1. UPLOADPACK_LS -> UPLOADPACK + * 2. RECEIVEPACK_LS -> RECEIVEPACK */ + int (* close)(struct git_smart_subtransport *transport); + void (* free)(struct git_smart_subtransport *transport); } git_smart_subtransport; diff --git a/include/git2/types.h b/include/git2/types.h index 11bcf270f..06fcf3613 100644 --- a/include/git2/types.h +++ b/include/git2/types.h @@ -187,6 +187,7 @@ typedef enum { typedef struct git_refspec git_refspec; typedef struct git_remote git_remote; +typedef struct git_push git_push; typedef struct git_remote_head git_remote_head; typedef struct git_remote_callbacks git_remote_callbacks; |