summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2012-05-19 01:46:11 +0200
committerVicent Marti <tanoku@gmail.com>2012-05-19 01:46:11 +0200
commit5b9fac39d8a76b9139667c26a63e6b3f204b3977 (patch)
treee6ba28025f92c16563c4ffa8bc60b95f17d69691 /include/git2
parent7ef9f1b5606c2672105ecbbf34c022a71ef212fe (diff)
parentad5df35a47d56c3d716d7a56eac4aeb611987c11 (diff)
downloadlibgit2-5b9fac39d8a76b9139667c26a63e6b3f204b3977.tar.gz
Merge branch 'development'v0.17.0
Conflicts: .travis.yml
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/attr.h180
-rw-r--r--include/git2/blob.h22
-rw-r--r--include/git2/branch.h121
-rw-r--r--include/git2/commit.h21
-rw-r--r--include/git2/common.h7
-rw-r--r--include/git2/config.h131
-rw-r--r--include/git2/diff.h362
-rw-r--r--include/git2/errors.h128
-rw-r--r--include/git2/index.h20
-rw-r--r--include/git2/indexer.h47
-rw-r--r--include/git2/merge.h35
-rw-r--r--include/git2/net.h2
-rw-r--r--include/git2/notes.h139
-rw-r--r--include/git2/object.h4
-rw-r--r--include/git2/odb.h18
-rw-r--r--include/git2/odb_backend.h16
-rw-r--r--include/git2/oid.h21
-rw-r--r--include/git2/reflog.h10
-rw-r--r--include/git2/refs.h50
-rw-r--r--include/git2/refspec.h18
-rw-r--r--include/git2/remote.h84
-rw-r--r--include/git2/repository.h30
-rw-r--r--include/git2/revwalk.h80
-rw-r--r--include/git2/signature.h6
-rw-r--r--include/git2/status.h131
-rw-r--r--include/git2/submodule.h103
-rw-r--r--include/git2/tag.h36
-rw-r--r--include/git2/threads.h2
-rw-r--r--include/git2/tree.h55
-rw-r--r--include/git2/types.h12
-rw-r--r--include/git2/version.h6
-rw-r--r--include/git2/windows.h2
-rw-r--r--include/git2/zlib.h40
33 files changed, 1568 insertions, 371 deletions
diff --git a/include/git2/attr.h b/include/git2/attr.h
index f4c5975a6..28ca3bc1c 100644
--- a/include/git2/attr.h
+++ b/include/git2/attr.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -19,42 +19,186 @@
*/
GIT_BEGIN_DECL
-#define GIT_ATTR_TRUE git_attr__true
-#define GIT_ATTR_FALSE git_attr__false
-#define GIT_ATTR_UNSPECIFIED NULL
+/**
+ * GIT_ATTR_TRUE checks if an attribute is set on. In core git
+ * parlance, this the value for "Set" attributes.
+ *
+ * For example, if the attribute file contains:
+ *
+ * *.c foo
+ *
+ * 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)
-GIT_EXTERN(const char *)git_attr__true;
-GIT_EXTERN(const char *)git_attr__false;
+/**
+ * GIT_ATTR_FALSE checks if an attribute is set off. In core git
+ * parlance, this is the value for attributes that are "Unset" (not to
+ * be confused with values that a "Unspecified").
+ *
+ * For example, if the attribute file contains:
+ *
+ * *.h -foo
+ *
+ * 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)
+/**
+ * GIT_ATTR_UNSPECIFIED checks if an attribute is unspecified. This
+ * may be due to the attribute not being mentioned at all or because
+ * the attribute was explicitly set unspecified via the `!` operator.
+ *
+ * For example, if the attribute file contains:
+ *
+ * *.c foo
+ * *.h -foo
+ * onefile.c !foo
+ *
+ * Then for `onefile.c` looking up attribute "foo" yields a value with
+ * `GIT_ATTR_UNSPECIFIED(value)` of true. Also, looking up "foo" on
+ * 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)
/**
- * Lookup attribute for path returning string caller must free
+ * GIT_ATTR_HAS_VALUE checks if an attribute is set to a value (as
+ * opposied to TRUE, FALSE or UNSPECIFIED). This would be the case if
+ * for a file with something like:
+ *
+ * *.txt eol=lf
+ *
+ * Given this, looking up "eol" for `onefile.txt` will give back the
+ * 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)
+
+GIT_EXTERN(const char *) git_attr__true;
+GIT_EXTERN(const char *) git_attr__false;
+GIT_EXTERN(const char *) git_attr__unset;
+
+/**
+ * Check attribute flags: Reading values from index and working directory.
+ *
+ * When checking attributes, it is possible to check attribute files
+ * in both the working directory (if there is one) and the index (if
+ * there is one). You can explicitly choose where to check and in
+ * which order using the following flags.
+ *
+ * Core git usually checks the working directory then the index,
+ * except during a checkout when it checks the index first. It will
+ * use index only for creating archives or for a bare repo (if an
+ * index has been specified for the bare repo).
+ */
+#define GIT_ATTR_CHECK_FILE_THEN_INDEX 0
+#define GIT_ATTR_CHECK_INDEX_THEN_FILE 1
+#define GIT_ATTR_CHECK_INDEX_ONLY 2
+
+/**
+ * Check attribute flags: Using the system attributes file.
+ *
+ * Normally, attribute checks include looking in the /etc (or system
+ * equivalent) directory for a `gitattributes` file. Passing this
+ * flag will cause attribute checks to ignore that file.
+ */
+#define GIT_ATTR_CHECK_NO_SYSTEM (1 << 2)
+
+/**
+ * Look up the value of one git attribute for path.
+ *
+ * @param value_out Output of the value of the attribute. Use the GIT_ATTR_...
+ * macros to test for TRUE, FALSE, UNSPECIFIED, etc. or just
+ * use the string value for attributes set to a value. You
+ * should NOT modify or free this value.
+ * @param repo The repository containing the path.
+ * @param flags A combination of GIT_ATTR_CHECK... flags.
+ * @param path The path to check for attributes. Relative paths are
+ * interpreted relative to the repo root. The file does
+ * not have to exist, but if it does not, then it will be
+ * treated as a plain file (not a directory).
+ * @param name The name of the attribute to look up.
*/
GIT_EXTERN(int) git_attr_get(
- git_repository *repo, const char *path, const char *name,
- const char **value);
+ const char **value_out,
+ git_repository *repo,
+ uint32_t flags,
+ const char *path,
+ const char *name);
/**
- * Lookup list of attributes for path, populating array of strings
+ * Look up a list of git attributes for path.
+ *
+ * Use this if you have a known list of attributes that you want to
+ * look up in a single call. This is somewhat more efficient than
+ * calling `git_attr_get()` multiple times.
+ *
+ * For example, you might write:
+ *
+ * const char *attrs[] = { "crlf", "diff", "foo" };
+ * const char **values[3];
+ * git_attr_get_many(values, repo, 0, "my/fun/file.c", 3, attrs);
+ *
+ * Then you could loop through the 3 values to get the settings for
+ * the three attributes you asked about.
+ *
+ * @param values An array of num_attr entries that will have string
+ * pointers written into it for the values of the attributes.
+ * You should not modify or free the values that are written
+ * into this array (although of course, you should free the
+ * array itself if you allocated it).
+ * @param repo The repository containing the path.
+ * @param flags A combination of GIT_ATTR_CHECK... flags.
+ * @param path The path inside the repo to check attributes. This
+ * does not have to exist, but if it does not, then
+ * it will be treated as a plain file (i.e. not a directory).
+ * @param num_attr The number of attributes being looked up
+ * @param names An array of num_attr strings containing attribute names.
*/
GIT_EXTERN(int) git_attr_get_many(
- git_repository *repo, const char *path,
- size_t num_attr, const char **names,
- const char **values);
+ const char **values_out,
+ git_repository *repo,
+ uint32_t flags,
+ const char *path,
+ size_t num_attr,
+ const char **names);
/**
- * Perform an operation on each attribute of a path.
+ * Loop over all the git attributes for a path.
+ *
+ * @param repo The repository containing the path.
+ * @param flags A combination of GIT_ATTR_CHECK... flags.
+ * @param path The path inside the repo to check attributes. This
+ * does not have to exist, but if it does not, then
+ * it will be treated as a plain file (i.e. not a directory).
+ * @param callback The function that will be invoked on each attribute
+ * and attribute value. The name parameter will be the name
+ * of the attribute and the value will be the value it is
+ * set to, including possibly NULL if the attribute is
+ * explicitly set to UNSPECIFIED using the ! sign. This
+ * will be invoked only once per attribute name, even if
+ * there are multiple rules for a given file. The highest
+ * priority rule will be used.
+ * @param payload Passed on as extra parameter to callback function.
*/
GIT_EXTERN(int) git_attr_foreach(
- git_repository *repo, const char *path,
+ git_repository *repo,
+ uint32_t flags,
+ const char *path,
int (*callback)(const char *name, const char *value, void *payload),
void *payload);
/**
* Flush the gitattributes cache.
*
- * Call this if you have reason to believe that the attributes files
- * on disk no longer match the cached contents of memory.
+ * Call this if you have reason to believe that the attributes files on
+ * disk no longer match the cached contents of memory. This will cause
+ * the attributes files to be reloaded the next time that an attribute
+ * access function is called.
*/
GIT_EXTERN(void) git_attr_cache_flush(
git_repository *repo);
@@ -62,7 +206,7 @@ GIT_EXTERN(void) git_attr_cache_flush(
/**
* Add a macro definition.
*
- * Macros will automatically be loaded from the top level .gitattributes
+ * Macros will automatically be loaded from the top level `.gitattributes`
* file of the repository (plus the build-in "binary" macro). This
* function allows you to add others. For example, to add the default
* macro, you would call:
diff --git a/include/git2/blob.h b/include/git2/blob.h
index 8b9380d82..551770678 100644
--- a/include/git2/blob.h
+++ b/include/git2/blob.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -27,7 +27,7 @@ GIT_BEGIN_DECL
* @param blob pointer to the looked up blob
* @param repo the repo to use when locating the blob.
* @param id identity of the blob to locate.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_INLINE(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git_oid *id)
{
@@ -44,7 +44,7 @@ GIT_INLINE(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git
* @param repo the repo to use when locating the blob.
* @param id identity of the blob to locate.
* @param len the length of the short identifier
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_INLINE(int) git_blob_lookup_prefix(git_blob **blob, git_repository *repo, const git_oid *id, unsigned int len)
{
@@ -99,10 +99,22 @@ GIT_EXTERN(size_t) git_blob_rawsize(git_blob *blob);
* this repository cannot be bare
* @param path file from which the blob will be created,
* relative to the repository's working dir
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *path);
+/**
+ * Read a file from the filesystem and write its content
+ * to the Object Database as a loose blob
+ *
+ * @param oid return the id of the written blob
+ * @param repo repository where the blob will be written.
+ * this repository can be bare or not
+ * @param path file from which the blob will be created
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *oid, git_repository *repo, const char *path);
+
/**
* Write an in-memory buffer to the ODB as a blob
@@ -111,7 +123,7 @@ GIT_EXTERN(int) git_blob_create_fromfile(git_oid *oid, git_repository *repo, con
* @param repo repository where to blob will be written
* @param buffer data to be written into the blob
* @param len length of the data
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_blob_create_frombuffer(git_oid *oid, git_repository *repo, const void *buffer, size_t len);
diff --git a/include/git2/branch.h b/include/git2/branch.h
index 5a92cf570..e2432bcfc 100644
--- a/include/git2/branch.h
+++ b/include/git2/branch.h
@@ -1,15 +1,122 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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_branch_h__
-#define INCLUDE_branch_h__
+#ifndef INCLUDE_git_branch_h__
+#define INCLUDE_git_branch_h__
-struct git_branch {
- char *remote; /* TODO: Make this a git_remote */
- char *merge;
-};
+#include "common.h"
+#include "types.h"
+/**
+ * @file git2/branch.h
+ * @brief Git branch parsing routines
+ * @defgroup git_branch Git branch management
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Create a new branch pointing at a target commit
+ *
+ * A new direct reference will be created pointing to
+ * this target commit. If `force` is true and a reference
+ * already exists with the given name, it'll be replaced.
+ *
+ * @param oid_out Pointer where to store the OID of the target commit.
+ *
+ * @param repo Repository where to store the branch.
+ *
+ * @param branch_name Name for the branch; this name is
+ * validated for consistency. It should also not conflict with
+ * an already existing branch name.
+ *
+ * @param target Object to which this branch should point. This object
+ * must belong to the given `repo` and can either be a git_commit or a
+ * git_tag. When a git_tag is being passed, it should be dereferencable
+ * to a git_commit which oid will be used as the target of the branch.
+ *
+ * @param force Overwrite existing branch.
+ *
+ * @return 0 or an error code.
+ * A proper reference is written in the refs/heads namespace
+ * pointing to the provided target commit.
+ */
+GIT_EXTERN(int) git_branch_create(
+ git_oid *oid_out,
+ git_repository *repo,
+ const char *branch_name,
+ const git_object *target,
+ int force);
+
+/**
+ * Delete an existing branch reference.
+ *
+ * @param repo Repository where lives the branch.
+ *
+ * @param branch_name Name of the branch to be deleted;
+ * this name is validated for consistency.
+ *
+ * @param branch_type Type of the considered branch. This should
+ * be valued with either GIT_BRANCH_LOCAL or GIT_BRANCH_REMOTE.
+ *
+ * @return 0 on success, GIT_ENOTFOUND if the branch
+ * doesn't exist or an error code.
+ */
+GIT_EXTERN(int) git_branch_delete(
+ git_repository *repo,
+ 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);
+
+/**
+ * Move/rename an existing branch reference.
+ *
+ * @param repo Repository where lives the branch.
+ *
+ * @param old_branch_name Current name of the branch to be moved;
+ * this name is validated for consistency.
+ *
+ * @param new_branch_name Target name of the branch once the move
+ * is performed; this name is validated for consistency.
+ *
+ * @param force Overwrite existing branch.
+ *
+ * @return 0 on success, GIT_ENOTFOUND if the branch
+ * doesn't exist or an error code.
+ */
+GIT_EXTERN(int) git_branch_move(
+ git_repository *repo,
+ const char *old_branch_name,
+ const char *new_branch_name,
+ int force);
+
+/** @} */
+GIT_END_DECL
#endif
diff --git a/include/git2/commit.h b/include/git2/commit.h
index 4e91b34b9..a6d9bb0e3 100644
--- a/include/git2/commit.h
+++ b/include/git2/commit.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -28,7 +28,7 @@ GIT_BEGIN_DECL
* @param repo the repo to use when locating the commit.
* @param id identity of the commit to locate. If the object is
* an annotated tag it will be peeled back to the commit.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_INLINE(int) git_commit_lookup(git_commit **commit, git_repository *repo, const git_oid *id)
{
@@ -46,7 +46,7 @@ GIT_INLINE(int) git_commit_lookup(git_commit **commit, git_repository *repo, con
* @param id identity of the commit to locate. If the object is
* an annotated tag it will be peeled back to the commit.
* @param len the length of the short identifier
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_INLINE(int) git_commit_lookup_prefix(git_commit **commit, git_repository *repo, const git_oid *id, unsigned len)
{
@@ -135,7 +135,7 @@ GIT_EXTERN(const git_signature *) git_commit_author(git_commit *commit);
*
* @param tree_out pointer where to store the tree object
* @param commit a previously loaded commit.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_commit_tree(git_tree **tree_out, git_commit *commit);
@@ -163,7 +163,7 @@ GIT_EXTERN(unsigned int) git_commit_parentcount(git_commit *commit);
* @param parent Pointer where to store the parent commit
* @param commit a previously loaded commit.
* @param n the position of the parent (from 0 to `parentcount`)
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_commit_parent(git_commit **parent, git_commit *commit, unsigned int n);
@@ -182,6 +182,9 @@ GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned i
* Create a new commit in the repository using `git_object`
* instances as parameters.
*
+ * The message will be cleaned up from excess whitespace
+ * it will be made sure that the last line ends with a '\n'.
+ *
* @param oid Pointer where to store the OID of the
* newly created commit
*
@@ -191,7 +194,8 @@ GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned i
* will be updated to point to this commit. If the reference
* is not direct, it will be resolved to a direct reference.
* Use "HEAD" to update the HEAD of the current branch and
- * make it point to this commit
+ * make it point to this commit. If the reference doesn't
+ * exist yet, it will be created.
*
* @param author Signature representing the author and the authory
* time of this commit
@@ -217,7 +221,7 @@ GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned i
* array may be NULL if `parent_count` is 0 (root commit). All the
* given commits must be owned by the `repo`.
*
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
* The created commit will be written to the Object Database and
* the given reference will be updated to point to it
*/
@@ -237,6 +241,9 @@ GIT_EXTERN(int) git_commit_create(
* Create a new commit in the repository using a variable
* argument list.
*
+ * The message will be cleaned up from excess whitespace
+ * it will be made sure that the last line ends with a '\n'.
+ *
* The parents for the commit are specified as a variable
* list of pointers to `const git_commit *`. Note that this
* is a convenience method which may not be safe to export
diff --git a/include/git2/common.h b/include/git2/common.h
index eee918a23..0e9379804 100644
--- a/include/git2/common.h
+++ b/include/git2/common.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -51,7 +51,7 @@
# define GIT_FORMAT_PRINTF(a,b) /* empty */
#endif
-#if (defined(_WIN32) || defined(_WIN64)) && !defined(__CYGWIN__)
+#if (defined(_WIN32)) && !defined(__CYGWIN__)
#define GIT_WIN32 1
#endif
@@ -77,7 +77,7 @@ GIT_BEGIN_DECL
#endif
/**
- * The maximum length of a git valid git path.
+ * The maximum length of a valid git path.
*/
#define GIT_PATH_MAX 4096
@@ -87,6 +87,7 @@ typedef struct {
} git_strarray;
GIT_EXTERN(void) git_strarray_free(git_strarray *array);
+GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src);
/**
* Return the version of the libgit2 library
diff --git a/include/git2/config.h b/include/git2/config.h
index ffafd7959..36946c4a5 100644
--- a/include/git2/config.h
+++ b/include/git2/config.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -29,12 +29,27 @@ struct git_config_file {
/* Open means open the file/database and parse if necessary */
int (*open)(struct git_config_file *);
int (*get)(struct git_config_file *, const char *key, const char **value);
+ int (*get_multivar)(struct git_config_file *, const char *key, const char *regexp, int (*fn)(const char *, void *), void *data);
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);
void (*free)(struct git_config_file *);
};
+typedef enum {
+ GIT_CVAR_FALSE = 0,
+ GIT_CVAR_TRUE = 1,
+ GIT_CVAR_INT32,
+ GIT_CVAR_STRING
+} git_cvar_t;
+
+typedef struct {
+ git_cvar_t cvar_type;
+ const char *str_match;
+ int map_value;
+} git_cvar_map;
+
/**
* Locate the path to the global configuration file
*
@@ -47,10 +62,10 @@ struct git_config_file {
* global configuration file.
*
* @param global_config_path Buffer of GIT_PATH_MAX length to store the path
- * @return GIT_SUCCESS if a global configuration file has been
+ * @return 0 if a global configuration file has been
* found. Its path will be stored in `buffer`.
*/
-GIT_EXTERN(int) git_config_find_global(char *global_config_path);
+GIT_EXTERN(int) git_config_find_global(char *global_config_path, size_t length);
/**
* Locate the path to the system configuration file
@@ -59,10 +74,10 @@ GIT_EXTERN(int) git_config_find_global(char *global_config_path);
* %PROGRAMFILES%\Git\etc\gitconfig.
* @param system_config_path Buffer of GIT_PATH_MAX length to store the path
- * @return GIT_SUCCESS if a system configuration file has been
+ * @return 0 if a system configuration file has been
* found. Its path will be stored in `buffer`.
*/
-GIT_EXTERN(int) git_config_find_system(char *system_config_path);
+GIT_EXTERN(int) git_config_find_system(char *system_config_path, size_t length);
/**
* Open the global configuration file
@@ -71,7 +86,7 @@ GIT_EXTERN(int) git_config_find_system(char *system_config_path);
* and opens the located file, if it exists.
*
* @param out Pointer to store the config instance
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_open_global(git_config **out);
@@ -95,7 +110,7 @@ GIT_EXTERN(int) git_config_file__ondisk(struct git_config_file **out, const char
* can do anything with it.
*
* @param out pointer to the new configuration
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_new(git_config **out);
@@ -112,7 +127,7 @@ GIT_EXTERN(int) git_config_new(git_config **out);
* @param cfg the configuration to add the file to
* @param file the configuration file (backend) to add
* @param priority the priority the backend should have
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_add_file(git_config *cfg, git_config_file *file, int priority);
@@ -133,7 +148,7 @@ GIT_EXTERN(int) git_config_add_file(git_config *cfg, git_config_file *file, int
* @param cfg the configuration to add the file to
* @param path path to the configuration file (backend) to add
* @param priority the priority the backend should have
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_add_file_ondisk(git_config *cfg, const char *path, int priority);
@@ -148,7 +163,7 @@ GIT_EXTERN(int) git_config_add_file_ondisk(git_config *cfg, const char *path, in
*
* @param cfg The configuration instance to create
* @param path Path to the on-disk file to open
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_open_ondisk(git_config **cfg, const char *path);
@@ -162,22 +177,22 @@ GIT_EXTERN(void) git_config_free(git_config *cfg);
/**
* Get the value of an integer config variable.
*
+ * @param out pointer to the variable where the value should be stored
* @param cfg where to look for the variable
* @param name the variable's name
- * @param out pointer to the variable where the value should be stored
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
-GIT_EXTERN(int) git_config_get_int32(git_config *cfg, const char *name, int32_t *out);
+GIT_EXTERN(int) git_config_get_int32(int32_t *out, git_config *cfg, const char *name);
/**
* Get the value of a long integer config variable.
*
+ * @param out pointer to the variable where the value should be stored
* @param cfg where to look for the variable
* @param name the variable's name
- * @param out pointer to the variable where the value should be stored
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
-GIT_EXTERN(int) git_config_get_int64(git_config *cfg, const char *name, int64_t *out);
+GIT_EXTERN(int) git_config_get_int64(int64_t *out, git_config *cfg, const char *name);
/**
* Get the value of a boolean config variable.
@@ -185,12 +200,12 @@ GIT_EXTERN(int) git_config_get_int64(git_config *cfg, const char *name, int64_t
* This function uses the usual C convention of 0 being false and
* anything else true.
*
+ * @param out pointer to the variable where the value should be stored
* @param cfg where to look for the variable
* @param name the variable's name
- * @param out pointer to the variable where the value should be stored
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
-GIT_EXTERN(int) git_config_get_bool(git_config *cfg, const char *name, int *out);
+GIT_EXTERN(int) git_config_get_bool(int *out, git_config *cfg, const char *name);
/**
* Get the value of a string config variable.
@@ -198,12 +213,26 @@ GIT_EXTERN(int) git_config_get_bool(git_config *cfg, const char *name, int *out)
* The string is owned by the variable and should not be freed by the
* user.
*
+ * @param out pointer to the variable's value
+ * @param cfg where to look for the variable
+ * @param name the variable's name
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_config_get_string(const char **out, git_config *cfg, const char *name);
+
+/**
+ * Get each value of a multivar.
+ *
+ * The callback will be called on each variable found
+ *
* @param cfg where to look for the variable
* @param name the variable's name
- * @param out pointer to the variable's value
- * @return GIT_SUCCESS or an error code
+ * @param regexp regular expression to filter which variables we're
+ * interested in. Use NULL to indicate all
+ * @param fn the function to be called on each value of the variable
+ * @param data opaque pointer to pass to the callback
*/
-GIT_EXTERN(int) git_config_get_string(git_config *cfg, const char *name, const char **out);
+GIT_EXTERN(int) git_config_get_multivar(git_config *cfg, const char *name, const char *regexp, int (*fn)(const char *, void *), void *data);
/**
* Set the value of an integer config variable.
@@ -211,7 +240,7 @@ GIT_EXTERN(int) git_config_get_string(git_config *cfg, const char *name, const c
* @param cfg where to look for the variable
* @param name the variable's name
* @param value Integer value for the variable
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_set_int32(git_config *cfg, const char *name, int32_t value);
@@ -221,7 +250,7 @@ GIT_EXTERN(int) git_config_set_int32(git_config *cfg, const char *name, int32_t
* @param cfg where to look for the variable
* @param name the variable's name
* @param value Long integer value for the variable
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_set_int64(git_config *cfg, const char *name, int64_t value);
@@ -231,7 +260,7 @@ GIT_EXTERN(int) git_config_set_int64(git_config *cfg, const char *name, int64_t
* @param cfg where to look for the variable
* @param name the variable's name
* @param value the value to store
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_set_bool(git_config *cfg, const char *name, int value);
@@ -244,10 +273,21 @@ GIT_EXTERN(int) git_config_set_bool(git_config *cfg, const char *name, int value
* @param cfg where to look for the variable
* @param name the variable's name
* @param value the string to store.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_config_set_string(git_config *cfg, const char *name, const char *value);
+
+/**
+ * Set a multivar
+ *
+ * @param cfg where to look for the variable
+ * @param name the variable's name
+ * @param regexp a regular expression to indicate which values to replace
+ * @param value the new value.
+ */
+GIT_EXTERN(int) git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value);
+
/**
* Delete a config variable
*
@@ -267,13 +307,50 @@ GIT_EXTERN(int) git_config_delete(git_config *cfg, const char *name);
* @param cfg where to get the variables from
* @param callback the function to call on each variable
* @param payload the data to pass to the callback
- * @return GIT_SUCCESS or the return value of the callback which didn't return 0
+ * @return 0 or the return value of the callback which didn't return 0
*/
GIT_EXTERN(int) git_config_foreach(
git_config *cfg,
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
+ * an integer constant.
+ *
+ * This is a helper method to easily map different possible values
+ * to a variable to integer constants that easily identify them.
+ *
+ * A mapping array looks as follows:
+ *
+ * git_cvar_map autocrlf_mapping[3] = {
+ * {GIT_CVAR_FALSE, NULL, GIT_AUTO_CRLF_FALSE},
+ * {GIT_CVAR_TRUE, NULL, GIT_AUTO_CRLF_TRUE},
+ * {GIT_CVAR_STRING, "input", GIT_AUTO_CRLF_INPUT},
+ * {GIT_CVAR_STRING, "default", GIT_AUTO_CRLF_DEFAULT}};
+ *
+ * On any "false" value for the variable (e.g. "false", "FALSE", "no"), the
+ * mapping will store `GIT_AUTO_CRLF_FALSE` in the `out` parameter.
+ *
+ * The same thing applies for any "true" value such as "true", "yes" or "1", storing
+ * the `GIT_AUTO_CRLF_TRUE` variable.
+ *
+ * Otherwise, if the value matches the string "input" (with case insensitive comparison),
+ * the given constant will be stored in `out`, and likewise for "default".
+ *
+ * If not a single match can be made to store in `out`, an error code will be
+ * returned.
+ *
+ * @param out place to store the result of the mapping
+ * @param cfg config file to get the variables from
+ * @param name name of the config variable to lookup
+ * @param maps array of `git_cvar_map` objects specifying the possible mappings
+ * @param map_n number of mapping objects in `maps`
+ * @return 0 on success, error code otherwise
+ */
+GIT_EXTERN(int) git_config_get_mapped(int *out, git_config *cfg, const char *name, git_cvar_map *maps, size_t map_n);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/diff.h b/include/git2/diff.h
new file mode 100644
index 000000000..bafe6268c
--- /dev/null
+++ b/include/git2/diff.h
@@ -0,0 +1,362 @@
+/*
+ * 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_diff_h__
+#define INCLUDE_git_diff_h__
+
+#include "common.h"
+#include "types.h"
+#include "oid.h"
+#include "tree.h"
+#include "refs.h"
+
+/**
+ * @file git2/diff.h
+ * @brief Git tree and file differencing routines.
+ *
+ * Calculating diffs is generally done in two phases: building a diff list
+ * then traversing the diff list. This makes is easier to share logic
+ * across the various types of diffs (tree vs tree, workdir vs index, etc.),
+ * and also allows you to insert optional diff list post-processing phases,
+ * such as rename detected, in between the steps. When you are done with a
+ * diff list object, it must be freed.
+ *
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+enum {
+ GIT_DIFF_NORMAL = 0,
+ GIT_DIFF_REVERSE = (1 << 0),
+ GIT_DIFF_FORCE_TEXT = (1 << 1),
+ GIT_DIFF_IGNORE_WHITESPACE = (1 << 2),
+ GIT_DIFF_IGNORE_WHITESPACE_CHANGE = (1 << 3),
+ GIT_DIFF_IGNORE_WHITESPACE_EOL = (1 << 4),
+ GIT_DIFF_IGNORE_SUBMODULES = (1 << 5),
+ GIT_DIFF_PATIENCE = (1 << 6),
+ GIT_DIFF_INCLUDE_IGNORED = (1 << 7),
+ GIT_DIFF_INCLUDE_UNTRACKED = (1 << 8),
+ GIT_DIFF_INCLUDE_UNMODIFIED = (1 << 9),
+ GIT_DIFF_RECURSE_UNTRACKED_DIRS = (1 << 10),
+};
+
+/**
+ * Structure describing options about how the diff should be executed.
+ *
+ * Setting all values of the structure to zero will yield the default
+ * values. Similarly, passing NULL for the options structure will
+ * give the defaults. The default values are marked below.
+ *
+ * @todo Most of the parameters here are not actually supported at this time.
+ */
+typedef struct {
+ uint32_t flags; /**< defaults to GIT_DIFF_NORMAL */
+ uint16_t context_lines; /**< defaults to 3 */
+ uint16_t interhunk_lines; /**< defaults to 3 */
+ char *old_prefix; /**< defaults to "a" */
+ char *new_prefix; /**< defaults to "b" */
+ git_strarray pathspec; /**< defaults to show all paths */
+} git_diff_options;
+
+/**
+ * The diff list object that contains all individual file deltas.
+ */
+typedef struct git_diff_list git_diff_list;
+
+enum {
+ GIT_DIFF_FILE_VALID_OID = (1 << 0),
+ GIT_DIFF_FILE_FREE_PATH = (1 << 1),
+ GIT_DIFF_FILE_BINARY = (1 << 2),
+ GIT_DIFF_FILE_NOT_BINARY = (1 << 3),
+ GIT_DIFF_FILE_FREE_DATA = (1 << 4),
+ GIT_DIFF_FILE_UNMAP_DATA = (1 << 5)
+};
+
+/**
+ * What type of change is described by a git_diff_delta?
+ */
+typedef enum {
+ GIT_DELTA_UNMODIFIED = 0,
+ GIT_DELTA_ADDED = 1,
+ GIT_DELTA_DELETED = 2,
+ GIT_DELTA_MODIFIED = 3,
+ GIT_DELTA_RENAMED = 4,
+ GIT_DELTA_COPIED = 5,
+ GIT_DELTA_IGNORED = 6,
+ GIT_DELTA_UNTRACKED = 7
+} git_delta_t;
+
+/**
+ * Description of one side of a diff.
+ */
+typedef struct {
+ git_oid oid;
+ char *path;
+ uint16_t mode;
+ git_off_t size;
+ unsigned int flags;
+} git_diff_file;
+
+/**
+ * Description of changes to one file.
+ *
+ * When iterating over a diff list object, this will generally be passed to
+ * most callback functions and you can use the contents to understand
+ * exactly what has changed.
+ *
+ * Under some circumstances, not all fields will be filled in, but the code
+ * generally tries to fill in as much as possible. One example is that the
+ * "binary" field will not actually look at file contents if you do not
+ * pass in hunk and/or line callbacks to the diff foreach iteration function.
+ * It will just use the git attributes for those files.
+ */
+typedef struct {
+ git_diff_file old_file;
+ git_diff_file new_file;
+ git_delta_t status;
+ unsigned int similarity; /**< for RENAMED and COPIED, value 0-100 */
+ int binary;
+} git_diff_delta;
+
+/**
+ * When iterating over a diff, callback that will be made per file.
+ */
+typedef int (*git_diff_file_fn)(
+ void *cb_data,
+ git_diff_delta *delta,
+ float progress);
+
+/**
+ * Structure describing a hunk of a diff.
+ */
+typedef struct {
+ int old_start;
+ int old_lines;
+ int new_start;
+ int new_lines;
+} git_diff_range;
+
+/**
+ * When iterating over a diff, callback that will be made per hunk.
+ */
+typedef int (*git_diff_hunk_fn)(
+ void *cb_data,
+ git_diff_delta *delta,
+ git_diff_range *range,
+ const char *header,
+ size_t header_len);
+
+/**
+ * Line origin constants.
+ *
+ * These values describe where a line came from and will be passed to
+ * the git_diff_data_fn when iterating over a diff. There are some
+ * special origin contants at the end that are used for the text
+ * output callbacks to demarcate lines that are actually part of
+ * the file or hunk headers.
+ */
+enum {
+ /* these values will be sent to `git_diff_data_fn` along with the line */
+ GIT_DIFF_LINE_CONTEXT = ' ',
+ GIT_DIFF_LINE_ADDITION = '+',
+ GIT_DIFF_LINE_DELETION = '-',
+ GIT_DIFF_LINE_ADD_EOFNL = '\n', /**< LF was added at end of file */
+ GIT_DIFF_LINE_DEL_EOFNL = '\0', /**< LF was removed at end of file */
+ /* these values will only be sent to a `git_diff_data_fn` when the content
+ * of a diff is being formatted (eg. through git_diff_print_patch() or
+ * git_diff_print_compact(), for instance).
+ */
+ GIT_DIFF_LINE_FILE_HDR = 'F',
+ GIT_DIFF_LINE_HUNK_HDR = 'H',
+ GIT_DIFF_LINE_BINARY = 'B'
+};
+
+/**
+ * When iterating over a diff, callback that will be made per text diff
+ * line. In this context, the provided range will be NULL.
+ *
+ * When printing a diff, callback that will be made to output each line
+ * of text. This uses some extra GIT_DIFF_LINE_... constants for output
+ * of lines of file and hunk headers.
+ */
+typedef int (*git_diff_data_fn)(
+ void *cb_data,
+ git_diff_delta *delta,
+ git_diff_range *range,
+ char line_origin, /**< GIT_DIFF_LINE_... value from above */
+ const char *content,
+ size_t content_len);
+
+/** @name Diff List Generator Functions
+ *
+ * These are the functions you would use to create (or destroy) a
+ * git_diff_list from various objects in a repository.
+ */
+/**@{*/
+
+/**
+ * Deallocate a diff list.
+ */
+GIT_EXTERN(void) git_diff_list_free(git_diff_list *diff);
+
+/**
+ * Compute a difference between two tree objects.
+ *
+ * @param repo The repository containing the trees.
+ * @param opts Structure with options to influence diff or NULL for defaults.
+ * @param old_tree A git_tree object to diff from.
+ * @param new_tree A git_tree object to diff to.
+ * @param diff A pointer to a git_diff_list pointer that will be allocated.
+ */
+GIT_EXTERN(int) git_diff_tree_to_tree(
+ git_repository *repo,
+ const git_diff_options *opts, /**< can be NULL for defaults */
+ git_tree *old_tree,
+ git_tree *new_tree,
+ git_diff_list **diff);
+
+/**
+ * Compute a difference between a tree and the index.
+ *
+ * @param repo The repository containing the tree and index.
+ * @param opts Structure with options to influence diff or NULL for defaults.
+ * @param old_tree A git_tree object to diff from.
+ * @param diff A pointer to a git_diff_list pointer that will be allocated.
+ */
+GIT_EXTERN(int) git_diff_index_to_tree(
+ git_repository *repo,
+ const git_diff_options *opts, /**< can be NULL for defaults */
+ git_tree *old_tree,
+ git_diff_list **diff);
+
+/**
+ * Compute a difference between the working directory and the index.
+ *
+ * @param repo The repository.
+ * @param opts Structure with options to influence diff or NULL for defaults.
+ * @param diff A pointer to a git_diff_list pointer that will be allocated.
+ */
+GIT_EXTERN(int) git_diff_workdir_to_index(
+ git_repository *repo,
+ const git_diff_options *opts, /**< can be NULL for defaults */
+ git_diff_list **diff);
+
+/**
+ * Compute a difference between the working directory and a tree.
+ *
+ * This returns strictly the differences between the tree and the
+ * files contained in the working directory, regardless of the state
+ * of files in the index. There is no direct equivalent in C git.
+ *
+ * This is *NOT* the same as 'git diff HEAD' or 'git diff <SHA>'. Those
+ * commands diff the tree, the index, and the workdir. To emulate those
+ * functions, call `git_diff_index_to_tree` and `git_diff_workdir_to_index`,
+ * then call `git_diff_merge` on the results.
+ *
+ * @param repo The repository containing the tree.
+ * @param opts Structure with options to influence diff or NULL for defaults.
+ * @param old_tree A git_tree object to diff from.
+ * @param diff A pointer to a git_diff_list pointer that will be allocated.
+ */
+GIT_EXTERN(int) git_diff_workdir_to_tree(
+ git_repository *repo,
+ const git_diff_options *opts, /**< can be NULL for defaults */
+ git_tree *old_tree,
+ git_diff_list **diff);
+
+/**
+ * Merge one diff list into another.
+ *
+ * This merges items from the "from" list into the "onto" list. The
+ * resulting diff list will have all items that appear in either list.
+ * If an item appears in both lists, then it will be "merged" to appear
+ * as if the old version was from the "onto" list and the new version
+ * is from the "from" list (with the exception that if the item has a
+ * pending DELETE in the middle, then it will show as deleted).
+ *
+ * @param onto Diff to merge into.
+ * @param from Diff to merge.
+ */
+GIT_EXTERN(int) git_diff_merge(
+ git_diff_list *onto,
+ const git_diff_list *from);
+
+/**@}*/
+
+
+/** @name Diff List Processor Functions
+ *
+ * These are the functions you apply to a diff list to process it
+ * or read it in some way.
+ */
+/**@{*/
+
+/**
+ * Iterate over a diff list issuing callbacks.
+ *
+ * If the hunk and/or line callbacks are not NULL, then this will calculate
+ * text diffs for all files it thinks are not binary. If those are both
+ * NULL, then this will not bother with the text diffs, so it can be
+ * efficient.
+ */
+GIT_EXTERN(int) git_diff_foreach(
+ git_diff_list *diff,
+ void *cb_data,
+ git_diff_file_fn file_cb,
+ git_diff_hunk_fn hunk_cb,
+ git_diff_data_fn line_cb);
+
+/**
+ * Iterate over a diff generating text output like "git diff --name-status".
+ */
+GIT_EXTERN(int) git_diff_print_compact(
+ git_diff_list *diff,
+ void *cb_data,
+ git_diff_data_fn print_cb);
+
+/**
+ * Iterate over a diff generating text output like "git diff".
+ *
+ * This is a super easy way to generate a patch from a diff.
+ */
+GIT_EXTERN(int) git_diff_print_patch(
+ git_diff_list *diff,
+ void *cb_data,
+ git_diff_data_fn print_cb);
+
+/**@}*/
+
+
+/*
+ * Misc
+ */
+
+/**
+ * Directly run a text diff on two blobs.
+ *
+ * Compared to a file, a blob lacks some contextual information. As such, the
+ * `git_diff_file` parameters of the callbacks will be filled accordingly to the following:
+ * `mode` will be set to 0, `path` will be set to NULL. When dealing with a NULL blob, `oid`
+ * will be set to 0.
+ *
+ * When at least one of the blobs being dealt with is binary, the `git_diff_delta` binary
+ * attribute will be set to 1 and no call to the hunk_cb nor line_cb will be made.
+ */
+GIT_EXTERN(int) git_diff_blobs(
+ git_blob *old_blob,
+ git_blob *new_blob,
+ git_diff_options *options,
+ void *cb_data,
+ git_diff_file_fn file_cb,
+ git_diff_hunk_fn hunk_cb,
+ git_diff_data_fn line_cb);
+
+GIT_END_DECL
+
+/** @} */
+
+#endif
diff --git a/include/git2/errors.h b/include/git2/errors.h
index 5ac0d5b27..fb6670004 100644
--- a/include/git2/errors.h
+++ b/include/git2/errors.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -17,127 +17,91 @@
*/
GIT_BEGIN_DECL
-typedef enum {
+#ifdef GIT_OLD_ERRORS
+enum {
GIT_SUCCESS = 0,
- GIT_ERROR = -1,
-
- /** Input was not a properly formatted Git object id. */
GIT_ENOTOID = -2,
-
- /** Input does not exist in the scope searched. */
GIT_ENOTFOUND = -3,
-
- /** Not enough space available. */
GIT_ENOMEM = -4,
-
- /** Consult the OS error information. */
GIT_EOSERR = -5,
-
- /** The specified object is of invalid type */
GIT_EOBJTYPE = -6,
-
- /** The specified repository is invalid */
GIT_ENOTAREPO = -7,
-
- /** The object type is invalid or doesn't match */
GIT_EINVALIDTYPE = -8,
-
- /** The object cannot be written because it's missing internal data */
GIT_EMISSINGOBJDATA = -9,
-
- /** The packfile for the ODB is corrupted */
GIT_EPACKCORRUPTED = -10,
-
- /** Failed to acquire or release a file lock */
GIT_EFLOCKFAIL = -11,
-
- /** The Z library failed to inflate/deflate an object's data */
GIT_EZLIB = -12,
-
- /** The queried object is currently busy */
GIT_EBUSY = -13,
-
- /** The index file is not backed up by an existing repository */
GIT_EBAREINDEX = -14,
-
- /** The name of the reference is not valid */
GIT_EINVALIDREFNAME = -15,
-
- /** The specified reference has its data corrupted */
GIT_EREFCORRUPTED = -16,
-
- /** The specified symbolic reference is too deeply nested */
GIT_ETOONESTEDSYMREF = -17,
-
- /** The pack-refs file is either corrupted or its format is not currently supported */
GIT_EPACKEDREFSCORRUPTED = -18,
-
- /** The path is invalid */
GIT_EINVALIDPATH = -19,
-
- /** The revision walker is empty; there are no more commits left to iterate */
GIT_EREVWALKOVER = -20,
-
- /** The state of the reference is not valid */
GIT_EINVALIDREFSTATE = -21,
-
- /** This feature has not been implemented yet */
GIT_ENOTIMPLEMENTED = -22,
-
- /** A reference with this name already exists */
GIT_EEXISTS = -23,
-
- /** The given integer literal is too large to be parsed */
GIT_EOVERFLOW = -24,
-
- /** The given literal is not a valid number */
GIT_ENOTNUM = -25,
-
- /** Streaming error */
GIT_ESTREAM = -26,
-
- /** invalid arguments to function */
GIT_EINVALIDARGS = -27,
-
- /** The specified object has its data corrupted */
GIT_EOBJCORRUPTED = -28,
-
- /** The given short oid is ambiguous */
- GIT_EAMBIGUOUSOIDPREFIX = -29,
-
- /** Skip and passthrough the given ODB backend */
+ GIT_EAMBIGUOUS = -29,
GIT_EPASSTHROUGH = -30,
-
- /** The path pattern and string did not match */
GIT_ENOMATCH = -31,
-
- /** The buffer is too short to satisfy the request */
GIT_ESHORTBUFFER = -32,
+};
+#endif
+
+/** Generic return codes */
+enum {
+ GIT_OK = 0,
+ GIT_ERROR = -1,
+ GIT_ENOTFOUND = -3,
+ GIT_EEXISTS = -4,
+ GIT_EAMBIGUOUS = -5,
+ GIT_EBUFS = -6,
+
+ GIT_PASSTHROUGH = -30,
+ GIT_REVWALKOVER = -31,
+};
+
+typedef struct {
+ char *message;
+ int klass;
} git_error;
-/**
- * Return a detailed error string with the latest error
- * that occurred in the library.
- * @return a string explaining the error
- */
-GIT_EXTERN(const char *) git_lasterror(void);
+typedef enum {
+ GITERR_NOMEMORY,
+ GITERR_OS,
+ GITERR_INVALID,
+ GITERR_REFERENCE,
+ GITERR_ZLIB,
+ GITERR_REPOSITORY,
+ GITERR_CONFIG,
+ GITERR_REGEX,
+ GITERR_ODB,
+ GITERR_INDEX,
+ GITERR_OBJECT,
+ GITERR_NET,
+ GITERR_TAG,
+ GITERR_TREE,
+ GITERR_INDEXER,
+} git_error_t;
/**
- * strerror() for the Git library
- *
- * Get a string description for a given error code.
- * NOTE: This method will be eventually deprecated in favor
- * of the new `git_lasterror`.
+ * Return the last `git_error` object that was generated for the
+ * current thread or NULL if no error has occurred.
*
- * @param num The error code to explain
- * @return a string explaining the error code
+ * @return A git_error object.
*/
-GIT_EXTERN(const char *) git_strerror(int num);
+GIT_EXTERN(const git_error *) giterr_last(void);
/**
- * Clear the latest library error
+ * Clear the last library error that occurred for this thread.
*/
-GIT_EXTERN(void) git_clearerror(void);
+GIT_EXTERN(void) giterr_clear(void);
/** @} */
GIT_END_DECL
diff --git a/include/git2/index.h b/include/git2/index.h
index 5018c896b..6a42c8515 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -106,7 +106,7 @@ typedef struct git_index_entry_unmerged {
*
* @param index the pointer for the new index
* @param index_path the path to the index file in disk
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_open(git_index **index, const char *index_path);
@@ -131,7 +131,7 @@ GIT_EXTERN(void) git_index_free(git_index *index);
* by reading from the hard disk.
*
* @param index an existing index object
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_read(git_index *index);
@@ -140,7 +140,7 @@ GIT_EXTERN(int) git_index_read(git_index *index);
* using an atomic file lock.
*
* @param index an existing index object
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_write(git_index *index);
@@ -176,7 +176,7 @@ GIT_EXTERN(void) git_index_uniq(git_index *index);
* @param index an existing index object
* @param path filename to add
* @param stage stage for the entry
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_add(git_index *index, const char *path, int stage);
@@ -188,7 +188,7 @@ GIT_EXTERN(int) git_index_add(git_index *index, const char *path, int stage);
*
* @param index an existing index object
* @param source_entry new entry object
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_add2(git_index *index, const git_index_entry *source_entry);
@@ -207,7 +207,7 @@ GIT_EXTERN(int) git_index_add2(git_index *index, const git_index_entry *source_e
* @param index an existing index object
* @param path filename to add
* @param stage stage for the entry
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_append(git_index *index, const char *path, int stage);
@@ -224,7 +224,7 @@ GIT_EXTERN(int) git_index_append(git_index *index, const char *path, int stage);
*
* @param index an existing index object
* @param source_entry new entry object
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_append2(git_index *index, const git_index_entry *source_entry);
@@ -233,7 +233,7 @@ GIT_EXTERN(int) git_index_append2(git_index *index, const git_index_entry *sourc
*
* @param index an existing index object
* @param position position of the entry to remove
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_remove(git_index *index, int position);
@@ -312,7 +312,7 @@ GIT_EXTERN(int) git_index_entry_stage(const git_index_entry *entry);
*
* @param index an existing index object
* @param tree tree to read
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_index_read_tree(git_index *index, git_tree *tree);
diff --git a/include/git2/indexer.h b/include/git2/indexer.h
index 1e5eb380c..14bd0e402 100644
--- a/include/git2/indexer.h
+++ b/include/git2/indexer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -23,6 +23,51 @@ typedef struct git_indexer_stats {
typedef struct git_indexer git_indexer;
+typedef struct git_indexer_stream git_indexer_stream;
+
+/**
+ * Create a new streaming indexer instance
+ *
+ * @param out where to store the inexer instance
+ * @param path to the gitdir (metadata directory)
+ */
+GIT_EXTERN(int) git_indexer_stream_new(git_indexer_stream **out, const char *gitdir);
+
+/**
+ * Add data to the indexer
+ *
+ * @param idx the indexer
+ * @param data the data to add
+ * @param size the size of the data
+ * @param stats stat storage
+ */
+GIT_EXTERN(int) git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t size, git_indexer_stats *stats);
+
+/**
+ * Finalize the pack and index
+ *
+ * Resolve any pending deltas and write out the index file
+ *
+ * @param idx the indexer
+ */
+GIT_EXTERN(int) git_indexer_stream_finalize(git_indexer_stream *idx, git_indexer_stats *stats);
+
+/**
+ * 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 finalized.
+ *
+ * @param idx the indexer instance
+ */
+GIT_EXTERN(const git_oid *) git_indexer_stream_hash(git_indexer_stream *idx);
+
+/**
+ * Free the indexer and its resources
+ *
+ * @param idx the indexer to free
+ */
+GIT_EXTERN(void) git_indexer_stream_free(git_indexer_stream *idx);
/**
* Create a new indexer instance
diff --git a/include/git2/merge.h b/include/git2/merge.h
new file mode 100644
index 000000000..5a0b2e7f2
--- /dev/null
+++ b/include/git2/merge.h
@@ -0,0 +1,35 @@
+/*
+ * 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_merge_h__
+#define INCLUDE_git_merge_h__
+
+#include "common.h"
+#include "types.h"
+#include "oid.h"
+
+/**
+ * @file git2/merge.h
+ * @brief Git merge-base routines
+ * @defgroup git_revwalk Git merge-base routines
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Find a merge base between two commits
+ *
+ * @param out the OID of a merge base between 'one' and 'two'
+ * @param repo the repository where the commits exist
+ * @param one one of the commits
+ * @param two the other commit
+ */
+GIT_EXTERN(int) git_merge_base(git_oid *out, git_repository *repo, git_oid *one, git_oid *two);
+
+/** @} */
+GIT_END_DECL
+#endif
diff --git a/include/git2/net.h b/include/git2/net.h
index 08bc81f16..c2301b6f1 100644
--- a/include/git2/net.h
+++ b/include/git2/net.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
diff --git a/include/git2/notes.h b/include/git2/notes.h
new file mode 100644
index 000000000..19073abd1
--- /dev/null
+++ b/include/git2/notes.h
@@ -0,0 +1,139 @@
+/*
+ * 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_note_h__
+#define INCLUDE_git_note_h__
+
+#include "oid.h"
+
+/**
+ * @file git2/notes.h
+ * @brief Git notes management routines
+ * @defgroup git_note Git notes management routines
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+/**
+ * Read the note for an object
+ *
+ * The note must be freed manually by the user.
+ *
+ * @param note the note; NULL in case of error
+ * @param repo the Git repository
+ * @param notes_ref OID reference to use (optional); defaults to "refs/notes/commits"
+ * @param oid OID of the object
+ *
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_note_read(git_note **note, git_repository *repo,
+ const char *notes_ref, const git_oid *oid);
+
+/**
+ * Get the note message
+ *
+ * @param note
+ * @return the note message
+ */
+GIT_EXTERN(const char *) git_note_message(git_note *note);
+
+
+/**
+ * Get the note object OID
+ *
+ * @param note
+ * @return the note object OID
+ */
+GIT_EXTERN(const git_oid *) git_note_oid(git_note *note);
+
+
+/**
+ * Add a note for an object
+ *
+ * @param oid pointer to store the OID (optional); NULL in case of error
+ * @param repo the Git repository
+ * @param author signature of the notes commit author
+ * @param committer signature of the notes commit committer
+ * @param notes_ref OID reference to update (optional); defaults to "refs/notes/commits"
+ * @param oid The OID of the object
+ * @param oid The note to add for object oid
+ *
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_note_create(git_oid *out, git_repository *repo,
+ git_signature *author, git_signature *committer,
+ const char *notes_ref, const git_oid *oid,
+ const char *note);
+
+
+/**
+ * Remove the note for an object
+ *
+ * @param repo the Git repository
+ * @param notes_ref OID reference to use (optional); defaults to "refs/notes/commits"
+ * @param author signature of the notes commit author
+ * @param committer signature of the notes commit committer
+ * @param oid the oid which note's to be removed
+ *
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_note_remove(git_repository *repo, const char *notes_ref,
+ git_signature *author, git_signature *committer,
+ const git_oid *oid);
+
+/**
+ * Free a git_note object
+ *
+ * @param note git_note object
+ */
+GIT_EXTERN(void) git_note_free(git_note *note);
+
+/**
+ * Get the default notes reference for a repository
+ *
+ * @param out Pointer to the default notes reference
+ * @param repo The Git repository
+ *
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_note_default_ref(const char **out, git_repository *repo);
+
+/**
+ * Basic components of a note
+ *
+ * - Oid of the blob containing the message
+ * - Oid of the git object being annotated
+ */
+typedef struct {
+ git_oid blob_oid;
+ git_oid annotated_object_oid;
+} git_note_data;
+
+/**
+ * Loop over all the notes within a specified namespace
+ * and issue a callback for each one.
+ *
+ * @param repo Repository where to find the notes.
+ *
+ * @param notes_ref OID reference to read from (optional); defaults to "refs/notes/commits".
+ *
+ * @param note_cb Callback to invoke per found annotation.
+ *
+ * @param payload Extra parameter to callback function.
+ *
+ * @return 0 or an error code.
+ */
+GIT_EXTERN(int) git_note_foreach(
+ git_repository *repo,
+ const char *notes_ref,
+ int (*note_cb)(git_note_data *note_data, void *payload),
+ void *payload
+);
+
+/** @} */
+GIT_END_DECL
+#endif
diff --git a/include/git2/object.h b/include/git2/object.h
index 86a0a585d..9e988b7b6 100644
--- a/include/git2/object.h
+++ b/include/git2/object.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -69,7 +69,7 @@ GIT_EXTERN(int) git_object_lookup(
* @param id a short identifier for the object
* @param len the length of the short identifier
* @param type the type of the object
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_object_lookup_prefix(
git_object **object_out,
diff --git a/include/git2/odb.h b/include/git2/odb.h
index b144eca7d..1df193389 100644
--- a/include/git2/odb.h
+++ b/include/git2/odb.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -29,7 +29,7 @@ GIT_BEGIN_DECL
*
* @param out location to store the database pointer, if opened.
* Set to NULL if the open failed.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_odb_new(git_odb **out);
@@ -47,7 +47,7 @@ GIT_EXTERN(int) git_odb_new(git_odb **out);
* @param out location to store the database pointer, if opened.
* Set to NULL if the open failed.
* @param objects_dir path of the backends' "objects" directory.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_odb_open(git_odb **out, const char *objects_dir);
@@ -108,7 +108,7 @@ GIT_EXTERN(void) git_odb_free(git_odb *db);
* @param db database to search for the object in.
* @param id identity of the object to read.
* @return
- * - GIT_SUCCESS if the object was read;
+ * - 0 if the object was read;
* - GIT_ENOTFOUND if the object is not in the database.
*/
GIT_EXTERN(int) git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id);
@@ -135,7 +135,7 @@ GIT_EXTERN(int) git_odb_read(git_odb_object **out, git_odb *db, const git_oid *i
* @param db database to search for the object in.
* @param short_id a prefix of the id of the object to read.
* @param len the length of the prefix
- * @return GIT_SUCCESS if the object was read;
+ * @return 0 if the object was read;
* GIT_ENOTFOUND if the object is not in the database.
* GIT_EAMBIGUOUS if the prefix is ambiguous (several objects match the prefix)
*/
@@ -156,7 +156,7 @@ GIT_EXTERN(int) git_odb_read_prefix(git_odb_object **out, git_odb *db, const git
* @param db database to search for the object in.
* @param id identity of the object to read.
* @return
- * - GIT_SUCCESS if the object was read;
+ * - 0 if the object was read;
* - GIT_ENOTFOUND if the object is not in the database.
*/
GIT_EXTERN(int) git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id);
@@ -188,7 +188,7 @@ GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id);
* @param data buffer with the data to storr
* @param len size of the buffer
* @param type type of the data to store
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_odb_write(git_oid *oid, git_odb *odb, const void *data, size_t len, git_otype type);
@@ -257,7 +257,7 @@ GIT_EXTERN(int) git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const
* @param data data to hash
* @param len size of the data
* @param type of the data to hash
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_odb_hash(git_oid *id, const void *data, size_t len, git_otype type);
@@ -270,7 +270,7 @@ GIT_EXTERN(int) git_odb_hash(git_oid *id, const void *data, size_t len, git_otyp
* @param out oid structure the result is written into.
* @param path file to read and determine object id for
* @param type the type of the object that will be hashed
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_odb_hashfile(git_oid *out, const char *path, git_otype type);
diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h
index eb8830fb3..f4620f5f4 100644
--- a/include/git2/odb_backend.h
+++ b/include/git2/odb_backend.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -74,6 +74,13 @@ struct git_odb_backend {
void (* free)(struct git_odb_backend *);
};
+/** Streaming mode */
+enum {
+ GIT_STREAM_RDONLY = (1 << 1),
+ GIT_STREAM_WRONLY = (1 << 2),
+ GIT_STREAM_RW = (GIT_STREAM_RDONLY | GIT_STREAM_WRONLY),
+};
+
/** A stream to read/write from a backend */
struct git_odb_stream {
struct git_odb_backend *backend;
@@ -85,13 +92,6 @@ struct git_odb_stream {
void (*free)(struct git_odb_stream *stream);
};
-/** Streaming mode */
-typedef enum {
- GIT_STREAM_RDONLY = (1 << 1),
- GIT_STREAM_WRONLY = (1 << 2),
- GIT_STREAM_RW = (GIT_STREAM_RDONLY | GIT_STREAM_WRONLY),
-} git_odb_streammode;
-
GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir);
GIT_EXTERN(int) git_odb_backend_loose(git_odb_backend **backend_out, const char *objects_dir, int compression_level, int do_fsync);
diff --git a/include/git2/oid.h b/include/git2/oid.h
index 9cebda931..c06458d24 100644
--- a/include/git2/oid.h
+++ b/include/git2/oid.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -43,7 +43,7 @@ struct _git_oid {
* @param str input hex string; must be pointing at the start of
* the hex sequence and have at least the number of bytes
* needed for an oid encoded in hex (40 bytes).
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str);
@@ -56,7 +56,7 @@ GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str);
* @param out oid structure the result is written into.
* @param str input hex string of at least size `length`
* @param length length of the input string
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_oid_fromstrn(git_oid *out, const char *str, size_t length);
@@ -119,7 +119,7 @@ GIT_EXTERN(char *) git_oid_allocfmt(const git_oid *oid);
* @return the out buffer pointer, assuming no input parameter
* errors, otherwise a pointer to an empty string.
*/
-GIT_EXTERN(char *) git_oid_to_string(char *out, size_t n, const git_oid *oid);
+GIT_EXTERN(char *) git_oid_tostr(char *out, size_t n, const git_oid *oid);
/**
* Copy an oid from one structure to another.
@@ -155,11 +155,16 @@ GIT_EXTERN(int) git_oid_ncmp(const git_oid *a, const git_oid *b, unsigned int le
* @param a oid structure.
* @param str input hex string of an object id.
* @return GIT_ENOTOID if str is not a valid hex string,
- * GIT_SUCCESS in case of a match, GIT_ERROR otherwise.
+ * 0 in case of a match, GIT_ERROR otherwise.
*/
GIT_EXTERN(int) git_oid_streq(const git_oid *a, const char *str);
/**
+ * Check is an oid is all zeros.
+ */
+GIT_EXTERN(int) git_oid_iszero(const git_oid *a);
+
+/**
* OID Shortener object
*/
typedef struct git_oid_shorten git_oid_shorten;
@@ -178,7 +183,7 @@ typedef struct git_oid_shorten git_oid_shorten;
* be unique.
* @return a `git_oid_shorten` instance, NULL if OOM
*/
-git_oid_shorten *git_oid_shorten_new(size_t min_length);
+GIT_EXTERN(git_oid_shorten *) git_oid_shorten_new(size_t min_length);
/**
* Add a new OID to set of shortened OIDs and calculate
@@ -204,14 +209,14 @@ git_oid_shorten *git_oid_shorten_new(size_t min_length);
* added so far to the set; or an error code (<0) if an
* error occurs.
*/
-int git_oid_shorten_add(git_oid_shorten *os, const char *text_oid);
+GIT_EXTERN(int) git_oid_shorten_add(git_oid_shorten *os, const char *text_oid);
/**
* Free an OID shortener instance
*
* @param os a `git_oid_shorten` instance
*/
-void git_oid_shorten_free(git_oid_shorten *os);
+GIT_EXTERN(void) git_oid_shorten_free(git_oid_shorten *os);
/** @} */
GIT_END_DECL
diff --git a/include/git2/reflog.h b/include/git2/reflog.h
index f1d08795e..f490e29de 100644
--- a/include/git2/reflog.h
+++ b/include/git2/reflog.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -28,7 +28,7 @@ GIT_BEGIN_DECL
*
* @param reflog pointer to reflog
* @param ref reference to read the reflog for
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reflog_read(git_reflog **reflog, git_reference *ref);
@@ -46,7 +46,7 @@ GIT_EXTERN(int) git_reflog_read(git_reflog **reflog, git_reference *ref);
* @param oid_old the OID the reference was pointing to
* @param committer the signature of the committer
* @param msg the reflog message
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reflog_write(git_reference *ref, const git_oid *oid_old, const git_signature *committer, const char *msg);
@@ -55,7 +55,7 @@ GIT_EXTERN(int) git_reflog_write(git_reference *ref, const git_oid *oid_old, con
*
* @param ref the reference
* @param new_name the new name of the reference
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reflog_rename(git_reference *ref, const char *new_name);
@@ -63,7 +63,7 @@ GIT_EXTERN(int) git_reflog_rename(git_reference *ref, const char *new_name);
* Delete the reflog for the given reference
*
* @param ref the reference
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reflog_delete(git_reference *ref);
diff --git a/include/git2/refs.h b/include/git2/refs.h
index 32671aa66..882e32769 100644
--- a/include/git2/refs.h
+++ b/include/git2/refs.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -28,11 +28,22 @@ GIT_BEGIN_DECL
* @param reference_out pointer to the looked-up reference
* @param repo the repository to look up the reference
* @param name the long name for the reference (e.g. HEAD, ref/heads/master, refs/tags/v0.1.0, ...)
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_lookup(git_reference **reference_out, git_repository *repo, const char *name);
/**
+ * Lookup a reference by name and resolve immediately to OID.
+ *
+ * @param oid Pointer to oid to be filled in
+ * @param repo The repository in which to look up the reference
+ * @param name The long name for the reference
+ * @return 0 on success, -1 if name could not be resolved
+ */
+GIT_EXTERN(int) git_reference_name_to_oid(
+ git_oid *out, git_repository *repo, const char *name);
+
+/**
* Create a new symbolic reference.
*
* The reference will be created in the repository and written
@@ -48,7 +59,7 @@ GIT_EXTERN(int) git_reference_lookup(git_reference **reference_out, git_reposito
* @param name The name of the reference
* @param target The target of the reference
* @param force Overwrite existing references
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_create_symbolic(git_reference **ref_out, git_repository *repo, const char *name, const char *target, int force);
@@ -68,7 +79,7 @@ GIT_EXTERN(int) git_reference_create_symbolic(git_reference **ref_out, git_repos
* @param name The name of the reference
* @param id The object id pointed to by the reference.
* @param force Overwrite existing references
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_create_oid(git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id, int force);
@@ -100,7 +111,7 @@ GIT_EXTERN(const char *) git_reference_target(git_reference *ref);
* @param ref The reference
* @return the type
*/
-GIT_EXTERN(git_rtype) git_reference_type(git_reference *ref);
+GIT_EXTERN(git_ref_t) git_reference_type(git_reference *ref);
/**
* Get the full name of a reference
@@ -126,7 +137,7 @@ GIT_EXTERN(const char *) git_reference_name(git_reference *ref);
*
* @param resolved_ref Pointer to the peeled reference
* @param ref The reference
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_resolve(git_reference **resolved_ref, git_reference *ref);
@@ -149,7 +160,7 @@ GIT_EXTERN(git_repository *) git_reference_owner(git_reference *ref);
*
* @param ref The reference
* @param target The new target for the reference
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_set_target(git_reference *ref, const char *target);
@@ -164,7 +175,7 @@ GIT_EXTERN(int) git_reference_set_target(git_reference *ref, const char *target)
*
* @param ref The reference
* @param id The new target OID for the reference
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_set_oid(git_reference *ref, const git_oid *id);
@@ -191,7 +202,7 @@ GIT_EXTERN(int) git_reference_set_oid(git_reference *ref, const git_oid *id);
* @param ref The reference to rename
* @param new_name The new name for the reference
* @param force Overwrite an existing reference
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*
*/
GIT_EXTERN(int) git_reference_rename(git_reference *ref, const char *new_name, int force);
@@ -205,7 +216,7 @@ GIT_EXTERN(int) git_reference_rename(git_reference *ref, const char *new_name, i
* memory. The given reference pointer will no longer be valid.
*
* @param ref The reference to remove
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_delete(git_reference *ref);
@@ -220,7 +231,7 @@ GIT_EXTERN(int) git_reference_delete(git_reference *ref);
* the loose references will be removed from disk.
*
* @param repo Repository where the loose refs will be packed
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_packall(git_repository *repo);
@@ -243,9 +254,9 @@ GIT_EXTERN(int) git_reference_packall(git_repository *repo);
* @param repo Repository where to find the refs
* @param list_flags Filtering flags for the reference
* listing.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
-GIT_EXTERN(int) git_reference_listall(git_strarray *array, git_repository *repo, unsigned int list_flags);
+GIT_EXTERN(int) git_reference_list(git_strarray *array, git_repository *repo, unsigned int list_flags);
/**
@@ -265,7 +276,7 @@ GIT_EXTERN(int) git_reference_listall(git_strarray *array, git_repository *repo,
* listing.
* @param callback Function which will be called for every listed ref
* @param payload Additional data to pass to the callback
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_reference_foreach(git_repository *repo, unsigned int list_flags, int (*callback)(const char *, void *), void *payload);
@@ -293,7 +304,7 @@ GIT_EXTERN(int) git_reference_is_packed(git_reference *ref);
* returned and the reference pointer will be invalidated.
*
* @param ref The reference to reload
- * @return GIT_SUCCESS on success, or an error code
+ * @return 0 on success, or an error code
*/
GIT_EXTERN(int) git_reference_reload(git_reference *ref);
@@ -304,6 +315,15 @@ GIT_EXTERN(int) git_reference_reload(git_reference *ref);
*/
GIT_EXTERN(void) git_reference_free(git_reference *ref);
+/**
+ * Compare two references.
+ *
+ * @param ref1 The first git_reference
+ * @param ref2 The second git_reference
+ * @return 0 if the same, else a stable but meaningless ordering.
+ */
+GIT_EXTERN(int) git_reference_cmp(git_reference *ref1, git_reference *ref2);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/refspec.h b/include/git2/refspec.h
index 0f8b13cec..c0a8eabfe 100644
--- a/include/git2/refspec.h
+++ b/include/git2/refspec.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -7,6 +7,7 @@
#ifndef INCLUDE_git_refspec_h__
#define INCLUDE_git_refspec_h__
+#include "common.h"
#include "types.h"
/**
@@ -24,7 +25,7 @@ GIT_BEGIN_DECL
* @param refspec the refspec
* @return the refspec's source specifier
*/
-const char *git_refspec_src(const git_refspec *refspec);
+GIT_EXTERN(const char *) git_refspec_src(const git_refspec *refspec);
/**
* Get the destination specifier
@@ -32,17 +33,16 @@ const char *git_refspec_src(const git_refspec *refspec);
* @param refspec the refspec
* @return the refspec's destination specifier
*/
-const char *git_refspec_dst(const git_refspec *refspec);
+GIT_EXTERN(const char *) git_refspec_dst(const git_refspec *refspec);
/**
- * Match a refspec's source descriptor with a reference name
+ * Check if a refspec's source descriptor matches a reference
*
* @param refspec the refspec
* @param refname the name of the reference to check
- * @return GIT_SUCCESS on successful match; GIT_ENOMACH on match
- * failure or an error code on other failure
+ * @return 1 if the refspec matches, 0 otherwise
*/
-int git_refspec_src_match(const git_refspec *refspec, const char *refname);
+GIT_EXTERN(int) git_refspec_src_matches(const git_refspec *refspec, const char *refname);
/**
* Transform a reference to its target following the refspec's rules
@@ -51,9 +51,9 @@ int git_refspec_src_match(const git_refspec *refspec, const char *refname);
* @param outlen the size ouf the `out` buffer
* @param spec the refspec
* @param name the name of the reference to transform
- * @return GIT_SUCCESS, GIT_ESHORTBUFFER or another error
+ * @return 0, GIT_EBUFS or another error
*/
-int git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, const char *name);
+GIT_EXTERN(int) git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, const char *name);
GIT_END_DECL
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 0ae38165c..865dfef04 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -11,6 +11,7 @@
#include "repository.h"
#include "refspec.h"
#include "net.h"
+#include "indexer.h"
/**
* @file git2/remote.h
@@ -37,11 +38,12 @@ GIT_BEGIN_DECL
*
* @param out pointer to the new remote object
* @param repo the associtated repository
- * @param url the remote repository's URL
* @param name the remote's name
- * @return GIT_SUCCESS or an error code
+ * @param url the remote repository's URL
+ * @param fetch the fetch refspec to use for this remote
+ * @return 0 or an error code
*/
-GIT_EXTERN(int) git_remote_new(git_remote **out, git_repository *repo, const char *url, const char *name);
+GIT_EXTERN(int) git_remote_new(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch);
/**
* Get the information for a particular remote
@@ -49,11 +51,19 @@ GIT_EXTERN(int) git_remote_new(git_remote **out, git_repository *repo, const cha
* @param out pointer to the new remote object
* @param cfg the repository's configuration
* @param name the remote's name
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_remote_load(git_remote **out, git_repository *repo, const char *name);
/**
+ * Save a remote to its repository's configuration
+ *
+ * @param remote the remote to save to config
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_remote_save(const git_remote *remote);
+
+/**
* Get the remote's name
*
* @param remote the remote
@@ -70,6 +80,15 @@ GIT_EXTERN(const char *) git_remote_name(git_remote *remote);
GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
/**
+ * Set the remote's fetch refspec
+ *
+ * @param remote the remote
+ * @apram spec the new fetch refspec
+ * @return 0 or an error value
+ */
+GIT_EXTERN(int) git_remote_set_fetchspec(git_remote *remote, const char *spec);
+
+/**
* Get the fetch refspec
*
* @param remote the remote
@@ -78,6 +97,15 @@ GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
GIT_EXTERN(const git_refspec *) git_remote_fetchspec(git_remote *remote);
/**
+ * Set the remote's push refspec
+ *
+ * @param remote the remote
+ * @apram spec the new push refspec
+ * @return 0 or an error value
+ */
+GIT_EXTERN(int) git_remote_set_pushspec(git_remote *remote, const char *spec);
+
+/**
* Get the push refspec
*
* @param remote the remote
@@ -95,7 +123,7 @@ GIT_EXTERN(const git_refspec *) git_remote_pushspec(git_remote *remote);
*
* @param remote the remote to connect to
* @param direction whether you want to receive or send data
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_remote_connect(git_remote *remote, int direction);
@@ -107,7 +135,7 @@ GIT_EXTERN(int) git_remote_connect(git_remote *remote, int direction);
*
* @param refs where to store the refs
* @param remote the remote
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void *payload);
@@ -122,9 +150,9 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void
*
* @param remote the remote to download from
* @param filename where to store the temproray filename
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
-GIT_EXTERN(int) git_remote_download(char **filename, git_remote *remote);
+GIT_EXTERN(int) git_remote_download(git_remote *remote, git_off_t *bytes, git_indexer_stats *stats);
/**
* Check whether the remote is connected
@@ -149,6 +177,9 @@ GIT_EXTERN(void) git_remote_disconnect(git_remote *remote);
/**
* Free the memory associated with a remote
*
+ * This also disconnects from the remote, if the connection
+ * has not been closed yet (using git_remote_disconnect).
+ *
* @param remote the remote to free
*/
GIT_EXTERN(void) git_remote_free(git_remote *remote);
@@ -156,12 +187,10 @@ GIT_EXTERN(void) git_remote_free(git_remote *remote);
/**
* 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
+ * @param cb callback to run on each ref update. 'a' is the old value, 'b' is then new value
*/
-GIT_EXTERN(int) git_remote_update_tips(git_remote *remote);
+GIT_EXTERN(int) git_remote_update_tips(git_remote *remote, int (*cb)(const char *refname, const git_oid *a, const git_oid *b));
/**
* Return whether a string is a valid remote URL
@@ -171,6 +200,35 @@ GIT_EXTERN(int) git_remote_update_tips(git_remote *remote);
*/
GIT_EXTERN(int) git_remote_valid_url(const char *url);
+/**
+ * Return whether the passed URL is supported by this version of the library.
+ *
+ * @param url the url to check
+ * @return 1 if the url is supported, 0 otherwise
+*/
+GIT_EXTERN(int) git_remote_supported_url(const char* url);
+
+/**
+ * Get a list of the configured remotes for a repo
+ *
+ * The string array must be freed by the user.
+ *
+ * @param remotes_list a string array with the names of the remotes
+ * @param repo the repository to query
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_remote_list(git_strarray *remotes_list, git_repository *repo);
+
+/**
+ * Add a remote with the default fetch refspec to the repository's configuration
+ *
+ * @param out the resulting remote
+ * @param repo the repository in which to create the remote
+ * @param name the remote's name
+ * @param url the remote's url
+ */
+GIT_EXTERN(int) git_remote_add(git_remote **out, git_repository *repo, const char *name, const char *url);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/repository.h b/include/git2/repository.h
index 4250ae161..3949438cf 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -31,7 +31,7 @@ GIT_BEGIN_DECL
*
* @param repository pointer to the repo which will be opened
* @param path the path to the repository
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_repository_open(git_repository **repository, const char *path);
@@ -61,7 +61,7 @@ GIT_EXTERN(int) git_repository_open(git_repository **repository, const char *pat
* start_path no matter start_path appears in ceiling_dirs ceiling_dirs
* might be NULL (which is equivalent to an empty string)
*
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_repository_discover(
char *repository_path,
@@ -70,6 +70,20 @@ GIT_EXTERN(int) git_repository_discover(
int across_fs,
const char *ceiling_dirs);
+enum {
+ GIT_REPOSITORY_OPEN_NO_SEARCH = (1 << 0),
+ GIT_REPOSITORY_OPEN_CROSS_FS = (1 << 1),
+};
+
+/**
+ * Find and open a repository with extended controls.
+ */
+GIT_EXTERN(int) git_repository_open_ext(
+ git_repository **repo,
+ const char *start_path,
+ uint32_t flags,
+ const char *ceiling_dirs);
+
/**
* Free a previously allocated repository
*
@@ -95,7 +109,7 @@ GIT_EXTERN(void) git_repository_free(git_repository *repo);
* at the pointed path. If false, provided path will be considered as the working
* directory into which the .git directory will be created.
*
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_repository_init(git_repository **repo_out, const char *path, unsigned is_bare);
@@ -180,7 +194,7 @@ GIT_EXTERN(const char *) git_repository_workdir(git_repository *repo);
*
* @param repo A repository object
* @param workdir The path to a working directory
- * @return GIT_SUCCESS, or an error code
+ * @return 0, or an error code
*/
GIT_EXTERN(int) git_repository_set_workdir(git_repository *repo, const char *workdir);
@@ -204,7 +218,7 @@ GIT_EXTERN(int) git_repository_is_bare(git_repository *repo);
*
* @param out Pointer to store the loaded config file
* @param repo A repository object
- * @return GIT_SUCCESS, or an error code
+ * @return 0, or an error code
*/
GIT_EXTERN(int) git_repository_config(git_config **out, git_repository *repo);
@@ -235,7 +249,7 @@ GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *con
*
* @param out Pointer to store the loaded ODB
* @param repo A repository object
- * @return GIT_SUCCESS, or an error code
+ * @return 0, or an error code
*/
GIT_EXTERN(int) git_repository_odb(git_odb **out, git_repository *repo);
@@ -266,7 +280,7 @@ GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb);
*
* @param out Pointer to store the loaded index
* @param repo A repository object
- * @return GIT_SUCCESS, or an error code
+ * @return 0, or an error code
*/
GIT_EXTERN(int) git_repository_index(git_index **out, git_repository *repo);
diff --git a/include/git2/revwalk.h b/include/git2/revwalk.h
index c84c5d301..aac6fb7c2 100644
--- a/include/git2/revwalk.h
+++ b/include/git2/revwalk.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -65,7 +65,7 @@ GIT_BEGIN_DECL
*
* @param walker pointer to the new revision walker
* @param repo the repo to walk through
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_revwalk_new(git_revwalk **walker, git_repository *repo);
@@ -97,10 +97,32 @@ GIT_EXTERN(void) git_revwalk_reset(git_revwalk *walker);
*
* @param walk the walker being used for the traversal.
* @param oid the oid of the commit to start from.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_revwalk_push(git_revwalk *walk, const git_oid *oid);
+/**
+ * Push matching references
+ *
+ * The OIDs pinted 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
+ * '/ *' if the glob lacks '?', '*' or '['.
+ *
+ * @param walk the walker being used for the traversal
+ * @param glob the glob pattern references should match
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_revwalk_push_glob(git_revwalk *walk, const char *glob);
+
+/**
+ * Push the repository's HEAD
+ *
+ * @param walk the walker being used for the traversal
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_revwalk_push_head(git_revwalk *walk);
/**
* Mark a commit (and its ancestors) uninteresting for the output.
@@ -113,11 +135,57 @@ GIT_EXTERN(int) git_revwalk_push(git_revwalk *walk, const git_oid *oid);
*
* @param walk the walker being used for the traversal.
* @param oid the oid of commit that will be ignored during the traversal
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_revwalk_hide(git_revwalk *walk, const git_oid *oid);
/**
+ * Hide matching references.
+ *
+ * The OIDs pinted to by the references that match the given glob
+ * 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
+ * '/ *' if the glob lacks '?', '*' or '['.
+ *
+ * @param walk the walker being used for the traversal
+ * @param glob the glob pattern references should match
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_revwalk_hide_glob(git_revwalk *walk, const char *glob);
+
+/**
+ * Hide the repository's HEAD
+ *
+ * @param walk the walker being used for the traversal
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_revwalk_hide_head(git_revwalk *walk);
+
+/**
+ * Push the OID pointed to by a reference
+ *
+ * The reference must point to a commit.
+ *
+ * @param walk the walker being used for the traversal
+ * @param refname the referece to push
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_revwalk_push_ref(git_revwalk *walk, const char *refname);
+
+/**
+ * Hide the OID pointed to by a reference
+ *
+ * The reference must point to a commit.
+ *
+ * @param walk the walker being used for the traversal
+ * @param refname the referece to hide
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_revwalk_hide_ref(git_revwalk *walk, const char *refname);
+
+/**
* Get the next commit from the revision walk.
*
* The initial call to this method is *not* blocking when
@@ -132,8 +200,8 @@ GIT_EXTERN(int) git_revwalk_hide(git_revwalk *walk, const git_oid *oid);
*
* @param oid Pointer where to store the oid of the next commit
* @param walk the walker to pop the commit from.
- * @return GIT_SUCCESS if the next commit was found;
- * GIT_EREVWALKOVER if there are no commits left to iterate
+ * @return 0 if the next commit was found;
+ * GIT_REVWALKOVER if there are no commits left to iterate
*/
GIT_EXTERN(int) git_revwalk_next(git_oid *oid, git_revwalk *walk);
diff --git a/include/git2/signature.h b/include/git2/signature.h
index 228929943..cbf94269f 100644
--- a/include/git2/signature.h
+++ b/include/git2/signature.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -28,7 +28,7 @@ GIT_BEGIN_DECL
* @param email email of the person
* @param time time when the action happened
* @param offset timezone offset in minutes for the time
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_signature_new(git_signature **sig_out, const char *name, const char *email, git_time_t time, int offset);
@@ -39,7 +39,7 @@ GIT_EXTERN(int) git_signature_new(git_signature **sig_out, const char *name, con
* @param sig_out new signature, in case of error NULL
* @param name name of the person
* @param email email of the person
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_signature_now(git_signature **sig_out, const char *name, const char *email);
diff --git a/include/git2/status.h b/include/git2/status.h
index c0f38c508..6a424dfd6 100644
--- a/include/git2/status.h
+++ b/include/git2/status.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -19,32 +19,111 @@
*/
GIT_BEGIN_DECL
-#define GIT_STATUS_CURRENT 0
+enum {
+ GIT_STATUS_CURRENT = 0,
-/** Flags for index status */
-#define GIT_STATUS_INDEX_NEW (1 << 0)
-#define GIT_STATUS_INDEX_MODIFIED (1 << 1)
-#define GIT_STATUS_INDEX_DELETED (1 << 2)
+ GIT_STATUS_INDEX_NEW = (1 << 0),
+ GIT_STATUS_INDEX_MODIFIED = (1 << 1),
+ GIT_STATUS_INDEX_DELETED = (1 << 2),
-/** Flags for worktree status */
-#define GIT_STATUS_WT_NEW (1 << 3)
-#define GIT_STATUS_WT_MODIFIED (1 << 4)
-#define GIT_STATUS_WT_DELETED (1 << 5)
+ GIT_STATUS_WT_NEW = (1 << 3),
+ GIT_STATUS_WT_MODIFIED = (1 << 4),
+ GIT_STATUS_WT_DELETED = (1 << 5),
-#define GIT_STATUS_IGNORED (1 << 6)
+ GIT_STATUS_IGNORED = (1 << 6),
+};
/**
* Gather file statuses and run a callback for each one.
*
- * The callback is passed the path of the file, the status and the data pointer
- * passed to this function. If the callback returns something other than
- * GIT_SUCCESS, this function will return that value.
+ * The callback is passed the path of the file, the status and the data
+ * pointer passed to this function. If the callback returns something other
+ * than 0, this function will return that value.
*
* @param repo a repository object
* @param callback the function to call on each file
- * @return GIT_SUCCESS or the return value of the callback which did not return GIT_SUCCESS
+ * @return 0 on success or the return value of the callback that was non-zero
*/
-GIT_EXTERN(int) git_status_foreach(git_repository *repo, int (*callback)(const char *, unsigned int, void *), void *payload);
+GIT_EXTERN(int) git_status_foreach(
+ git_repository *repo,
+ int (*callback)(const char *, unsigned int, void *),
+ void *payload);
+
+/**
+ * Select the files on which to report status.
+ *
+ * - GIT_STATUS_SHOW_INDEX_AND_WORKDIR is the default. This is the
+ * rough equivalent of `git status --porcelain` where each file
+ * will receive a callback indicating its status in the index and
+ * in the workdir.
+ * - GIT_STATUS_SHOW_INDEX_ONLY will only make callbacks for index
+ * side of status. The status of the index contents relative to
+ * the HEAD will be given.
+ * - GIT_STATUS_SHOW_WORKDIR_ONLY will only make callbacks for the
+ * workdir side of status, reporting the status of workdir content
+ * relative to the index.
+ * - GIT_STATUS_SHOW_INDEX_THEN_WORKDIR behaves like index-only
+ * followed by workdir-only, causing two callbacks to be issued
+ * per file (first index then workdir). This is slightly more
+ * efficient than making separate calls. This makes it easier to
+ * emulate the output of a plain `git status`.
+ */
+typedef enum {
+ GIT_STATUS_SHOW_INDEX_AND_WORKDIR = 0,
+ GIT_STATUS_SHOW_INDEX_ONLY = 1,
+ GIT_STATUS_SHOW_WORKDIR_ONLY = 2,
+ GIT_STATUS_SHOW_INDEX_THEN_WORKDIR = 3,
+} git_status_show_t;
+
+/**
+ * Flags to control status callbacks
+ *
+ * - GIT_STATUS_OPT_INCLUDE_UNTRACKED says that callbacks should
+ * be made on untracked files. These will only be made if the
+ * workdir files are included in the status "show" option.
+ * - GIT_STATUS_OPT_INCLUDE_IGNORED says that ignored files should
+ * get callbacks. Again, these callbacks will only be made if
+ * the workdir files are included in the status "show" option.
+ * Right now, there is no option to include all files in
+ * directories that are ignored completely.
+ * - GIT_STATUS_OPT_INCLUDE_UNMODIFIED indicates that callback
+ * should be made even on unmodified files.
+ * - GIT_STATUS_OPT_EXCLUDE_SUBMODULES indicates that directories
+ * which appear to be submodules should just be skipped over.
+ * - GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS indicates that the
+ * contents of untracked directories should be included in the
+ * status. Normally if an entire directory is new, then just
+ * the top-level directory will be included (with a trailing
+ * slash on the entry name). Given this flag, the directory
+ * itself will not be included, but all the files in it will.
+ */
+
+enum {
+ GIT_STATUS_OPT_INCLUDE_UNTRACKED = (1 << 0),
+ GIT_STATUS_OPT_INCLUDE_IGNORED = (1 << 1),
+ GIT_STATUS_OPT_INCLUDE_UNMODIFIED = (1 << 2),
+ GIT_STATUS_OPT_EXCLUDE_SUBMODULED = (1 << 3),
+ GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS = (1 << 4),
+};
+
+/**
+ * Options to control how callbacks will be made by
+ * `git_status_foreach_ext()`.
+ */
+typedef struct {
+ git_status_show_t show;
+ unsigned int flags;
+ git_strarray pathspec;
+} git_status_options;
+
+/**
+ * Gather file status information and run callbacks as requested.
+ */
+GIT_EXTERN(int) git_status_foreach_ext(
+ git_repository *repo,
+ const git_status_options *opts,
+ int (*callback)(const char *, unsigned int, void *),
+ void *payload);
/**
* Get file status for a single file
@@ -54,9 +133,12 @@ GIT_EXTERN(int) git_status_foreach(git_repository *repo, int (*callback)(const c
* @param path the file to retrieve status for, rooted at the repo's workdir
* @return GIT_EINVALIDPATH when `path` points at a folder, GIT_ENOTFOUND when
* the file doesn't exist in any of HEAD, the index or the worktree,
- * GIT_SUCCESS otherwise
+ * 0 otherwise
*/
-GIT_EXTERN(int) git_status_file(unsigned int *status_flags, git_repository *repo, const char *path);
+GIT_EXTERN(int) git_status_file(
+ unsigned int *status_flags,
+ git_repository *repo,
+ const char *path);
/**
* Test if the ignore rules apply to a given file.
@@ -66,13 +148,16 @@ GIT_EXTERN(int) git_status_file(unsigned int *status_flags, git_repository *repo
* would be ignored regardless of whether the file is already in the index
* or in the repository.
*
- * @param repo a repository object
- * @param path the file to check ignores for, rooted at the repo's workdir
* @param ignored boolean returning 0 if the file is not ignored, 1 if it is
- * @return GIT_SUCCESS if the ignore rules could be processed for the file
- * (regardless of whether it exists or not), or an error < 0 if they could not.
+ * @param repo a repository object
+ * @param path the file to check ignores for, rooted at the repo's workdir.
+ * @return 0 if ignore rules could be processed for the file (regardless
+ * of whether it exists or not), or an error < 0 if they could not.
*/
-GIT_EXTERN(int) git_status_should_ignore(git_repository *repo, const char *path, int *ignored);
+GIT_EXTERN(int) git_status_should_ignore(
+ int *ignored,
+ git_repository *repo,
+ const char *path);
/** @} */
GIT_END_DECL
diff --git a/include/git2/submodule.h b/include/git2/submodule.h
new file mode 100644
index 000000000..930168275
--- /dev/null
+++ b/include/git2/submodule.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 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_submodule_h__
+#define INCLUDE_git_submodule_h__
+
+#include "common.h"
+#include "types.h"
+#include "oid.h"
+
+/**
+ * @file git2/submodule.h
+ * @brief Git submodule management utilities
+ * @defgroup git_submodule Git submodule management routines
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+typedef enum {
+ GIT_SUBMODULE_UPDATE_CHECKOUT = 0,
+ GIT_SUBMODULE_UPDATE_REBASE = 1,
+ GIT_SUBMODULE_UPDATE_MERGE = 2
+} git_submodule_update_t;
+
+typedef enum {
+ GIT_SUBMODULE_IGNORE_ALL = 0, /* never dirty */
+ GIT_SUBMODULE_IGNORE_DIRTY = 1, /* only dirty if HEAD moved */
+ GIT_SUBMODULE_IGNORE_UNTRACKED = 2, /* dirty if tracked files change */
+ GIT_SUBMODULE_IGNORE_NONE = 3 /* any change or untracked == dirty */
+} git_submodule_ignore_t;
+
+/**
+ * Description of submodule
+ *
+ * This record describes a submodule found in a repository. There
+ * should be an entry for every submodule found in the HEAD and for
+ * every submodule described in .gitmodules. The fields are as follows:
+ *
+ * - `name` is the name of the submodule from .gitmodules.
+ * - `path` is the path to the submodule from the repo working directory.
+ * It is almost always the same as `name`.
+ * - `url` is the url for the submodule.
+ * - `oid` is the HEAD SHA1 for the submodule.
+ * - `update` is a value from above - see gitmodules(5) update.
+ * - `ignore` is a value from above - see gitmodules(5) ignore.
+ * - `fetch_recurse` is 0 or 1 - see gitmodules(5) fetchRecurseSubmodules.
+ * - `refcount` is for internal use.
+ *
+ * If the submodule has been added to .gitmodules but not yet git added,
+ * then the `oid` will be zero. If the submodule has been deleted, but
+ * the delete has not been committed yet, then the `oid` will be set, but
+ * the `url` will be NULL.
+ */
+typedef struct {
+ char *name;
+ char *path;
+ char *url;
+ git_oid oid; /* sha1 of submodule HEAD ref or zero if not committed */
+ git_submodule_update_t update;
+ git_submodule_ignore_t ignore;
+ int fetch_recurse;
+ int refcount;
+} git_submodule;
+
+/**
+ * Iterate over all submodules of a repository.
+ *
+ * @param repo The repository
+ * @param callback Function to be called with the name of each submodule.
+ * Return a non-zero value to terminate the iteration.
+ * @param payload Extra data to pass to callback
+ * @return 0 on success, -1 on error, or non-zero return value of callback
+ */
+GIT_EXTERN(int) git_submodule_foreach(
+ git_repository *repo,
+ int (*callback)(const char *name, void *payload),
+ void *payload);
+
+/**
+ * Lookup submodule information by name or path.
+ *
+ * Given either the submodule name or path (they are ususally the same),
+ * this returns a structure describing the submodule. If the submodule
+ * does not exist, this will return GIT_ENOTFOUND and set the submodule
+ * pointer to NULL.
+ *
+ * @param submodule Pointer to submodule description object pointer..
+ * @param repo The repository.
+ * @param name The name of the submodule. Trailing slashes will be ignored.
+ * @return 0 on success, GIT_ENOTFOUND if submodule does not exist, -1 on error
+ */
+GIT_EXTERN(int) git_submodule_lookup(
+ git_submodule **submodule,
+ git_repository *repo,
+ const char *name);
+
+/** @} */
+GIT_END_DECL
+#endif
diff --git a/include/git2/tag.h b/include/git2/tag.h
index be49621e9..859c28995 100644
--- a/include/git2/tag.h
+++ b/include/git2/tag.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -27,7 +27,7 @@ GIT_BEGIN_DECL
* @param tag pointer to the looked up tag
* @param repo the repo to use when locating the tag.
* @param id identity of the tag to locate.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_INLINE(int) git_tag_lookup(git_tag **tag, git_repository *repo, const git_oid *id)
{
@@ -44,7 +44,7 @@ GIT_INLINE(int) git_tag_lookup(git_tag **tag, git_repository *repo, const git_oi
* @param repo the repo to use when locating the tag.
* @param id identity of the tag to locate.
* @param len the length of the short identifier
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_INLINE(int) git_tag_lookup_prefix(git_tag **tag, git_repository *repo, const git_oid *id, unsigned int len)
{
@@ -85,7 +85,7 @@ GIT_EXTERN(const git_oid *) git_tag_id(git_tag *tag);
*
* @param target pointer where to store the target
* @param tag a previously loaded tag.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_tag_target(git_object **target, git_tag *tag);
@@ -137,6 +137,9 @@ GIT_EXTERN(const char *) git_tag_message(git_tag *tag);
* this tag object. If `force` is true and a reference
* already exists with the given name, it'll be replaced.
*
+ * The message will be cleaned up from excess whitespace
+ * it will be made sure that the last line ends with a '\n'.
+ *
* @param oid Pointer where to store the OID of the
* newly created tag. If the tag already exists, this parameter
* will be the oid of the existing tag, and the function will
@@ -158,7 +161,7 @@ GIT_EXTERN(const char *) git_tag_message(git_tag *tag);
*
* @param force Overwrite existing references
*
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
* A tag object is written to the ODB, and a proper reference
* is written in the /refs/tags folder, pointing to it
*/
@@ -209,7 +212,7 @@ GIT_EXTERN(int) git_tag_create_frombuffer(
*
* @param force Overwrite existing references
*
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
* A proper reference is written in the /refs/tags folder,
* pointing to the provided target object
*/
@@ -228,7 +231,7 @@ GIT_EXTERN(int) git_tag_create_lightweight(
* @param tag_name Name of the tag to be deleted;
* this name is validated for consistency.
*
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_tag_delete(
git_repository *repo,
@@ -245,7 +248,7 @@ GIT_EXTERN(int) git_tag_delete(
* @param tag_names Pointer to a git_strarray structure where
* the tag names will be stored
* @param repo Repository where to find the tags
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_tag_list(
git_strarray *tag_names,
@@ -267,13 +270,28 @@ GIT_EXTERN(int) git_tag_list(
* the tag names will be stored
* @param pattern Standard fnmatch pattern
* @param repo Repository where to find the tags
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_tag_list_match(
git_strarray *tag_names,
const char *pattern,
git_repository *repo);
+/**
+ * Recursively peel a tag until a non tag git_object
+ * is met
+ *
+ * The retrieved `tag_target` object is owned by the repository
+ * and should be closed with the `git_object_free` method.
+ *
+ * @param tag_target Pointer to the peeled git_object
+ * @param tag The tag to be processed
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_tag_peel(
+ git_object **tag_target,
+ git_tag *tag);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/threads.h b/include/git2/threads.h
index 85472a441..567a10487 100644
--- a/include/git2/threads.h
+++ b/include/git2/threads.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
diff --git a/include/git2/tree.h b/include/git2/tree.h
index 982646628..777f8ff0d 100644
--- a/include/git2/tree.h
+++ b/include/git2/tree.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -27,7 +27,7 @@ GIT_BEGIN_DECL
* @param tree pointer to the looked up tree
* @param repo the repo to use when locating the tree.
* @param id identity of the tree to locate.
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_INLINE(int) git_tree_lookup(git_tree **tree, git_repository *repo, const git_oid *id)
{
@@ -44,7 +44,7 @@ GIT_INLINE(int) git_tree_lookup(git_tree **tree, git_repository *repo, const git
* @param repo the repo to use when locating the tree.
* @param id identity of the tree to locate.
* @param len the length of the short identifier
- * @return GIT_SUCCESS or an error code
+ * @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)
{
@@ -141,9 +141,9 @@ GIT_EXTERN(git_otype) git_tree_entry_type(const git_tree_entry *entry);
* @param object pointer to the converted object
* @param repo repository where to lookup the pointed object
* @param entry a tree entry
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
-GIT_EXTERN(int) git_tree_entry_2object(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
@@ -159,7 +159,7 @@ GIT_EXTERN(int) git_tree_entry_2object(git_object **object_out, git_repository *
*
* @param oid Pointer where to store the written tree
* @param index Index to write
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_tree_create_fromindex(git_oid *oid, git_index *index);
@@ -229,7 +229,7 @@ GIT_EXTERN(const git_tree_entry *) git_treebuilder_get(git_treebuilder *bld, con
* @param filename Filename of the entry
* @param id SHA1 oid of the entry
* @param attributes Folder attributes of the entry
- * @return GIT_SUCCESS or an error code
+ * @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);
@@ -264,7 +264,7 @@ GIT_EXTERN(void) git_treebuilder_filter(git_treebuilder *bld, int (*filter)(cons
* @param oid Pointer where to store the written OID
* @param repo Repository where to store the object
* @param bld Tree builder to write
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_treebuilder_write(git_oid *oid, git_repository *repo, git_treebuilder *bld);
@@ -278,8 +278,7 @@ GIT_EXTERN(int) git_treebuilder_write(git_oid *oid, git_repository *repo, git_tr
* @param subtree Pointer where to store the subtree
* @param root A previously loaded tree which will be the root of the relative path
* @param subtree_path Path to the contained subtree
- * @return GIT_SUCCESS on success; GIT_ENOTFOUND if the path does not lead to a
- * subtree, GIT_EINVALIDPATH or an error code
+ * @return 0 on success; GIT_ENOTFOUND if the path does not lead to a subtree
*/
GIT_EXTERN(int) git_tree_get_subtree(git_tree **subtree, git_tree *root, const char *subtree_path);
@@ -309,45 +308,11 @@ enum git_treewalk_mode {
* @param callback Function to call on each tree entry
* @param mode Traversal mode (pre or post-order)
* @param payload Opaque pointer to be passed on each callback
- * @return GIT_SUCCESS or an error code
+ * @return 0 or an error code
*/
GIT_EXTERN(int) git_tree_walk(git_tree *tree, git_treewalk_cb callback, int mode, void *payload);
/** @} */
-typedef enum {
- GIT_STATUS_ADDED = 1,
- GIT_STATUS_DELETED = 2,
- GIT_STATUS_MODIFIED = 3,
-} git_status_t;
-
-typedef struct {
- unsigned int old_attr;
- unsigned int new_attr;
- git_oid old_oid;
- git_oid new_oid;
- git_status_t status;
- const char *path;
-} git_tree_diff_data;
-
-typedef int (*git_tree_diff_cb)(const git_tree_diff_data *ptr, void *data);
-
-/**
- * Diff two trees
- *
- * Compare two trees. For each difference in the trees, the callback
- * will be called with a git_tree_diff_data filled with the relevant
- * information.
- *
- * @param old the "old" tree
- * @param newer the "newer" tree
- * @param cb callback
- * @param data data to give to the callback
- * @return GIT_SUCCESS or an error code
- */
-int git_tree_diff(git_tree *old, git_tree *newer, git_tree_diff_cb cb, void *data);
-
-int git_tree_diff_index_recursive(git_tree *tree, git_index *index, git_tree_diff_cb cb, void *data);
-
GIT_END_DECL
#endif
diff --git a/include/git2/types.h b/include/git2/types.h
index ea97ee915..cfb0acf33 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -131,6 +131,9 @@ typedef struct git_reflog_entry git_reflog_entry;
/** Representation of a reference log */
typedef struct git_reflog git_reflog;
+/** Representation of a git note */
+typedef struct git_note git_note;
+
/** Time in a signature */
typedef struct git_time {
git_time_t time; /** time in seconds from epoch */
@@ -155,8 +158,13 @@ typedef enum {
GIT_REF_PACKED = 4,
GIT_REF_HAS_PEEL = 8,
GIT_REF_LISTALL = GIT_REF_OID|GIT_REF_SYMBOLIC|GIT_REF_PACKED,
-} git_rtype;
+} git_ref_t;
+/** Basic type of any Git branch. */
+typedef enum {
+ GIT_BRANCH_LOCAL = 1,
+ GIT_BRANCH_REMOTE = 2,
+} git_branch_t;
typedef struct git_refspec git_refspec;
typedef struct git_remote git_remote;
diff --git a/include/git2/version.h b/include/git2/version.h
index d78178727..8edbe323c 100644
--- a/include/git2/version.h
+++ b/include/git2/version.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
@@ -7,9 +7,9 @@
#ifndef INCLUDE_git_version_h__
#define INCLUDE_git_version_h__
-#define LIBGIT2_VERSION "0.16.0"
+#define LIBGIT2_VERSION "0.17.0"
#define LIBGIT2_VER_MAJOR 0
-#define LIBGIT2_VER_MINOR 16
+#define LIBGIT2_VER_MINOR 17
#define LIBGIT2_VER_REVISION 0
#endif
diff --git a/include/git2/windows.h b/include/git2/windows.h
index 6a2e9e2cd..8b743f0aa 100644
--- a/include/git2/windows.h
+++ b/include/git2/windows.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 the libgit2 contributors
+ * 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.
diff --git a/include/git2/zlib.h b/include/git2/zlib.h
deleted file mode 100644
index e3dd23f96..000000000
--- a/include/git2/zlib.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2009-2011 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_zlib_h__
-#define INCLUDE_git_zlib_h__
-
-#include <zlib.h>
-
-/**
- * @file git2/zlib.h
- * @brief Git data compression routines
- * @defgroup git_zlib Git data compression routines
- * @ingroup Git
- * @{
- */
-GIT_BEGIN_DECL
-
-#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
-/**
- * deflateBound returns an upper bound on the compressed size.
- *
- * This is a stub function used when zlib does not supply the
- * deflateBound() implementation itself.
- *
- * @param stream the stream pointer.
- * @param s total length of the source data (in bytes).
- * @return maximum length of the compressed data.
- */
-GIT_INLINE(size_t) deflateBound(z_streamp stream, size_t s)
-{
- return (s + ((s + 7) >> 3) + ((s + 63) >> 6) + 11);
-}
-#endif
-
-/** @} */
-GIT_END_DECL
-#endif