diff options
| author | Ben Straub <bstraub@github.com> | 2012-07-17 08:08:34 -0700 |
|---|---|---|
| committer | Ben Straub <bstraub@github.com> | 2012-07-17 08:08:34 -0700 |
| commit | bfc65634050dc52e3ed6b4497ebbb511e39d6e1e (patch) | |
| tree | 32b03847b8a152b69bc3b48b6bb32e7b8621f45e /include | |
| parent | 1d68fcd04b21a2c5665d0ca6a5543e7166c73457 (diff) | |
| parent | ea5d2ce4cfa6cec89e2d844a70d1eb24bb401c7d (diff) | |
| download | libgit2-bfc65634050dc52e3ed6b4497ebbb511e39d6e1e.tar.gz | |
Merge branch 'development' into clone
Diffstat (limited to 'include')
| -rw-r--r-- | include/git2.h | 2 | ||||
| -rw-r--r-- | include/git2/attr.h | 16 | ||||
| -rw-r--r-- | include/git2/branch.h | 25 | ||||
| -rw-r--r-- | include/git2/commit.h | 19 | ||||
| -rw-r--r-- | include/git2/common.h | 4 | ||||
| -rw-r--r-- | include/git2/config.h | 20 | ||||
| -rw-r--r-- | include/git2/diff.h | 2 | ||||
| -rw-r--r-- | include/git2/errors.h | 38 | ||||
| -rw-r--r-- | include/git2/indexer.h | 4 | ||||
| -rw-r--r-- | include/git2/odb.h | 14 | ||||
| -rw-r--r-- | include/git2/odb_backend.h | 6 | ||||
| -rw-r--r-- | include/git2/reflog.h | 2 | ||||
| -rw-r--r-- | include/git2/refs.h | 62 | ||||
| -rw-r--r-- | include/git2/repository.h | 5 | ||||
| -rw-r--r-- | include/git2/revwalk.h | 4 | ||||
| -rw-r--r-- | include/git2/signature.h | 3 | ||||
| -rw-r--r-- | include/git2/tree.h | 67 | ||||
| -rw-r--r-- | include/git2/types.h | 3 |
18 files changed, 217 insertions, 79 deletions
diff --git a/include/git2.h b/include/git2.h index cab517d99..edb73e8a5 100644 --- a/include/git2.h +++ b/include/git2.h @@ -39,6 +39,8 @@ #include "git2/remote.h" #include "git2/clone.h" +#include "git2/attr.h" +#include "git2/branch.h" #include "git2/refspec.h" #include "git2/net.h" #include "git2/status.h" diff --git a/include/git2/attr.h b/include/git2/attr.h index 8f5a1268d..fad7183da 100644 --- a/include/git2/attr.h +++ b/include/git2/attr.h @@ -30,7 +30,7 @@ GIT_BEGIN_DECL * Then for file `xyz.c` looking up attribute "foo" gives a value for * which `GIT_ATTR_TRUE(value)` is true. */ -#define GIT_ATTR_TRUE(attr) ((attr) == git_attr__true) +#define GIT_ATTR_TRUE(attr) ((attr) == git_l_attr__true) /** * GIT_ATTR_FALSE checks if an attribute is set off. In core git @@ -44,7 +44,7 @@ GIT_BEGIN_DECL * Then for file `zyx.h` looking up attribute "foo" gives a value for * which `GIT_ATTR_FALSE(value)` is true. */ -#define GIT_ATTR_FALSE(attr) ((attr) == git_attr__false) +#define GIT_ATTR_FALSE(attr) ((attr) == git_l_attr__false) /** * GIT_ATTR_UNSPECIFIED checks if an attribute is unspecified. This @@ -62,7 +62,7 @@ GIT_BEGIN_DECL * file `onefile.rb` or looking up "bar" on any file will all give * `GIT_ATTR_UNSPECIFIED(value)` of true. */ -#define GIT_ATTR_UNSPECIFIED(attr) (!(attr) || (attr) == git_attr__unset) +#define GIT_ATTR_UNSPECIFIED(attr) (!(attr) || (attr) == git_l_attr__unset) /** * GIT_ATTR_HAS_VALUE checks if an attribute is set to a value (as @@ -75,12 +75,12 @@ GIT_BEGIN_DECL * string "lf" and `GIT_ATTR_SET_TO_VALUE(attr)` will return true. */ #define GIT_ATTR_HAS_VALUE(attr) \ - ((attr) && (attr) != git_attr__unset && \ - (attr) != git_attr__true && (attr) != git_attr__false) + ((attr) && (attr) != git_l_attr__unset && \ + (attr) != git_l_attr__true && (attr) != git_attr__false) -GIT_EXTERN(const char *) git_attr__true; -GIT_EXTERN(const char *) git_attr__false; -GIT_EXTERN(const char *) git_attr__unset; +GIT_EXTERN(const char *) git_l_attr__true; +GIT_EXTERN(const char *) git_l_attr__false; +GIT_EXTERN(const char *) git_l_attr__unset; /** * Check attribute flags: Reading values from index and working directory. diff --git a/include/git2/branch.h b/include/git2/branch.h index e2432bcfc..8884df15a 100644 --- a/include/git2/branch.h +++ b/include/git2/branch.h @@ -72,15 +72,7 @@ GIT_EXTERN(int) git_branch_delete( git_branch_t branch_type); /** - * Fill a list with all the branches in the Repository - * - * The string array will be filled with the names of the - * matching branches; these values are owned by the user and - * should be free'd manually when no longer needed, using - * `git_strarray_free`. - * - * @param branch_names Pointer to a git_strarray structure - * where the branch names will be stored. + * Loop over all the branches and issue a callback for each one. * * @param repo Repository where to find the branches. * @@ -88,12 +80,21 @@ GIT_EXTERN(int) git_branch_delete( * listing. Valid values are GIT_BRANCH_LOCAL, GIT_BRANCH_REMOTE * or a combination of the two. * + * @param branch_cb Callback to invoke per found branch. + * + * @param payload Extra parameter to callback function. + * * @return 0 or an error code. */ -GIT_EXTERN(int) git_branch_list( - git_strarray *branch_names, +GIT_EXTERN(int) git_branch_foreach( git_repository *repo, - unsigned int list_flags); + unsigned int list_flags, + int (*branch_cb)( + const char *branch_name, + git_branch_t branch_type, + void *payload), + void *payload +); /** * Move/rename an existing branch reference. diff --git a/include/git2/commit.h b/include/git2/commit.h index 640adf5c2..e8ecc808b 100644 --- a/include/git2/commit.h +++ b/include/git2/commit.h @@ -179,6 +179,25 @@ GIT_EXTERN(int) git_commit_parent(git_commit **parent, git_commit *commit, unsig GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned int n); /** + * Get the commit object that is the <n>th generation ancestor + * of the named commit object, following only the first parents. + * The returned commit has to be freed by the caller. + * + * Passing `0` as the generation number returns another instance of the + * base commit itself. + * + * @param ancestor Pointer where to store the ancestor commit + * @param commit a previously loaded commit. + * @param n the requested generation + * @return 0 on success; GIT_ENOTFOUND if no matching ancestor exists + * or an error code + */ +GIT_EXTERN(int) git_commit_nth_gen_ancestor( + git_commit **ancestor, + const git_commit *commit, + unsigned int n); + +/** * Create a new commit in the repository using `git_object` * instances as parameters. * diff --git a/include/git2/common.h b/include/git2/common.h index 0e9379804..1af045cff 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -55,6 +55,10 @@ #define GIT_WIN32 1 #endif +#ifdef __amigaos4__ +#include <netinet/in.h> +#endif + /** * @file git2/common.h * @brief Git common platform definitions diff --git a/include/git2/config.h b/include/git2/config.h index 36946c4a5..c46e7fc9d 100644 --- a/include/git2/config.h +++ b/include/git2/config.h @@ -33,7 +33,7 @@ struct git_config_file { int (*set)(struct git_config_file *, const char *key, const char *value); int (*set_multivar)(git_config_file *cfg, const char *name, const char *regexp, const char *value); int (*del)(struct git_config_file *, const char *key); - int (*foreach)(struct git_config_file *, int (*fn)(const char *, const char *, void *), void *data); + int (*foreach)(struct git_config_file *, const char *, int (*fn)(const char *, const char *, void *), void *data); void (*free)(struct git_config_file *); }; @@ -314,6 +314,24 @@ GIT_EXTERN(int) git_config_foreach( int (*callback)(const char *var_name, const char *value, void *payload), void *payload); +/** + * Perform an operation on each config variable matching a regular expression. + * + * This behaviors like `git_config_foreach` with an additional filter of a + * regular expression that filters which config keys are passed to the + * callback. + * + * @param cfg where to get the variables from + * @param regexp regular expression to match against config names + * @param callback the function to call on each variable + * @param payload the data to pass to the callback + * @return 0 or the return value of the callback which didn't return 0 + */ +GIT_EXTERN(int) git_config_foreach_match( + git_config *cfg, + const char *regexp, + int (*callback)(const char *var_name, const char *value, void *payload), + void *payload); /** * Query the value of a config variable and return it mapped to diff --git a/include/git2/diff.h b/include/git2/diff.h index d4d0eac47..edec9957b 100644 --- a/include/git2/diff.h +++ b/include/git2/diff.h @@ -60,7 +60,7 @@ enum { typedef struct { uint32_t flags; /**< defaults to GIT_DIFF_NORMAL */ uint16_t context_lines; /**< defaults to 3 */ - uint16_t interhunk_lines; /**< defaults to 3 */ + uint16_t interhunk_lines; /**< defaults to 0 */ char *old_prefix; /**< defaults to "a" */ char *new_prefix; /**< defaults to "b" */ git_strarray pathspec; /**< defaults to show all paths */ diff --git a/include/git2/errors.h b/include/git2/errors.h index ccbc9fcf4..ca7f0de6e 100644 --- a/include/git2/errors.h +++ b/include/git2/errors.h @@ -17,43 +17,6 @@ */ GIT_BEGIN_DECL -#ifdef GIT_OLD_ERRORS -enum { - GIT_SUCCESS = 0, - GIT_ENOTOID = -2, - GIT_ENOTFOUND = -3, - GIT_ENOMEM = -4, - GIT_EOSERR = -5, - GIT_EOBJTYPE = -6, - GIT_ENOTAREPO = -7, - GIT_EINVALIDTYPE = -8, - GIT_EMISSINGOBJDATA = -9, - GIT_EPACKCORRUPTED = -10, - GIT_EFLOCKFAIL = -11, - GIT_EZLIB = -12, - GIT_EBUSY = -13, - GIT_EBAREINDEX = -14, - GIT_EINVALIDREFNAME = -15, - GIT_EREFCORRUPTED = -16, - GIT_ETOONESTEDSYMREF = -17, - GIT_EPACKEDREFSCORRUPTED = -18, - GIT_EINVALIDPATH = -19, - GIT_EREVWALKOVER = -20, - GIT_EINVALIDREFSTATE = -21, - GIT_ENOTIMPLEMENTED = -22, - GIT_EEXISTS = -23, - GIT_EOVERFLOW = -24, - GIT_ENOTNUM = -25, - GIT_ESTREAM = -26, - GIT_EINVALIDARGS = -27, - GIT_EOBJCORRUPTED = -28, - GIT_EAMBIGUOUS = -29, - GIT_EPASSTHROUGH = -30, - GIT_ENOMATCH = -31, - GIT_ESHORTBUFFER = -32, -}; -#endif - /** Generic return codes */ enum { GIT_OK = 0, @@ -72,6 +35,7 @@ typedef struct { int klass; } git_error; +/** Error classes */ typedef enum { GITERR_NOMEMORY, GITERR_OS, diff --git a/include/git2/indexer.h b/include/git2/indexer.h index 626377701..d300ba01a 100644 --- a/include/git2/indexer.h +++ b/include/git2/indexer.h @@ -29,9 +29,9 @@ typedef struct git_indexer_stream git_indexer_stream; * Create a new streaming indexer instance * * @param out where to store the indexer instance - * @param path to the gitdir (metadata directory) + * @param path to the directory where the packfile should be stored */ -GIT_EXTERN(int) git_indexer_stream_new(git_indexer_stream **out, const char *gitdir); +GIT_EXTERN(int) git_indexer_stream_new(git_indexer_stream **out, const char *path); /** * Add data to the indexer diff --git a/include/git2/odb.h b/include/git2/odb.h index e2443178c..dac9e06a9 100644 --- a/include/git2/odb.h +++ b/include/git2/odb.h @@ -173,6 +173,20 @@ GIT_EXTERN(int) git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *d GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id); /** + * List all objects available in the database + * + * The callback will be called for each object available in the + * database. Note that the objects are likely to be returned in the + * index order, which would make accessing the objects in that order + * inefficient. + * + * @param db database to use + * @param cb the callback to call for each object + * @param data data to pass to the callback + */ +GIT_EXTERN(int) git_odb_foreach(git_odb *db, int (*cb)(git_oid *oid, void *data), void *data); + +/** * Write an object directly into the ODB * * This method writes a full object straight into the ODB. diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h index f4620f5f4..3f67202d1 100644 --- a/include/git2/odb_backend.h +++ b/include/git2/odb_backend.h @@ -71,6 +71,12 @@ struct git_odb_backend { struct git_odb_backend *, const git_oid *); + int (*foreach)( + struct git_odb_backend *, + int (*cb)(git_oid *oid, void *data), + void *data + ); + void (* free)(struct git_odb_backend *); }; diff --git a/include/git2/reflog.h b/include/git2/reflog.h index f490e29de..8acba349b 100644 --- a/include/git2/reflog.h +++ b/include/git2/reflog.h @@ -53,6 +53,8 @@ GIT_EXTERN(int) git_reflog_write(git_reference *ref, const git_oid *oid_old, con /** * Rename the reflog for the given reference * + * The reflog to be renamed is expected to already exist + * * @param ref the reference * @param new_name the new name of the reference * @return 0 or an error code diff --git a/include/git2/refs.h b/include/git2/refs.h index 2918215aa..b119e90b1 100644 --- a/include/git2/refs.h +++ b/include/git2/refs.h @@ -258,7 +258,6 @@ GIT_EXTERN(int) git_reference_packall(git_repository *repo); */ GIT_EXTERN(int) git_reference_list(git_strarray *array, git_repository *repo, unsigned int list_flags); - /** * Perform an operation on each reference in the repository * @@ -324,6 +323,67 @@ GIT_EXTERN(void) git_reference_free(git_reference *ref); */ GIT_EXTERN(int) git_reference_cmp(git_reference *ref1, git_reference *ref2); +/** + * Loop over all the references and issue a callback for each one + * which name matches the given glob pattern. + * + * The processed references may be filtered by type, or using + * a bitwise OR of several types. Use the magic value + * `GIT_REF_LISTALL` to obtain all references, including + * packed ones. + * + * @param repo Repository where to find the references. + * + * @param list_flags Filtering flags for the reference + * listing. + * + * @param callback Callback to invoke per found reference. + * + * @param payload Extra parameter to callback function. + * + * @return 0 or an error code. + */ +GIT_EXTERN(int) git_reference_foreach_glob( + git_repository *repo, + const char *glob, + unsigned int list_flags, + int (*callback)( + const char *reference_name, + void *payload), + void *payload +); + +/** + * Check if a reflog exists for the specified reference. + * + * @param ref A git reference + * + * @return 0 when no reflog can be found, 1 when it exists; + * otherwise an error code. + */ +GIT_EXTERN(int) git_reference_has_log(git_reference *ref); + + +/** + * Return the reference supporting the remote tracking branch, + * given a reference branch. + * + * The input reference has to be located in the `refs/heads` + * namespace. + * + * @param tracking_ref Pointer where to store the retrieved + * reference. + * + * @param branch_ref A git local branch reference. + * + * @return 0 on success; GIT_ENOTFOUND when no remote tracking + * reference exists, otherwise an error code. + */ +GIT_EXTERN(int) git_reference_remote_tracking_from_branch( + git_reference **tracking_ref, + git_reference *branch_ref +); + /** @} */ GIT_END_DECL #endif diff --git a/include/git2/repository.h b/include/git2/repository.h index 0b56a0870..ff81b75ec 100644 --- a/include/git2/repository.h +++ b/include/git2/repository.h @@ -194,9 +194,12 @@ GIT_EXTERN(const char *) git_repository_workdir(git_repository *repo); * * @param repo A repository object * @param workdir The path to a working directory + * @param update_gitlink Create/update gitlink in workdir and set config + * "core.worktree" (if workdir is not the parent of the .git directory) * @return 0, or an error code */ -GIT_EXTERN(int) git_repository_set_workdir(git_repository *repo, const char *workdir); +GIT_EXTERN(int) git_repository_set_workdir( + git_repository *repo, const char *workdir, int update_gitlink); /** * Check if a repository is bare diff --git a/include/git2/revwalk.h b/include/git2/revwalk.h index 2e9dc421a..d86bb28eb 100644 --- a/include/git2/revwalk.h +++ b/include/git2/revwalk.h @@ -107,7 +107,7 @@ GIT_EXTERN(int) git_revwalk_push(git_revwalk *walk, const git_oid *oid); * The OIDs pointed to by the references that match the given glob * pattern will be pushed to the revision walker. * - * A leading 'refs/' is implied it not present as well as a trailing + * A leading 'refs/' is implied if not present as well as a trailing * '/ *' if the glob lacks '?', '*' or '['. * * @param walk the walker being used for the traversal @@ -146,7 +146,7 @@ GIT_EXTERN(int) git_revwalk_hide(git_revwalk *walk, const git_oid *oid); * pattern and their ancestors will be hidden from the output on the * revision walk. * - * A leading 'refs/' is implied it not present as well as a trailing + * A leading 'refs/' is implied if not present as well as a trailing * '/ *' if the glob lacks '?', '*' or '['. * * @param walk the walker being used for the traversal diff --git a/include/git2/signature.h b/include/git2/signature.h index cbf94269f..cdbe67879 100644 --- a/include/git2/signature.h +++ b/include/git2/signature.h @@ -23,6 +23,9 @@ GIT_BEGIN_DECL * Create a new action signature. The signature must be freed * manually or using git_signature_free * + * Note: angle brackets ('<' and '>') characters are not allowed + * to be used in either the `name` or the `email` parameter. + * * @param sig_out new signature, in case of error NULL * @param name name of the person * @param email email of the person diff --git a/include/git2/tree.h b/include/git2/tree.h index 8f62e752a..f12b15e2e 100644 --- a/include/git2/tree.h +++ b/include/git2/tree.h @@ -46,7 +46,11 @@ GIT_INLINE(int) git_tree_lookup(git_tree **tree, git_repository *repo, const git * @param len the length of the short identifier * @return 0 or an error code */ -GIT_INLINE(int) git_tree_lookup_prefix(git_tree **tree, git_repository *repo, const git_oid *id, unsigned int len) +GIT_INLINE(int) git_tree_lookup_prefix( + git_tree **tree, + git_repository *repo, + const git_oid *id, + unsigned int len) { return git_object_lookup_prefix((git_object **)tree, repo, id, len, GIT_OBJ_TREE); } @@ -62,12 +66,33 @@ GIT_INLINE(int) git_tree_lookup_prefix(git_tree **tree, git_repository *repo, co * * @param tree the tree to close */ - GIT_INLINE(void) git_tree_free(git_tree *tree) { git_object_free((git_object *) tree); } +/** + * Free a tree entry + * + * IMPORTANT: This function is only needed for tree + * entries owned by the user, such as the ones returned + * by `git_tree_entry_dup`. + * + * @param entry The entry to free + */ +GIT_EXTERN(void) git_tree_entry_free(git_tree_entry *entry); + +/** + * Duplicate a tree entry + * + * Create a copy of a tree entry. The returned copy is owned + * by the user, and must be freed manually with + * `git_tree_entry_free`. + * + * @param entry A tree entry to duplicate + * @return a copy of the original entry + */ +GIT_EXTERN(git_tree_entry *) git_tree_entry_dup(const git_tree_entry *entry); /** * Get the id of a tree. @@ -143,7 +168,10 @@ GIT_EXTERN(git_otype) git_tree_entry_type(const git_tree_entry *entry); * @param entry a tree entry * @return 0 or an error code */ -GIT_EXTERN(int) git_tree_entry_to_object(git_object **object_out, git_repository *repo, const git_tree_entry *entry); +GIT_EXTERN(int) git_tree_entry_to_object( + git_object **object_out, + git_repository *repo, + const git_tree_entry *entry); /** * Write a tree to the ODB from the index file @@ -231,7 +259,12 @@ GIT_EXTERN(const git_tree_entry *) git_treebuilder_get(git_treebuilder *bld, con * @param attributes Folder attributes of the entry * @return 0 or an error code */ -GIT_EXTERN(int) git_treebuilder_insert(git_tree_entry **entry_out, git_treebuilder *bld, const char *filename, const git_oid *id, unsigned int attributes); +GIT_EXTERN(int) git_treebuilder_insert( + const git_tree_entry **entry_out, + git_treebuilder *bld, + const char *filename, + const git_oid *id, + unsigned int attributes); /** * Remove an entry from the builder by its filename @@ -252,7 +285,10 @@ GIT_EXTERN(int) git_treebuilder_remove(git_treebuilder *bld, const char *filenam * @param bld Tree builder * @param filter Callback to filter entries */ -GIT_EXTERN(void) git_treebuilder_filter(git_treebuilder *bld, int (*filter)(const git_tree_entry *, void *), void *payload); +GIT_EXTERN(void) git_treebuilder_filter( + git_treebuilder *bld, + int (*filter)(const git_tree_entry *, void *), + void *payload); /** * Write the contents of the tree builder as a tree object @@ -269,21 +305,24 @@ GIT_EXTERN(void) git_treebuilder_filter(git_treebuilder *bld, int (*filter)(cons GIT_EXTERN(int) git_treebuilder_write(git_oid *oid, git_repository *repo, git_treebuilder *bld); /** - * Retrieve a subtree contained in a tree, given its - * relative path. + * Retrieve a tree entry contained in a tree or in any + * of its subtrees, given its relative path. * - * The returned tree is owned by the repository and - * should be closed with the `git_object_free` method. + * The returned tree entry is owned by the user and must + * be freed manually with `git_tree_entry_free`. * - * @param subtree Pointer where to store the subtree + * @param entry Pointer where to store the tree entry * @param root A previously loaded tree which will be the root of the relative path - * @param subtree_path Path to the contained subtree - * @return 0 on success; GIT_ENOTFOUND if the path does not lead to a subtree + * @param subtree_path Path to the contained entry + * @return 0 on success; GIT_ENOTFOUND if the path does not exist */ -GIT_EXTERN(int) git_tree_get_subtree(git_tree **subtree, git_tree *root, const char *subtree_path); +GIT_EXTERN(int) git_tree_entry_bypath( + git_tree_entry **entry, + git_tree *root, + const char *path); /** Callback for the tree traversal method */ -typedef int (*git_treewalk_cb)(const char *root, git_tree_entry *entry, void *payload); +typedef int (*git_treewalk_cb)(const char *root, const git_tree_entry *entry, void *payload); /** Tree traversal modes */ enum git_treewalk_mode { diff --git a/include/git2/types.h b/include/git2/types.h index b4b48afa3..691903005 100644 --- a/include/git2/types.h +++ b/include/git2/types.h @@ -32,6 +32,9 @@ GIT_BEGIN_DECL * stat() functions, for all platforms. */ #include <sys/types.h> +#ifdef __amigaos4__ +#include <stdint.h> +#endif #if defined(_MSC_VER) |
