From d0517805d84f0fdd6c1311eb00a0d4ff257b4e47 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Tue, 5 Jun 2012 11:47:17 +0100 Subject: Required include for OS4 to typedef int64_t --- include/git2/types.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/git2') diff --git a/include/git2/types.h b/include/git2/types.h index b569e83c..8fdfd7fc 100644 --- a/include/git2/types.h +++ b/include/git2/types.h @@ -48,6 +48,9 @@ GIT_BEGIN_DECL * stat() functions, for all platforms. */ #include +#ifdef __amigaos4__ +#include +#endif #if defined(_MSC_VER) -- cgit v1.2.1 From 0f5e1f3b68eb68c257eb45b72650e8a653451a1d Mon Sep 17 00:00:00 2001 From: Chris Young Date: Thu, 7 Jun 2012 21:56:19 +0100 Subject: Network byte order is big-endian - the way it should be :) --- include/git2/common.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/git2') diff --git a/include/git2/common.h b/include/git2/common.h index 0e937980..4e6c2a57 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -55,6 +55,14 @@ #define GIT_WIN32 1 #endif +#ifdef __amigaos4__ +/* Network byte order is big-endian... so is PPC, so these functions are NOP */ +#define htonl(x) x +#define ntohl(x) x +#define htons(x) x +#define ntohs(x) x +#endif + /** * @file git2/common.h * @brief Git common platform definitions -- cgit v1.2.1 From 519757279eb25fe4075f65b86da5ce52d352b454 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Thu, 7 Jun 2012 23:13:39 +0100 Subject: Fix double-defines when using GIT_OLD_ERRORS --- include/git2/errors.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include/git2') diff --git a/include/git2/errors.h b/include/git2/errors.h index ccbc9fcf..b4809fe1 100644 --- a/include/git2/errors.h +++ b/include/git2/errors.h @@ -20,6 +20,7 @@ GIT_BEGIN_DECL #ifdef GIT_OLD_ERRORS enum { GIT_SUCCESS = 0, + GIT_ERROR = -1, GIT_ENOTOID = -2, GIT_ENOTFOUND = -3, GIT_ENOMEM = -4, @@ -52,7 +53,7 @@ enum { GIT_ENOMATCH = -31, GIT_ESHORTBUFFER = -32, }; -#endif +#else /** Generic return codes */ enum { @@ -66,6 +67,7 @@ enum { GIT_PASSTHROUGH = -30, GIT_REVWALKOVER = -31, }; +#endif typedef struct { char *message; -- cgit v1.2.1 From aa5a92d121d4fcc56d9661ce1c76534b410784c7 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Fri, 8 Jun 2012 18:57:35 +0100 Subject: OS4 compatibility --- include/git2/common.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/git2') diff --git a/include/git2/common.h b/include/git2/common.h index 4e6c2a57..b692c67e 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -107,6 +107,8 @@ GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src); */ GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev); +GIT_EXTERN(int) p_fnmatch(const char *pattern, const char *string, int flags); + /** @} */ GIT_END_DECL #endif -- cgit v1.2.1 From fa56478fb8d5e19d64bf43b51372ab3315cb1884 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Fri, 8 Jun 2012 19:15:11 +0100 Subject: Generic needs compat files --- include/git2/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/git2') diff --git a/include/git2/common.h b/include/git2/common.h index b692c67e..045ba85c 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -107,7 +107,7 @@ GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src); */ GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev); -GIT_EXTERN(int) p_fnmatch(const char *pattern, const char *string, int flags); +/* GIT_EXTERN(int) p_fnmatch(const char *pattern, const char *string, int flags); */ /** @} */ GIT_END_DECL -- cgit v1.2.1 From 327fb51cec5393bd84b560ad7df5b85298f96e3c Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 9 Jun 2012 18:13:07 +0100 Subject: Fix gethostbyname compatibility --- include/git2/common.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'include/git2') diff --git a/include/git2/common.h b/include/git2/common.h index 045ba85c..99018d4f 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -56,11 +56,7 @@ #endif #ifdef __amigaos4__ -/* Network byte order is big-endian... so is PPC, so these functions are NOP */ -#define htonl(x) x -#define ntohl(x) x -#define htons(x) x -#define ntohs(x) x +#include #endif /** -- cgit v1.2.1 From a8df98c6fb07b8ddff18a01d7f2f607d9493dd7c Mon Sep 17 00:00:00 2001 From: Chris Young Date: Thu, 14 Jun 2012 18:57:24 +0100 Subject: Updates from comments on OS4 compatibility pull request http://github.com/libgit2/libgit2/pull/766 --- include/git2/common.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include/git2') diff --git a/include/git2/common.h b/include/git2/common.h index 99018d4f..1af045cf 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -103,8 +103,6 @@ GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src); */ GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev); -/* GIT_EXTERN(int) p_fnmatch(const char *pattern, const char *string, int flags); */ - /** @} */ GIT_END_DECL #endif -- cgit v1.2.1 From a8fd805e2ff73a3825ddfe6f290774ef5a217972 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Thu, 21 Jun 2012 18:29:38 +0200 Subject: branch: add git_branch_foreach() --- include/git2/branch.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include/git2') diff --git a/include/git2/branch.h b/include/git2/branch.h index e2432bcf..f2239a20 100644 --- a/include/git2/branch.h +++ b/include/git2/branch.h @@ -95,6 +95,31 @@ GIT_EXTERN(int) git_branch_list( git_repository *repo, unsigned int list_flags); +/** + * Loop over all the branches and issue a callback for each one. + * + * @param repo Repository where to find the branches. + * + * @param list_flags Filtering flags for the branch + * 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_foreach( + git_repository *repo, + 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. * -- cgit v1.2.1 From d4827081ea3ed869c92fcc414bea81be7aa3edfe Mon Sep 17 00:00:00 2001 From: nulltoken Date: Thu, 21 Jun 2012 18:48:36 +0200 Subject: branch: drop git_branch_list() --- include/git2/branch.h | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'include/git2') diff --git a/include/git2/branch.h b/include/git2/branch.h index f2239a20..8884df15 100644 --- a/include/git2/branch.h +++ b/include/git2/branch.h @@ -71,30 +71,6 @@ GIT_EXTERN(int) git_branch_delete( const char *branch_name, 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. - * - * @param repo Repository where to find the branches. - * - * @param list_flags Filtering flags for the branch - * listing. Valid values are GIT_BRANCH_LOCAL, GIT_BRANCH_REMOTE - * or a combination of the two. - * - * @return 0 or an error code. - */ -GIT_EXTERN(int) git_branch_list( - git_strarray *branch_names, - git_repository *repo, - unsigned int list_flags); - /** * Loop over all the branches and issue a callback for each one. * -- cgit v1.2.1 From 798e4d53dcd2f5340782083130c0fb5227d596ac Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Fri, 22 Jun 2012 21:25:17 +0200 Subject: amigaos: Cleanup --- include/git2/errors.h | 40 +--------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) (limited to 'include/git2') diff --git a/include/git2/errors.h b/include/git2/errors.h index b4809fe1..ca7f0de6 100644 --- a/include/git2/errors.h +++ b/include/git2/errors.h @@ -17,44 +17,6 @@ */ GIT_BEGIN_DECL -#ifdef GIT_OLD_ERRORS -enum { - GIT_SUCCESS = 0, - GIT_ERROR = -1, - 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, -}; -#else - /** Generic return codes */ enum { GIT_OK = 0, @@ -67,13 +29,13 @@ enum { GIT_PASSTHROUGH = -30, GIT_REVWALKOVER = -31, }; -#endif typedef struct { char *message; int klass; } git_error; +/** Error classes */ typedef enum { GITERR_NOMEMORY, GITERR_OS, -- cgit v1.2.1 From 527ed55448fb8fceb93837426c60bb401b8e32ab Mon Sep 17 00:00:00 2001 From: nulltoken Date: Fri, 22 Jun 2012 15:51:44 +0200 Subject: references: introduce git_reference_foreach_glob() --- include/git2/refs.h | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'include/git2') diff --git a/include/git2/refs.h b/include/git2/refs.h index 2918215a..2aa0ac26 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,36 @@ 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 +); + /** @} */ GIT_END_DECL #endif -- cgit v1.2.1 From 371599576a82b43ab30fe66feadcfb3045e649ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Thu, 28 Jun 2012 09:33:08 +0200 Subject: indexer: don't use '/objects/pack/' unconditionally Not everyone who indexes a packfile wants to put it in the standard git repository location. --- include/git2/indexer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/git2') diff --git a/include/git2/indexer.h b/include/git2/indexer.h index 62637770..d300ba01 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 -- cgit v1.2.1 From 0e2fcca850e3021da4a08bc6487a10b35a75d05b Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Fri, 29 Jun 2012 02:21:12 +0200 Subject: tree: Bring back `entry_bypath` Smaller, simpler, faster. --- include/git2/tree.h | 67 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 14 deletions(-) (limited to 'include/git2') diff --git a/include/git2/tree.h b/include/git2/tree.h index 8f62e752..107c771c 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_copy`. + * + * @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_copy(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 { -- cgit v1.2.1 From 46ea40d9955a171187d252872f5c9bac1da7e286 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Fri, 29 Jun 2012 17:08:36 +0200 Subject: tree: Rename `entry_copy` to `entry_dup` --- include/git2/tree.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/git2') diff --git a/include/git2/tree.h b/include/git2/tree.h index 107c771c..f12b15e2 100644 --- a/include/git2/tree.h +++ b/include/git2/tree.h @@ -76,7 +76,7 @@ GIT_INLINE(void) git_tree_free(git_tree *tree) * * IMPORTANT: This function is only needed for tree * entries owned by the user, such as the ones returned - * by `git_tree_entry_copy`. + * by `git_tree_entry_dup`. * * @param entry The entry to free */ @@ -92,7 +92,7 @@ GIT_EXTERN(void) git_tree_entry_free(git_tree_entry *entry); * @param entry A tree entry to duplicate * @return a copy of the original entry */ -GIT_EXTERN(git_tree_entry *) git_tree_entry_copy(const git_tree_entry *entry); +GIT_EXTERN(git_tree_entry *) git_tree_entry_dup(const git_tree_entry *entry); /** * Get the id of a tree. -- cgit v1.2.1 From 29f9186d1b772994f65bb87ac88180d7d9d4141b Mon Sep 17 00:00:00 2001 From: yorah Date: Mon, 2 Jul 2012 11:18:01 +0200 Subject: diff: make inter-hunk-context default value git-compliant Default in git core is 0, not 3 --- include/git2/diff.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/git2') diff --git a/include/git2/diff.h b/include/git2/diff.h index d4d0eac4..edec9957 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 */ -- cgit v1.2.1 From 521aedad307c6f72d6f6d660943508b2b015f6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Tue, 5 Jun 2012 14:48:51 +0200 Subject: odb: add git_odb_foreach() Go through each backend and list every objects that exists in them. This allows fsck-like uses. --- include/git2/odb.h | 14 ++++++++++++++ include/git2/odb_backend.h | 6 ++++++ 2 files changed, 20 insertions(+) (limited to 'include/git2') diff --git a/include/git2/odb.h b/include/git2/odb.h index e2443178..dac9e06a 100644 --- a/include/git2/odb.h +++ b/include/git2/odb.h @@ -172,6 +172,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 * diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h index f4620f5f..3f67202d 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 *); }; -- cgit v1.2.1 From 4ea7c8c6660a33d27190133d0aed8437da432478 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 3 Jul 2012 12:35:33 -0700 Subject: Replace incorrect 'it' with 'if' in documentation --- include/git2/revwalk.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/git2') diff --git a/include/git2/revwalk.h b/include/git2/revwalk.h index 2e9dc421..d86bb28e 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 -- cgit v1.2.1 From 75261421ec00b6dc0a72931ed7640743a4998c7d Mon Sep 17 00:00:00 2001 From: nulltoken Date: Wed, 4 Jul 2012 11:58:04 +0200 Subject: refs: add git_reference_has_log() --- include/git2/refs.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/git2') diff --git a/include/git2/refs.h b/include/git2/refs.h index 2aa0ac26..7f6eb0e9 100644 --- a/include/git2/refs.h +++ b/include/git2/refs.h @@ -353,6 +353,16 @@ GIT_EXTERN(int) git_reference_foreach_glob( 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); + /** @} */ GIT_END_DECL #endif -- cgit v1.2.1 From 33c3370700083b9138b167778814d5af06ccf0b4 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Wed, 4 Jul 2012 12:20:43 +0200 Subject: refs: deploy git_reference_has_log() --- include/git2/reflog.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/git2') diff --git a/include/git2/reflog.h b/include/git2/reflog.h index f490e29d..8acba349 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 -- cgit v1.2.1 From b3ff1dab317dc9194c4bc124afd95ae9be2ad57b Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 10 Jul 2012 15:22:39 -0700 Subject: Adding git_config_foreach_match() iteration fn Adding a new config iteration function that let's you iterate over just the config entries that match a particular regular expression. The old foreach becomes a simple use of this with an empty pattern. This also fixes an apparent bug in the existing `git_config_foreach` where returning a non-zero value from the iteration callback was not correctly aborting the iteration and the returned value was not being propogated back to the caller of foreach. Added to tests to cover all these changes. --- include/git2/config.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'include/git2') diff --git a/include/git2/config.h b/include/git2/config.h index 36946c4a..c46e7fc9 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 -- cgit v1.2.1 From 991a56c704f931e7eb52a0583e5d8684803f3b04 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 10 Jul 2012 15:35:38 -0700 Subject: Add flag to write gitlink on setting repo workdir This added a flag to the `git_repository_set_workdir()` function that enables generation of a `.git` gitlink file that links the new workdir to the parent repository. Essentially, the flag tells the function to write out the changes to disk to permanently set the workdir of the repository to the new path. If you pass this flag as true, then setting the workdir to something other than the default workdir (i.e. the parent of the .git repo directory), will create a plain file named ".git" with the standard gitlink contents "gitdir: ", and also update the "core.worktree" and "core.bare" config values. Setting the workdir to the default repo workdir will clear the core.worktree flag (but still permanently set core.bare to false). BTW, the libgit2 API does not currently provide a function for clearing the workdir and converting a non-bare repo into a bare one. --- include/git2/repository.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include/git2') diff --git a/include/git2/repository.h b/include/git2/repository.h index 0b56a087..ff81b75e 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 -- cgit v1.2.1 From 8aedf1d5581f518da286ca4a33d6f7a98db38651 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Thu, 5 Jul 2012 17:02:03 +0200 Subject: signature: prevent angle bracket usage in identity --- include/git2/signature.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/git2') diff --git a/include/git2/signature.h b/include/git2/signature.h index cbf94269..cdbe6787 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 -- cgit v1.2.1 From b1aca6eae084ebe59c5a092314e94019c59ecec6 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Wed, 11 Jul 2012 16:14:12 +0200 Subject: commit: introduce git_commit_nth_gen_ancestor() --- include/git2/commit.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include/git2') diff --git a/include/git2/commit.h b/include/git2/commit.h index 640adf5c..5b6da520 100644 --- a/include/git2/commit.h +++ b/include/git2/commit.h @@ -178,6 +178,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 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 + */ +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. -- cgit v1.2.1 From 84f18e358742b77bfc815f2a360a41f3f1b9abd7 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Thu, 12 Jul 2012 00:44:07 +0200 Subject: refs: introduce git_reference_remote_tracking_from_branch() --- include/git2/refs.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'include/git2') diff --git a/include/git2/refs.h b/include/git2/refs.h index 7f6eb0e9..b119e90b 100644 --- a/include/git2/refs.h +++ b/include/git2/refs.h @@ -363,6 +363,27 @@ GIT_EXTERN(int) git_reference_foreach_glob( */ 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 -- cgit v1.2.1 From 1ebe432e2f685c72774aa5012f99fbb4845cffba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Thu, 12 Jul 2012 20:33:30 +0200 Subject: commit: properly export git_commit_nth_gen_ancestor() --- include/git2/commit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/git2') diff --git a/include/git2/commit.h b/include/git2/commit.h index 5b6da520..e8ecc808 100644 --- a/include/git2/commit.h +++ b/include/git2/commit.h @@ -192,7 +192,7 @@ GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned i * @return 0 on success; GIT_ENOTFOUND if no matching ancestor exists * or an error code */ -int git_commit_nth_gen_ancestor( +GIT_EXTERN(int) git_commit_nth_gen_ancestor( git_commit **ancestor, const git_commit *commit, unsigned int n); -- cgit v1.2.1 From 227f31311979a2fdb1ffc8dbcb4cf0737e7bc899 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Sun, 15 Jul 2012 14:11:58 +0200 Subject: attr: Rename the `git_attr__` exports Pevents collisions with the original libgit, which also exports those exact symbols. Fixes #822 --- include/git2/attr.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'include/git2') diff --git a/include/git2/attr.h b/include/git2/attr.h index 8f5a1268..fad7183d 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. -- cgit v1.2.1