diff options
Diffstat (limited to 'include/git2')
| -rw-r--r-- | include/git2/commit.h | 17 | ||||
| -rw-r--r-- | include/git2/index.h | 4 | ||||
| -rw-r--r-- | include/git2/indexer.h | 70 | ||||
| -rw-r--r-- | include/git2/net.h | 20 | ||||
| -rw-r--r-- | include/git2/oid.h | 5 | ||||
| -rw-r--r-- | include/git2/reflog.h | 4 | ||||
| -rw-r--r-- | include/git2/refspec.h | 3 | ||||
| -rw-r--r-- | include/git2/remote.h | 62 | ||||
| -rw-r--r-- | include/git2/signature.h | 10 | ||||
| -rw-r--r-- | include/git2/tag.h | 2 | ||||
| -rw-r--r-- | include/git2/transport.h | 8 | ||||
| -rw-r--r-- | include/git2/types.h | 2 |
12 files changed, 169 insertions, 38 deletions
diff --git a/include/git2/commit.h b/include/git2/commit.h index 84adef596..12646cf58 100644 --- a/include/git2/commit.h +++ b/include/git2/commit.h @@ -97,12 +97,16 @@ GIT_INLINE(void) git_commit_close(git_commit *commit) GIT_EXTERN(const git_oid *) git_commit_id(git_commit *commit); /** - * Get the short (one line) message of a commit. + * Get the encoding for the message of a commit, + * as a string representing a standard encoding name. + * + * The encoding may be NULL if the `encoding` header + * in the commit is missing; in that case UTF-8 is assumed. * * @param commit a previously loaded commit. - * @return the short message of a commit + * @return NULL, or the encoding */ -GIT_EXTERN(const char *) git_commit_message_short(git_commit *commit); +GIT_EXTERN(const char *) git_commit_message_encoding(git_commit *commit); /** * Get the full message of a commit. @@ -213,6 +217,11 @@ GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned i * @param committer Signature representing the committer and the * commit time of this commit * + * @param message_encoding The encoding for the message in the + * commit, represented with a standard encoding name. + * E.g. "UTF-8". If NULL, no encoding header is written and + * UTF-8 is assumed. + * * @param message Full message for this commit * * @param tree An instance of a `git_tree` object that will @@ -236,6 +245,7 @@ GIT_EXTERN(int) git_commit_create( const char *update_ref, const git_signature *author, const git_signature *committer, + const char *message_encoding, const char *message, const git_tree *tree, int parent_count, @@ -260,6 +270,7 @@ GIT_EXTERN(int) git_commit_create_v( const char *update_ref, const git_signature *author, const git_signature *committer, + const char *message_encoding, const char *message, const git_tree *tree, int parent_count, diff --git a/include/git2/index.h b/include/git2/index.h index d34ed0a92..18ab9b858 100644 --- a/include/git2/index.h +++ b/include/git2/index.h @@ -98,14 +98,14 @@ typedef struct git_index_entry { unsigned short flags; unsigned short flags_extended; - const char *path; + char *path; } git_index_entry; /** Representation of an unmerged file entry in the index. */ typedef struct git_index_entry_unmerged { unsigned int mode[3]; git_oid oid[3]; - const char *path; + char *path; } git_index_entry_unmerged; /** diff --git a/include/git2/indexer.h b/include/git2/indexer.h new file mode 100644 index 000000000..2852d7e6f --- /dev/null +++ b/include/git2/indexer.h @@ -0,0 +1,70 @@ +#ifndef _INCLUDE_git_indexer_h__ +#define _INCLUDE_git_indexer_h__ + +#include "git2/common.h" +#include "git2/oid.h" + +GIT_BEGIN_DECL + +/** + * This is passed as the first argument to the callback to allow the + * user to see the progress. + */ +typedef struct git_indexer_stats { + unsigned int total; + unsigned int processed; +} git_indexer_stats; + + +typedef struct git_indexer git_indexer; + +/** + * Create a new indexer instance + * + * @param out where to store the indexer instance + * @param packname the absolute filename of the packfile to index + */ +GIT_EXTERN(int) git_indexer_new(git_indexer **out, const char *packname); + +/** + * Iterate over the objects in the packfile and extract the information + * + * Indexing a packfile can be very expensive so this function is + * expected to be run in a worker thread and the stats used to provide + * feedback the user. + * + * @param idx the indexer instance + * @param stats storage for the running state + */ +GIT_EXTERN(int) git_indexer_run(git_indexer *idx, git_indexer_stats *stats); + +/** + * Write the index file to disk. + * + * The file will be stored as pack-$hash.idx in the same directory as + * the packfile. + * + * @param idx the indexer instance + */ +GIT_EXTERN(int) git_indexer_write(git_indexer *idx); + +/** + * Get the packfile's hash + * + * A packfile's name is derived from the sorted hashing of all object + * names. This is only correct after the index has been written to disk. + * + * @param idx the indexer instance + */ +GIT_EXTERN(const git_oid *) git_indexer_hash(git_indexer *idx); + +/** + * Free the indexer and its resources + * + * @param idx the indexer to free + */ +GIT_EXTERN(void) git_indexer_free(git_indexer *idx); + +GIT_END_DECL + +#endif diff --git a/include/git2/net.h b/include/git2/net.h index 01b307dae..d4f475527 100644 --- a/include/git2/net.h +++ b/include/git2/net.h @@ -29,6 +29,14 @@ #include "oid.h" #include "types.h" +/** + * @file git2/net.h + * @brief Git networking declarations + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + #define GIT_DEFAULT_PORT "9418" /* @@ -41,18 +49,12 @@ #define GIT_DIR_PUSH 1 /** - * @file git2/net.h - * @brief Git networking declarations - * @ingroup Git - * @{ - */ -GIT_BEGIN_DECL - -/** * Remote head description, given out on `ls` calls. */ struct git_remote_head { + int local:1; /* available locally */ git_oid oid; + git_oid loid; char *name; }; @@ -64,4 +66,6 @@ struct git_headarray { struct git_remote_head **heads; }; +/** @} */ +GIT_END_DECL #endif diff --git a/include/git2/oid.h b/include/git2/oid.h index 96f8649f0..8a0f134b9 100644 --- a/include/git2/oid.h +++ b/include/git2/oid.h @@ -48,10 +48,11 @@ GIT_BEGIN_DECL #define GIT_OID_MINPREFIXLEN 4 /** Unique identity of any object (commit, tree, blob, tag). */ -typedef struct { +typedef struct _git_oid git_oid; +struct _git_oid { /** raw binary formatted id */ unsigned char id[GIT_OID_RAWSZ]; -} git_oid; +}; /** * Parse a hex formatted object id into a git_oid. diff --git a/include/git2/reflog.h b/include/git2/reflog.h index 7f2781fc3..53b344733 100644 --- a/include/git2/reflog.h +++ b/include/git2/reflog.h @@ -91,7 +91,7 @@ GIT_EXTERN(const git_reflog_entry *) git_reflog_entry_byindex(git_reflog *reflog * @param entry a reflog entry * @return the old oid */ -GIT_EXTERN(char *) git_reflog_entry_oidold(const git_reflog_entry *entry); +GIT_EXTERN(const git_oid *) git_reflog_entry_oidold(const git_reflog_entry *entry); /** * Get the new oid @@ -99,7 +99,7 @@ GIT_EXTERN(char *) git_reflog_entry_oidold(const git_reflog_entry *entry); * @param entry a reflog entry * @return the new oid at this time */ -GIT_EXTERN(char *) git_reflog_entry_oidnew(const git_reflog_entry *entry); +GIT_EXTERN(const git_oid *) git_reflog_entry_oidnew(const git_reflog_entry *entry); /** * Get the committer of this entry diff --git a/include/git2/refspec.h b/include/git2/refspec.h index b5361edbb..dd0dc5873 100644 --- a/include/git2/refspec.h +++ b/include/git2/refspec.h @@ -72,4 +72,7 @@ int git_refspec_src_match(const git_refspec *refspec, const char *refname); * @preturn GIT_SUCCESS, GIT_ESHORTBUFFER or another error */ int git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, const char *name); + +GIT_END_DECL + #endif diff --git a/include/git2/remote.h b/include/git2/remote.h index 7775070d8..651e41075 100644 --- a/include/git2/remote.h +++ b/include/git2/remote.h @@ -28,6 +28,14 @@ #include "git2/common.h" #include "git2/repository.h" #include "git2/refspec.h" +/** + * @file git2/remote.h + * @brief Git remote management functions + * @defgroup git_remote remote management functions + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL /* * TODO: This functions still need to be implemented: @@ -38,13 +46,16 @@ */ /** - * @file git2/remote.h - * @brief Git remote management - * @defgroup git_remote Git remote management routines - * @ingroup Git - * @{ + * Create a new unnamed remote + * + * Useful when you don't want to store the remote + * + * @param out pointer to the new remote object + * @param repo the associtated repository + * @param url the remote repository's URL + * @return GIT_SUCCESS or an error message */ -GIT_BEGIN_DECL +int git_remote_new(git_remote **out, git_repository *repo, const char *url); /** * Get the information for a particular remote @@ -92,9 +103,12 @@ GIT_EXTERN(const git_refspec *) git_remote_pushspec(struct git_remote *remote); /** * Open a connection to a remote * - * The transport is selected based on the URL + * The transport is selected based on the URL. The direction argument + * is due to a limitation of the git protocol (over TCP or SSH) which + * starts up a specific binary which can only do the one or the other. * * @param remote the remote to connect to + * @param direction whether you want to receive or send data * @return GIT_SUCCESS or an error code */ GIT_EXTERN(int) git_remote_connect(struct git_remote *remote, int direction); @@ -111,12 +125,44 @@ GIT_EXTERN(int) git_remote_connect(struct git_remote *remote, int direction); GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headarray *refs); /** + * Negotiate what data needs to be exchanged to synchroize the remtoe + * and local references + * + * @param remote the remote you want to negotiate with + */ +GIT_EXTERN(int) git_remote_negotiate(git_remote *remote); + +/** + * Download the packfile + * + * The packfile is downloaded with a temporary filename, as it's final + * name is not known yet. If there was no packfile needed (all the + * objects were available locally), filename will be NULL and the + * function will return success. + * + * @param remote the remote to download from + * @param filename where to store the temproray filename + * @return GIT_SUCCESS or an error code + */ +GIT_EXTERN(int) git_remote_download(char **filename, git_remote *remote); + +/** * Free the memory associated with a remote * * @param remote the remote to free */ GIT_EXTERN(void) git_remote_free(struct git_remote *remote); -GIT_END_DECL +/** + * Update the tips to the new state + * + * Make sure that you only call this once you've successfully indexed + * or expanded the packfile. + * + * @param remote the remote to update + */ +GIT_EXTERN(int) git_remote_update_tips(struct git_remote *remote); +/** @} */ +GIT_END_DECL #endif diff --git a/include/git2/signature.h b/include/git2/signature.h index 4b5601783..f5d03ac77 100644 --- a/include/git2/signature.h +++ b/include/git2/signature.h @@ -41,23 +41,25 @@ GIT_BEGIN_DECL * Create a new action signature. The signature must be freed * manually or using git_signature_free * + * @param sig_out new signature, in case of error NULL * @param name name of the person * @param email email of the person * @param time time when the action happened * @param offset timezone offset in minutes for the time - * @return the new sig, NULL on out of memory + * @return 0 on success; error code otherwise */ -GIT_EXTERN(git_signature *) git_signature_new(const char *name, const char *email, git_time_t time, int offset); +GIT_EXTERN(int) git_signature_new(git_signature **sig_out, const char *name, const char *email, git_time_t time, int offset); /** * Create a new action signature with a timestamp of 'now'. The * signature must be freed manually or using git_signature_free * + * @param sig_out new signature, in case of error NULL * @param name name of the person * @param email email of the person - * @return the new sig, NULL on out of memory + * @return 0 on success; error code otherwise */ -GIT_EXTERN(git_signature *) git_signature_now(const char *name, const char *email); +GIT_EXTERN(int) git_signature_now(git_signature **sig_out, const char *name, const char *email); /** diff --git a/include/git2/tag.h b/include/git2/tag.h index 3c3266183..2b10d4525 100644 --- a/include/git2/tag.h +++ b/include/git2/tag.h @@ -231,7 +231,7 @@ GIT_EXTERN(int) git_tag_create_frombuffer( * A proper reference is written in the /refs/tags folder, * pointing to the provided target object */ -int git_tag_create_lightweight( +GIT_EXTERN(int) git_tag_create_lightweight( git_oid *oid, git_repository *repo, const char *tag_name, diff --git a/include/git2/transport.h b/include/git2/transport.h index 982b081f8..d19eb8a88 100644 --- a/include/git2/transport.h +++ b/include/git2/transport.h @@ -45,14 +45,6 @@ GIT_BEGIN_DECL */ GIT_EXTERN(int) git_transport_new(git_transport **transport, const char *url); -GIT_EXTERN(int) git_transport_connect(git_transport *transport, int direction); - -GIT_EXTERN(int) git_transport_ls(git_transport *transport, git_headarray *array); -GIT_EXTERN(int) git_transport_close(git_transport *transport); -GIT_EXTERN(void) git_transport_free(git_transport *transport); - -GIT_EXTERN(int) git_transport_add(git_transport *transport, const char *prefix); - /** @} */ GIT_END_DECL #endif diff --git a/include/git2/types.h b/include/git2/types.h index 9d14c3e2f..b9db4e529 100644 --- a/include/git2/types.h +++ b/include/git2/types.h @@ -25,6 +25,8 @@ #ifndef INCLUDE_git_types_h__ #define INCLUDE_git_types_h__ +#include "common.h" + /** * @file git2/types.h * @brief libgit2 base & compatibility types |
