summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/git2/checkout.h59
-rw-r--r--include/git2/diff.h297
-rw-r--r--include/git2/errors.h34
-rw-r--r--include/git2/odb.h6
-rw-r--r--include/git2/refs.h15
-rw-r--r--include/git2/refspec.h8
-rw-r--r--include/git2/remote.h24
-rw-r--r--include/git2/repository.h63
-rw-r--r--include/git2/reset.h3
-rw-r--r--include/git2/types.h1
10 files changed, 342 insertions, 168 deletions
diff --git a/include/git2/checkout.h b/include/git2/checkout.h
index deb828722..ef3badbe9 100644
--- a/include/git2/checkout.h
+++ b/include/git2/checkout.h
@@ -21,21 +21,45 @@
*/
GIT_BEGIN_DECL
-
-#define GIT_CHECKOUT_OVERWRITE_EXISTING 0 /* default */
-#define GIT_CHECKOUT_SKIP_EXISTING 1
+enum {
+ GIT_CHECKOUT_DEFAULT = (1 << 0),
+ GIT_CHECKOUT_OVERWRITE_MODIFIED = (1 << 1),
+ GIT_CHECKOUT_CREATE_MISSING = (1 << 2),
+ GIT_CHECKOUT_REMOVE_UNTRACKED = (1 << 3),
+};
/* Use zeros to indicate default settings */
typedef struct git_checkout_opts {
- int existing_file_action; /* default: GIT_CHECKOUT_OVERWRITE_EXISTING */
+ unsigned int checkout_strategy; /* default: GIT_CHECKOUT_DEFAULT */
int disable_filters;
int dir_mode; /* default is 0755 */
int file_mode; /* default is 0644 */
int file_open_flags; /* default is O_CREAT | O_TRUNC | O_WRONLY */
+
+ /* Optional callback to notify the consumer of files that
+ * haven't be checked out because a modified version of them
+ * exist in the working directory.
+ *
+ * When provided, this callback will be invoked when the flag
+ * GIT_CHECKOUT_OVERWRITE_MODIFIED isn't part of the checkout strategy.
+ */
+ int (* skipped_notify_cb)(
+ const char *skipped_file,
+ const git_oid *blob_oid,
+ int file_mode,
+ void *payload);
+
+ void *notify_payload;
+
+ /* when not NULL, arrays of fnmatch pattern specifying
+ * which paths should be taken into account
+ */
+ git_strarray paths;
} git_checkout_opts;
/**
- * Updates files in the working tree to match the commit pointed to by HEAD.
+ * Updates files in the index and the working tree to match the content of the
+ * commit pointed at by HEAD.
*
* @param repo repository to check out (must be non-bare)
* @param opts specifies checkout options (may be NULL)
@@ -49,19 +73,36 @@ GIT_EXTERN(int) git_checkout_head(
git_indexer_stats *stats);
/**
- * Updates files in the working tree to match a commit pointed to by a ref.
+ * Updates files in the working tree to match the content of the index.
*
- * @param ref reference to follow to a commit
+ * @param repo repository to check out (must be non-bare)
* @param opts specifies checkout options (may be NULL)
* @param stats structure through which progress information is reported
* @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
* about the error)
*/
-GIT_EXTERN(int) git_checkout_reference(
- git_reference *ref,
+GIT_EXTERN(int) git_checkout_index(
+ git_repository *repo,
git_checkout_opts *opts,
git_indexer_stats *stats);
+/**
+ * Updates files in the index and working tree to match the content of the
+ * tree pointed at by the treeish.
+ *
+ * @param repo repository to check out (must be non-bare)
+ * @param treeish a commit, tag or tree which content will be used to update
+ * the working directory
+ * @param opts specifies checkout options (may be NULL)
+ * @param stats structure through which progress information is reported
+ * @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
+ * about the error)
+ */
+GIT_EXTERN(int) git_checkout_tree(
+ git_repository *repo,
+ git_object *treeish,
+ git_checkout_opts *opts,
+ git_indexer_stats *stats);
/** @} */
GIT_END_DECL
diff --git a/include/git2/diff.h b/include/git2/diff.h
index 61b5bdbd0..1f7f8ab2a 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -123,7 +123,7 @@ typedef enum {
*/
typedef struct {
git_oid oid;
- char *path;
+ const char *path;
git_off_t size;
unsigned int flags;
uint16_t mode;
@@ -155,7 +155,7 @@ typedef struct {
*/
typedef int (*git_diff_file_fn)(
void *cb_data,
- git_diff_delta *delta,
+ const git_diff_delta *delta,
float progress);
/**
@@ -173,8 +173,8 @@ typedef struct {
*/
typedef int (*git_diff_hunk_fn)(
void *cb_data,
- git_diff_delta *delta,
- git_diff_range *range,
+ const git_diff_delta *delta,
+ const git_diff_range *range,
const char *header,
size_t header_len);
@@ -214,16 +214,20 @@ enum {
*/
typedef int (*git_diff_data_fn)(
void *cb_data,
- git_diff_delta *delta,
- git_diff_range *range,
+ const git_diff_delta *delta,
+ const git_diff_range *range,
char line_origin, /**< GIT_DIFF_LINE_... value from above */
const char *content,
size_t content_len);
/**
- * The diff iterator object is used to scan a diff list.
+ * The diff patch is used to store all the text diffs for a delta.
+ *
+ * You can easily loop over the content of patches and get information about
+ * them.
*/
-typedef struct git_diff_iterator git_diff_iterator;
+typedef struct git_diff_patch git_diff_patch;
+
/** @name Diff List Generator Functions
*
@@ -350,7 +354,7 @@ GIT_EXTERN(int) git_diff_merge(
/**@{*/
/**
- * Iterate over a diff list issuing callbacks.
+ * Loop over all deltas in a diff list issuing callbacks.
*
* This will iterate through all of the files described in a diff. You
* should provide a file callback to learn about each file.
@@ -382,188 +386,191 @@ GIT_EXTERN(int) git_diff_foreach(
git_diff_data_fn line_cb);
/**
- * Create a diff iterator object that can be used to traverse a diff.
+ * Iterate over a diff generating text output like "git diff --name-status".
*
- * This iterator can be used instead of `git_diff_foreach` in situations
- * where callback functions are awkward to use. Because of the way that
- * diffs are calculated internally, using an iterator will use somewhat
- * more memory than `git_diff_foreach` would.
+ * Returning a non-zero value from the callbacks will terminate the
+ * iteration and cause this return `GIT_EUSER`.
*
- * @param iterator Output parameter of newly created iterator.
- * @param diff Diff over which you wish to iterate.
- * @return 0 on success, < 0 on error
+ * @param diff A git_diff_list generated by one of the above functions.
+ * @param cb_data Reference pointer that will be passed to your callback.
+ * @param print_cb Callback to make per line of diff text.
+ * @return 0 on success, GIT_EUSER on non-zero callback, or error code
*/
-GIT_EXTERN(int) git_diff_iterator_new(
- git_diff_iterator **iterator,
- git_diff_list *diff);
+GIT_EXTERN(int) git_diff_print_compact(
+ git_diff_list *diff,
+ void *cb_data,
+ git_diff_data_fn print_cb);
/**
- * Release the iterator object.
+ * Look up the single character abbreviation for a delta status code.
*
- * Call this when you are done using the iterator.
+ * When you call `git_diff_print_compact` it prints single letter codes into
+ * the output such as 'A' for added, 'D' for deleted, 'M' for modified, etc.
+ * It is sometimes convenient to convert a git_delta_t value into these
+ * letters for your own purposes. This function does just that. By the
+ * way, unmodified will return a space (i.e. ' ').
*
- * @param iterator The diff iterator to be freed.
+ * @param delta_t The git_delta_t value to look up
+ * @return The single character label for that code
*/
-GIT_EXTERN(void) git_diff_iterator_free(git_diff_iterator *iterator);
+GIT_EXTERN(char) git_diff_status_char(git_delta_t status);
/**
- * Return progress value for traversing the diff.
- *
- * This returns a value between 0.0 and 1.0 that represents the progress
- * through the diff iterator. The value is monotonically increasing and
- * will advance gradually as you progress through the iteration.
+ * Iterate over a diff generating text output like "git diff".
*
- * @param iterator The diff iterator
- * @return Value between 0.0 and 1.0
- */
-GIT_EXTERN(float) git_diff_iterator_progress(git_diff_iterator *iterator);
-
-/**
- * Return the number of hunks in the current file
+ * This is a super easy way to generate a patch from a diff.
*
- * This will return the number of diff hunks in the current file. If the
- * diff has not been performed yet, this may result in loading the file and
- * performing the diff.
+ * Returning a non-zero value from the callbacks will terminate the
+ * iteration and cause this return `GIT_EUSER`.
*
- * @param iterator The iterator object
- * @return The number of hunks in the current file or <0 on loading failure
+ * @param diff A git_diff_list generated by one of the above functions.
+ * @param cb_data Reference pointer that will be passed to your callbacks.
+ * @param print_cb Callback function to output lines of the diff. This
+ * same function will be called for file headers, hunk
+ * headers, and diff lines. Fortunately, you can probably
+ * use various GIT_DIFF_LINE constants to determine what
+ * text you are given.
+ * @return 0 on success, GIT_EUSER on non-zero callback, or error code
*/
-GIT_EXTERN(int) git_diff_iterator_num_hunks_in_file(git_diff_iterator *iterator);
+GIT_EXTERN(int) git_diff_print_patch(
+ git_diff_list *diff,
+ void *cb_data,
+ git_diff_data_fn print_cb);
/**
- * Return the number of lines in the hunk currently being examined.
- *
- * This will return the number of lines in the current hunk. If the diff
- * has not been performed yet, this may result in loading the file and
- * performing the diff.
+ * Query how many diff records are there in a diff list.
*
- * @param iterator The iterator object
- * @return The number of lines in the current hunk (context, added, and
- * removed all added together) or <0 on loading failure
+ * @param diff A git_diff_list generated by one of the above functions
+ * @return Count of number of deltas in the list
*/
-GIT_EXTERN(int) git_diff_iterator_num_lines_in_hunk(git_diff_iterator *iterator);
+GIT_EXTERN(size_t) git_diff_num_deltas(git_diff_list *diff);
/**
- * Return the delta information for the next file in the diff.
+ * Query how many diff deltas are there in a diff list filtered by type.
*
- * This will return a pointer to the next git_diff_delta` to be processed or
- * NULL if the iterator is at the end of the diff, then advance. This
- * returns the value `GIT_ITEROVER` after processing the last file.
+ * This works just like `git_diff_entrycount()` with an extra parameter
+ * that is a `git_delta_t` and returns just the count of how many deltas
+ * match that particular type.
*
- * @param delta Output parameter for the next delta object
- * @param iterator The iterator object
- * @return 0 on success, GIT_ITEROVER when done, other value < 0 on error
+ * @param diff A git_diff_list generated by one of the above functions
+ * @param type A git_delta_t value to filter the count
+ * @return Count of number of deltas matching delta_t type
*/
-GIT_EXTERN(int) git_diff_iterator_next_file(
- git_diff_delta **delta,
- git_diff_iterator *iterator);
+GIT_EXTERN(size_t) git_diff_num_deltas_of_type(
+ git_diff_list *diff,
+ git_delta_t type);
/**
- * Return the hunk information for the next hunk in the current file.
+ * Return the diff delta and patch for an entry in the diff list.
+ *
+ * The `git_diff_patch` is a newly created object contains the text diffs
+ * for the delta. You have to call `git_diff_patch_free()` when you are
+ * done with it. You can use the patch object to loop over all the hunks
+ * and lines in the diff of the one delta.
*
- * It is recommended that you not call this if the file is a binary
- * file, but it is allowed to do so.
+ * For an unchanged file or a binary file, no `git_diff_patch` will be
+ * created, the output will be set to NULL, and the `binary` flag will be
+ * set true in the `git_diff_delta` structure.
*
- * The `header` text output will contain the standard hunk header that
- * would appear in diff output. The header string will be NUL terminated.
+ * The `git_diff_delta` pointer points to internal data and you do not have
+ * to release it when you are done with it. It will go away when the
+ * `git_diff_list` and `git_diff_patch` go away.
*
- * WARNING! Call this function for the first time on a file is when the
- * actual text diff will be computed (it cannot be computed incrementally)
- * so the first call for a new file is expensive (at least in relative
- * terms - in reality, it is still pretty darn fast).
+ * It is okay to pass NULL for either of the output parameters; if you pass
+ * NULL for the `git_diff_patch`, then the text diff will not be calculated.
*
- * @param range Output pointer to range of lines covered by the hunk;
- * This range object is owned by the library and should not be freed.
- * @param header Output pointer to the text of the hunk header
- * This string is owned by the library and should not be freed.
- * @param header_len Output pointer to store the length of the header text
- * @param iterator The iterator object
- * @return 0 on success, GIT_ITEROVER when done with current file, other
- * value < 0 on error
+ * @param patch Output parameter for the delta patch object
+ * @param delta Output parameter for the delta object
+ * @param diff Diff list object
+ * @param idx Index into diff list
+ * @return 0 on success, other value < 0 on error
*/
-GIT_EXTERN(int) git_diff_iterator_next_hunk(
- git_diff_range **range,
- const char **header,
- size_t *header_len,
- git_diff_iterator *iterator);
+GIT_EXTERN(int) git_diff_get_patch(
+ git_diff_patch **patch,
+ const git_diff_delta **delta,
+ git_diff_list *diff,
+ size_t idx);
/**
- * Return the next line of the current hunk of diffs.
- *
- * The `line_origin` output will tell you what type of line this is
- * (e.g. was it added or removed or is it just context for the diff).
- *
- * The `content` will be a pointer to the file data that goes in the
- * line. IT WILL NOT BE NUL TERMINATED. You have to use the `content_len`
- * value and only process that many bytes of data from the content string.
- *
- * @param line_origin Output pointer to store a GIT_DIFF_LINE value for this
- * next chunk of data. The value is a single character, not a buffer.
- * @param content Output pointer to store the content of the diff; this
- * string is owned by the library and should not be freed.
- * @param content_len Output pointer to store the length of the content.
- * @param iterator The iterator object
- * @return 0 on success, GIT_ITEROVER when done with current line, other
- * value < 0 on error
+ * Free a git_diff_patch object.
*/
-GIT_EXTERN(int) git_diff_iterator_next_line(
- char *line_origin, /**< GIT_DIFF_LINE_... value from above */
- const char **content,
- size_t *content_len,
- git_diff_iterator *iterator);
+GIT_EXTERN(void) git_diff_patch_free(
+ git_diff_patch *patch);
/**
- * Iterate over a diff generating text output like "git diff --name-status".
- *
- * Returning a non-zero value from the callbacks will terminate the
- * iteration and cause this return `GIT_EUSER`.
- *
- * @param diff A git_diff_list generated by one of the above functions.
- * @param cb_data Reference pointer that will be passed to your callback.
- * @param print_cb Callback to make per line of diff text.
- * @return 0 on success, GIT_EUSER on non-zero callback, or error code
+ * Get the delta associated with a patch
*/
-GIT_EXTERN(int) git_diff_print_compact(
- git_diff_list *diff,
- void *cb_data,
- git_diff_data_fn print_cb);
+GIT_EXTERN(const git_diff_delta *) git_diff_patch_delta(
+ git_diff_patch *patch);
/**
- * Iterate over a diff generating text output like "git diff".
+ * Get the number of hunks in a patch
+ */
+GIT_EXTERN(size_t) git_diff_patch_num_hunks(
+ git_diff_patch *patch);
+
+/**
+ * Get the information about a hunk in a patch
*
- * This is a super easy way to generate a patch from a diff.
+ * Given a patch and a hunk index into the patch, this returns detailed
+ * information about that hunk. Any of the output pointers can be passed
+ * as NULL if you don't care about that particular piece of information.
*
- * Returning a non-zero value from the callbacks will terminate the
- * iteration and cause this return `GIT_EUSER`.
+ * @param range Output pointer to git_diff_range of hunk
+ * @param header Output pointer to header string for hunk. Unlike the
+ * content pointer for each line, this will be NUL-terminated
+ * @param header_len Output value of characters in header string
+ * @param lines_in_hunk Output count of total lines in this hunk
+ * @param patch Input pointer to patch object
+ * @param hunk_idx Input index of hunk to get information about
+ * @return 0 on success, GIT_ENOTFOUND if hunk_idx out of range, <0 on error
+ */
+GIT_EXTERN(int) git_diff_patch_get_hunk(
+ const git_diff_range **range,
+ const char **header,
+ size_t *header_len,
+ size_t *lines_in_hunk,
+ git_diff_patch *patch,
+ size_t hunk_idx);
+
+/**
+ * Get the number of lines in a hunk.
*
- * @param diff A git_diff_list generated by one of the above functions.
- * @param cb_data Reference pointer that will be passed to your callbacks.
- * @param print_cb Callback function to output lines of the diff. This
- * same function will be called for file headers, hunk
- * headers, and diff lines. Fortunately, you can probably
- * use various GIT_DIFF_LINE constants to determine what
- * text you are given.
- * @return 0 on success, GIT_EUSER on non-zero callback, or error code
+ * @param patch The git_diff_patch object
+ * @param hunk_idx Index of the hunk
+ * @return Number of lines in hunk or -1 if invalid hunk index
*/
-GIT_EXTERN(int) git_diff_print_patch(
- git_diff_list *diff,
- void *cb_data,
- git_diff_data_fn print_cb);
+GIT_EXTERN(int) git_diff_patch_num_lines_in_hunk(
+ git_diff_patch *patch,
+ size_t hunk_idx);
/**
- * Query how many diff records are there in a diff list.
+ * Get data about a line in a hunk of a patch.
*
- * You can optionally pass in a `git_delta_t` value if you want a count
- * of just entries that match that delta type, or pass -1 for all delta
- * records.
+ * Given a patch, a hunk index, and a line index in the hunk, this
+ * will return a lot of details about that line. If you pass a hunk
+ * index larger than the number of hunks or a line index larger than
+ * the number of lines in the hunk, this will return -1.
*
- * @param diff A git_diff_list generated by one of the above functions
- * @param delta_t A git_delta_t value to filter the count, or -1 for all records
- * @return Count of number of deltas matching delta_t type
+ * @param line_origin A GIT_DIFF_LINE constant from above
+ * @param content Pointer to content of diff line, not NUL-terminated
+ * @param content_len Number of characters in content
+ * @param old_lineno Line number in old file or -1 if line is added
+ * @param new_lineno Line number in new file or -1 if line is deleted
+ * @param patch The patch to look in
+ * @param hunk_idx The index of the hunk
+ * @param line_of_index The index of the line in the hunk
+ * @return 0 on success, <0 on failure
*/
-GIT_EXTERN(int) git_diff_entrycount(
- git_diff_list *diff,
- int delta_t);
+GIT_EXTERN(int) git_diff_patch_get_line_in_hunk(
+ char *line_origin,
+ const char **content,
+ size_t *content_len,
+ int *old_lineno,
+ int *new_lineno,
+ git_diff_patch *patch,
+ size_t hunk_idx,
+ size_t line_of_hunk);
/**@}*/
@@ -589,7 +596,7 @@ GIT_EXTERN(int) git_diff_entrycount(
GIT_EXTERN(int) git_diff_blobs(
git_blob *old_blob,
git_blob *new_blob,
- git_diff_options *options,
+ const git_diff_options *options,
void *cb_data,
git_diff_file_fn file_cb,
git_diff_hunk_fn hunk_cb,
diff --git a/include/git2/errors.h b/include/git2/errors.h
index e5f435926..f6d9bf2e3 100644
--- a/include/git2/errors.h
+++ b/include/git2/errors.h
@@ -71,6 +71,40 @@ GIT_EXTERN(const git_error *) giterr_last(void);
*/
GIT_EXTERN(void) giterr_clear(void);
+/**
+ * Set the error message string for this thread.
+ *
+ * This function is public so that custom ODB backends and the like can
+ * relay an error message through libgit2. Most regular users of libgit2
+ * will never need to call this function -- actually, calling it in most
+ * circumstances (for example, calling from within a callback function)
+ * will just end up having the value overwritten by libgit2 internals.
+ *
+ * This error message is stored in thread-local storage and only applies
+ * to the particular thread that this libgit2 call is made from.
+ *
+ * NOTE: Passing the `error_class` as GITERR_OS has a special behavior: we
+ * attempt to append the system default error message for the last OS error
+ * that occurred and then clear the last error. The specific implementation
+ * of looking up and clearing this last OS error will vary by platform.
+ *
+ * @param error_class One of the `git_error_t` enum above describing the
+ * general subsystem that is responsible for the error.
+ * @param message The formatted error message to keep
+ */
+GIT_EXTERN(void) giterr_set_str(int error_class, const char *string);
+
+/**
+ * Set the error message to a special value for memory allocation failure.
+ *
+ * The normal `giterr_set_str()` function attempts to `strdup()` the string
+ * that is passed in. This is not a good idea when the error in question
+ * is a memory allocation failure. That circumstance has a special setter
+ * function that sets the error string to a known and statically allocated
+ * internal value.
+ */
+GIT_EXTERN(void) giterr_set_oom(void);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/odb.h b/include/git2/odb.h
index 1919f61a0..c6e73571b 100644
--- a/include/git2/odb.h
+++ b/include/git2/odb.h
@@ -279,8 +279,10 @@ GIT_EXTERN(int) git_odb_hash(git_oid *id, const void *data, size_t len, git_otyp
/**
* Read a file from disk and fill a git_oid with the object id
* that the file would have if it were written to the Object
- * Database as an object of the given type. Similar functionality
- * to git.git's `git hash-object` without the `-w` flag.
+ * Database as an object of the given type (w/o applying filters).
+ * Similar functionality to git.git's `git hash-object` without
+ * the `-w` flag, however, with the --no-filters flag.
+ * If you need filters, see git_repository_hashfile.
*
* @param out oid structure the result is written into.
* @param path file to read and determine object id for
diff --git a/include/git2/refs.h b/include/git2/refs.h
index 73b32a9e2..10b73f0c9 100644
--- a/include/git2/refs.h
+++ b/include/git2/refs.h
@@ -392,7 +392,8 @@ enum {
/**
* Control whether one-level refnames are accepted
* (i.e., refnames that do not contain multiple /-separated
- * components)
+ * components). Those are expected to be written only using
+ * uppercase letters and underscore (FETCH_HEAD, ...)
*/
GIT_REF_FORMAT_ALLOW_ONELEVEL = (1 << 0),
@@ -414,8 +415,6 @@ enum {
* Once normalized, if the reference name is valid, it will be
* returned in the user allocated buffer.
*
- * TODO: Implement handling of GIT_REF_FORMAT_REFSPEC_PATTERN
- *
* @param buffer_out The user allocated buffer where the
* normalized name will be stored.
*
@@ -454,6 +453,16 @@ GIT_EXTERN(int) git_reference_peel(
git_reference *ref,
git_otype type);
+/**
+ * Ensure the reference name is well-formed.
+ *
+ * @param refname name to be checked.
+ *
+ * @return 1 if the reference name is acceptable; 0 if it isn't
+ */
+GIT_EXTERN(int) git_reference_is_valid_name(
+ const char *refname);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/refspec.h b/include/git2/refspec.h
index 9e84aad99..1100e9022 100644
--- a/include/git2/refspec.h
+++ b/include/git2/refspec.h
@@ -20,14 +20,6 @@
GIT_BEGIN_DECL
/**
- * Parse a refspec string and create a refspec object
- *
- * @param refspec pointer to the refspec structure to be used
- * @param str the refspec as a string
- */
-GIT_EXTERN(int) git_refspec_parse(git_refspec *refspec, const char *str);
-
-/**
* Get the source specifier
*
* @param refspec the refspec
diff --git a/include/git2/remote.h b/include/git2/remote.h
index a3913af5b..c015289e8 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -304,6 +304,30 @@ struct git_remote_callbacks {
*/
GIT_EXTERN(void) git_remote_set_callbacks(git_remote *remote, git_remote_callbacks *callbacks);
+enum {
+ GIT_REMOTE_DOWNLOAD_TAGS_UNSET,
+ GIT_REMOTE_DOWNLOAD_TAGS_NONE,
+ GIT_REMOTE_DOWNLOAD_TAGS_AUTO,
+ GIT_REMOTE_DOWNLOAD_TAGS_ALL
+};
+
+/**
+ * Retrieve the tag auto-follow setting
+ *
+ * @param remote the remote to query
+ * @return the auto-follow setting
+ */
+GIT_EXTERN(int) git_remote_autotag(git_remote *remote);
+
+/**
+ * Set the tag auto-follow setting
+ *
+ * @param remote the remote to configure
+ * @param value a GIT_REMOTE_DOWNLOAD_TAGS value
+ */
+GIT_EXTERN(void) git_remote_set_autotag(git_remote *remote, int value);
+
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/repository.h b/include/git2/repository.h
index 32ec58dae..025a0a95d 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -456,7 +456,7 @@ GIT_EXTERN(int) git_repository_index(git_index **out, git_repository *repo);
GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index);
/**
- * Retrive git's prepared message
+ * Retrieve git's prepared message
*
* Operations such as git revert/cherry-pick/merge with the -n option
* stop just short of creating a commit with the changes and save
@@ -506,6 +506,67 @@ GIT_EXTERN(int) git_repository_hashfile(
git_otype type,
const char *as_path);
+/**
+ * Make the repository HEAD point to the specified reference.
+ *
+ * If the provided reference points to a Tree or a Blob, the HEAD is
+ * unaltered and -1 is returned.
+ *
+ * If the provided reference points to a branch, the HEAD will point
+ * to that branch, staying attached, or become attached if it isn't yet.
+ * If the branch doesn't exist yet, no error will be return. The HEAD
+ * will then be attached to an unborn branch.
+ *
+ * Otherwise, the HEAD will be detached and will directly point to
+ * the Commit.
+ *
+ * @param repo Repository pointer
+ * @param refname Canonical name of the reference the HEAD should point at
+ * @return 0 on success, or an error code
+ */
+GIT_EXTERN(int) git_repository_set_head(
+ git_repository* repo,
+ const char* refname);
+
+/**
+ * Make the repository HEAD directly point to the Commit.
+ *
+ * If the provided committish cannot be found in the repository, the HEAD
+ * is unaltered and GIT_ENOTFOUND is returned.
+ *
+ * If the provided commitish cannot be peeled into a commit, the HEAD
+ * is unaltered and -1 is returned.
+ *
+ * Otherwise, the HEAD will eventually be detached and will directly point to
+ * the peeled Commit.
+ *
+ * @param repo Repository pointer
+ * @param commitish Object id of the Commit the HEAD should point to
+ * @return 0 on success, or an error code
+ */
+GIT_EXTERN(int) git_repository_set_head_detached(
+ git_repository* repo,
+ const git_oid* commitish);
+
+/**
+ * Detach the HEAD.
+ *
+ * If the HEAD is already detached and points to a Commit, 0 is returned.
+ *
+ * If the HEAD is already detached and points to a Tag, the HEAD is
+ * updated into making it point to the peeled Commit, and 0 is returned.
+ *
+ * If the HEAD is already detached and points to a non commitish, the HEAD is
+ * unaletered, and -1 is returned.
+ *
+ * Otherwise, the HEAD will be detached and point to the peeled Commit.
+ *
+ * @param repo Repository pointer
+ * @return 0 on success, or an error code
+ */
+GIT_EXTERN(int) git_repository_detach_head(
+ git_repository* repo);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/reset.h b/include/git2/reset.h
index cd263fa99..cdcfb7671 100644
--- a/include/git2/reset.h
+++ b/include/git2/reset.h
@@ -24,6 +24,9 @@ GIT_BEGIN_DECL
* Specifying a Mixed kind of reset will trigger a Soft reset and the index will
* be replaced with the content of the commit tree.
*
+ * Specifying a Hard kind of reset will trigger a Mixed reset and the working
+ * directory will be replaced with the content of the index.
+ *
* TODO: Implement remaining kinds of resets.
*
* @param repo Repository where to perform the reset operation.
diff --git a/include/git2/types.h b/include/git2/types.h
index d3a905372..26e9c57e7 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -173,6 +173,7 @@ typedef enum {
typedef enum {
GIT_RESET_SOFT = 1,
GIT_RESET_MIXED = 2,
+ GIT_RESET_HARD = 3,
} git_reset_type;
/** Valid modes for index and tree entries. */