summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVicent Marti <vicent@github.com>2014-05-02 09:50:15 -0700
committerVicent Marti <vicent@github.com>2014-05-02 09:50:15 -0700
commit272b462db7cfb50c1ab69e1edda214b21f242ae5 (patch)
tree13c7a7ef6e7ef1e6d90949e60a3d4677ef9096e4 /include
parent9862ef8ef8ffd95a74be8082acab9fea0de85edb (diff)
parent99dfa470398b9c4e06e5a5ee61868d3b9e21b26e (diff)
downloadlibgit2-272b462db7cfb50c1ab69e1edda214b21f242ae5.tar.gz
Merge pull request #2308 from libgit2/rb/diff-update-index-stat-cache
Reduce excessive OID calculation for diff and stat
Diffstat (limited to 'include')
-rw-r--r--include/git2/blame.h19
-rw-r--r--include/git2/checkout.h11
-rw-r--r--include/git2/cherrypick.h11
-rw-r--r--include/git2/clone.h19
-rw-r--r--include/git2/diff.h80
-rw-r--r--include/git2/index.h2
-rw-r--r--include/git2/merge.h6
-rw-r--r--include/git2/push.h4
-rw-r--r--include/git2/remote.h9
-rw-r--r--include/git2/repository.h9
-rw-r--r--include/git2/revert.h11
-rw-r--r--include/git2/status.h15
-rw-r--r--include/git2/sys/config.h9
-rw-r--r--include/git2/sys/diff.h28
-rw-r--r--include/git2/sys/odb_backend.h9
-rw-r--r--include/git2/sys/refdb_backend.h9
-rw-r--r--include/git2/transport.h9
17 files changed, 135 insertions, 125 deletions
diff --git a/include/git2/blame.h b/include/git2/blame.h
index b7fa9aeda..7f0de1731 100644
--- a/include/git2/blame.h
+++ b/include/git2/blame.h
@@ -83,17 +83,16 @@ typedef struct git_blame_options {
#define GIT_BLAME_OPTIONS_INIT {GIT_BLAME_OPTIONS_VERSION}
/**
-* Initializes a `git_blame_options` with default values. Equivalent to
-* creating an instance with GIT_BLAME_OPTIONS_INIT.
-*
-* @param opts the `git_blame_options` instance to initialize.
-* @param version the version of the struct; you should pass
-* `GIT_BLAME_OPTIONS_VERSION` here.
-* @return Zero on success; -1 on failure.
-*/
+ * Initializes a `git_blame_options` with default values. Equivalent to
+ * creating an instance with GIT_BLAME_OPTIONS_INIT.
+ *
+ * @param opts The `git_blame_options` struct to initialize
+ * @param version Version of struct; pass `GIT_BLAME_OPTIONS_VERSION`
+ * @return Zero on success; -1 on failure.
+ */
GIT_EXTERN(int) git_blame_init_options(
- git_blame_options* opts,
- int version);
+ git_blame_options *opts,
+ unsigned int version);
/**
* Structure that represents a blame hunk.
diff --git a/include/git2/checkout.h b/include/git2/checkout.h
index 69addb7d9..494f67456 100644
--- a/include/git2/checkout.h
+++ b/include/git2/checkout.h
@@ -270,14 +270,13 @@ typedef struct git_checkout_options {
* Initializes a `git_checkout_options` with default values. Equivalent to
* creating an instance with GIT_CHECKOUT_OPTIONS_INIT.
*
-* @param opts the `git_checkout_options` instance to initialize.
-* @param version the version of the struct; you should pass
-* `GIT_CHECKOUT_OPTIONS_VERSION` here.
+* @param opts the `git_checkout_options` struct to initialize.
+* @param version Version of struct; pass `GIT_CHECKOUT_OPTIONS_VERSION`
* @return Zero on success; -1 on failure.
*/
-GIT_EXTERN(int) git_checkout_init_opts(
- git_checkout_options* opts,
- int version);
+GIT_EXTERN(int) git_checkout_init_options(
+ git_checkout_options *opts,
+ unsigned int version);
/**
* Updates files in the index and the working tree to match the content of
diff --git a/include/git2/cherrypick.h b/include/git2/cherrypick.h
index 7c48e6659..e998d325f 100644
--- a/include/git2/cherrypick.h
+++ b/include/git2/cherrypick.h
@@ -37,14 +37,13 @@ typedef struct {
* Initializes a `git_cherry_pick_options` with default values. Equivalent to
* creating an instance with GIT_CHERRY_PICK_OPTIONS_INIT.
*
- * @param opts the `git_cherry_pick_options` instance to initialize.
- * @param version the version of the struct; you should pass
- * `GIT_CHERRY_PICK_OPTIONS_VERSION` here.
+ * @param opts the `git_cherry_pick_options` struct to initialize
+ * @param version Version of struct; pass `GIT_CHERRY_PICK_OPTIONS_VERSION`
* @return Zero on success; -1 on failure.
*/
-GIT_EXTERN(int) git_cherry_pick_init_opts(
- git_cherry_pick_options* opts,
- int version);
+GIT_EXTERN(int) git_cherry_pick_init_options(
+ git_cherry_pick_options *opts,
+ unsigned int version);
/**
* Cherry-picks the given commit against the given "our" commit, producing an
diff --git a/include/git2/clone.h b/include/git2/clone.h
index 20be1a105..985c04bf6 100644
--- a/include/git2/clone.h
+++ b/include/git2/clone.h
@@ -66,17 +66,16 @@ typedef struct git_clone_options {
#define GIT_CLONE_OPTIONS_INIT {GIT_CLONE_OPTIONS_VERSION, {GIT_CHECKOUT_OPTIONS_VERSION, GIT_CHECKOUT_SAFE_CREATE}, GIT_REMOTE_CALLBACKS_INIT}
/**
-* Initializes a `git_clone_options` with default values. Equivalent to
-* creating an instance with GIT_CLONE_OPTIONS_INIT.
-*
-* @param opts the `git_clone_options` instance to initialize.
-* @param version the version of the struct; you should pass
-* `GIT_CLONE_OPTIONS_VERSION` here.
-* @return Zero on success; -1 on failure.
-*/
+ * Initializes a `git_clone_options` with default values. Equivalent to
+ * creating an instance with GIT_CLONE_OPTIONS_INIT.
+ *
+ * @param opts The `git_clone_options` struct to initialize
+ * @param version Version of struct; pass `GIT_CLONE_OPTIONS_VERSION`
+ * @return Zero on success; -1 on failure.
+ */
GIT_EXTERN(int) git_clone_init_options(
- git_clone_options* opts,
- int version);
+ git_clone_options *opts,
+ unsigned int version);
/**
* Clone a remote repository.
diff --git a/include/git2/diff.h b/include/git2/diff.h
index 273f471b6..b40cc6135 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -145,6 +145,13 @@ typedef enum {
*/
GIT_DIFF_ENABLE_FAST_UNTRACKED_DIRS = (1u << 14),
+ /** When diff finds a file in the working directory with stat
+ * information different from the index, but the OID ends up being the
+ * same, write the correct stat information into the index. Note:
+ * without this flag, diff will always leave the index untouched.
+ */
+ GIT_DIFF_UPDATE_INDEX = (1u << 15),
+
/*
* Options controlling how output will be generated
*/
@@ -381,17 +388,16 @@ typedef struct {
{GIT_DIFF_OPTIONS_VERSION, 0, GIT_SUBMODULE_IGNORE_DEFAULT, {NULL,0}, NULL, NULL, 3}
/**
-* Initializes a `git_diff_options` with default values. Equivalent to
-* creating an instance with GIT_DIFF_OPTIONS_INIT.
-*
-* @param opts the `git_diff_options` instance to initialize.
-* @param version the version of the struct; you should pass
-* `GIT_DIFF_OPTIONS_VERSION` here.
-* @return Zero on success; -1 on failure.
-*/
+ * Initializes a `git_diff_options` with default values. Equivalent to
+ * creating an instance with GIT_DIFF_OPTIONS_INIT.
+ *
+ * @param opts The `git_diff_options` struct to initialize
+ * @param version Version of struct; pass `GIT_DIFF_OPTIONS_VERSION`
+ * @return Zero on success; -1 on failure.
+ */
GIT_EXTERN(int) git_diff_init_options(
- git_diff_options* opts,
- int version);
+ git_diff_options *opts,
+ unsigned int version);
/**
* When iterating over a diff, callback that will be made per file.
@@ -622,17 +628,16 @@ typedef struct {
#define GIT_DIFF_FIND_OPTIONS_INIT {GIT_DIFF_FIND_OPTIONS_VERSION}
/**
-* Initializes a `git_diff_find_options` with default values. Equivalent to
-* creating an instance with GIT_DIFF_FIND_OPTIONS_INIT.
-*
-* @param opts the `git_diff_find_options` instance to initialize.
-* @param version the version of the struct; you should pass
-* `GIT_DIFF_FIND_OPTIONS_VERSION` here.
-* @return Zero on success; -1 on failure.
-*/
+ * Initializes a `git_diff_find_options` with default values. Equivalent to
+ * creating an instance with GIT_DIFF_FIND_OPTIONS_INIT.
+ *
+ * @param opts The `git_diff_find_options` struct to initialize
+ * @param version Version of struct; pass `GIT_DIFF_FIND_OPTIONS_VERSION`
+ * @return Zero on success; -1 on failure.
+ */
GIT_EXTERN(int) git_diff_find_init_options(
- git_diff_find_options* opts,
- int version);
+ git_diff_find_options *opts,
+ unsigned int version);
/** @name Diff Generator Functions
*
@@ -804,23 +809,6 @@ GIT_EXTERN(int) git_diff_find_similar(
git_diff *diff,
const git_diff_find_options *options);
-/**
- * Initialize diff options structure
- *
- * In most cases, you can probably just use `GIT_DIFF_OPTIONS_INIT` to
- * initialize the diff options structure, but in some cases that is not
- * going to work. You can call this function instead. Note that you
- * must pass both a pointer to the structure to be initialized and the
- * `GIT_DIFF_OPTIONS_VERSION` value from the header you compiled with.
- *
- * @param options Pointer to git_diff_options memory to be initialized
- * @param version Should be `GIT_DIFF_OPTIONS_VERSION`
- * @return 0 on success, negative on failure (such as unsupported version)
- */
-GIT_EXTERN(int) git_diff_options_init(
- git_diff_options *options,
- unsigned int version);
-
/**@}*/
@@ -1233,17 +1221,17 @@ GIT_EXTERN(int) git_diff_commit_as_email(
const git_diff_options *diff_opts);
/**
-* Initializes a `git_diff_format_email_options` with default values. Equivalent to
-* creating an instance with GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT.
-*
-* @param opts the `git_diff_format_email_options` instance to initialize.
-* @param version the version of the struct; you should pass
-* `GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION` here.
-* @return Zero on success; -1 on failure.
-*/
+ * Initializes a `git_diff_format_email_options` with default values.
+ *
+ * Equivalent to creating an instance with GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT.
+ *
+ * @param opts The `git_diff_format_email_options` struct to initialize
+ * @param version Version of struct; pass `GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION`
+ * @return Zero on success; -1 on failure.
+ */
GIT_EXTERN(int) git_diff_format_email_init_options(
git_diff_format_email_options *opts,
- int version);
+ unsigned int version);
GIT_END_DECL
diff --git a/include/git2/index.h b/include/git2/index.h
index 05e58a632..cdb87282c 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -61,7 +61,7 @@ typedef struct git_index_entry {
unsigned short flags;
unsigned short flags_extended;
- char *path;
+ const char *path;
} git_index_entry;
/**
diff --git a/include/git2/merge.h b/include/git2/merge.h
index 6d97e81e6..ef2dc3804 100644
--- a/include/git2/merge.h
+++ b/include/git2/merge.h
@@ -57,7 +57,7 @@ typedef struct {
*/
GIT_EXTERN(int) git_merge_file_init_input(
git_merge_file_input *opts,
- int version);
+ unsigned int version);
/**
* Flags for `git_merge_tree` options. A combination of these flags can be
@@ -164,7 +164,7 @@ typedef struct {
*/
GIT_EXTERN(int) git_merge_file_init_options(
git_merge_file_options *opts,
- int version);
+ unsigned int version);
typedef struct {
/**
@@ -232,7 +232,7 @@ typedef struct {
*/
GIT_EXTERN(int) git_merge_init_options(
git_merge_options *opts,
- int version);
+ unsigned int version);
/**
* The results of `git_merge_analysis` indicate the merge opportunities.
diff --git a/include/git2/push.h b/include/git2/push.h
index 7a8bec12c..cbf115661 100644
--- a/include/git2/push.h
+++ b/include/git2/push.h
@@ -49,8 +49,8 @@ typedef struct {
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_push_init_options(
- git_push_options* opts,
- int version);
+ git_push_options *opts,
+ unsigned int version);
/** Push network progress notification function */
typedef int (*git_push_transfer_progress)(
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 11e1e26d0..3633501e2 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -501,14 +501,13 @@ struct git_remote_callbacks {
* Initializes a `git_remote_callbacks` with default values. Equivalent to
* creating an instance with GIT_REMOTE_CALLBACKS_INIT.
*
- * @param opts the `git_remote_callbacks` instance to initialize.
- * @param version the version of the struct; you should pass
- * `GIT_REMOTE_CALLBACKS_VERSION` here.
+ * @param opts the `git_remote_callbacks` struct to initialize
+ * @param version Version of struct; pass `GIT_REMOTE_CALLBACKS_VERSION`
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_remote_init_callbacks(
- git_remote_callbacks* opts,
- int version);
+ git_remote_callbacks *opts,
+ unsigned int version);
/**
* Set the callbacks for a remote
diff --git a/include/git2/repository.h b/include/git2/repository.h
index 4433e71a2..e3f687a29 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -271,14 +271,13 @@ typedef struct {
* Initializes a `git_repository_init_options` with default values. Equivalent
* to creating an instance with GIT_REPOSITORY_INIT_OPTIONS_INIT.
*
- * @param opts the `git_repository_init_options` instance to initialize.
- * @param version the version of the struct; you should pass
- * `GIT_REPOSITORY_INIT_OPTIONS_VERSION` here.
+ * @param opts the `git_repository_init_options` struct to initialize
+ * @param version Version of struct; pass `GIT_REPOSITORY_INIT_OPTIONS_VERSION`
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_repository_init_init_options(
- git_repository_init_options* opts,
- int version);
+ git_repository_init_options *opts,
+ unsigned int version);
/**
* Create a new Git repository in the given folder with extended controls.
diff --git a/include/git2/revert.h b/include/git2/revert.h
index 3a6beb6b8..da37fbe7b 100644
--- a/include/git2/revert.h
+++ b/include/git2/revert.h
@@ -37,14 +37,13 @@ typedef struct {
* Initializes a `git_revert_options` with default values. Equivalent to
* creating an instance with GIT_REVERT_OPTIONS_INIT.
*
- * @param opts the `git_revert_options` instance to initialize.
- * @param version the version of the struct; you should pass
- * `GIT_REVERT_OPTIONS_VERSION` here.
+ * @param opts the `git_revert_options` struct to initialize
+ * @param version Version of struct; pass `GIT_REVERT_OPTIONS_VERSION`
* @return Zero on success; -1 on failure.
*/
-GIT_EXTERN(int) git_revert_init_opts(
- git_revert_options* opts,
- int version);
+GIT_EXTERN(int) git_revert_init_options(
+ git_revert_options *opts,
+ unsigned int version);
/**
* Reverts the given commit against the given "our" commit, producing an
diff --git a/include/git2/status.h b/include/git2/status.h
index 6af45c7dd..effe5e1ea 100644
--- a/include/git2/status.h
+++ b/include/git2/status.h
@@ -121,6 +121,11 @@ typedef enum {
* - GIT_STATUS_OPT_NO_REFRESH bypasses the default status behavior of
* doing a "soft" index reload (i.e. reloading the index data if the
* file on disk has been modified outside libgit2).
+ * - GIT_STATUS_OPT_UPDATE_INDEX tells libgit2 to refresh the stat cache
+ * in the index for files that are unchanged but have out of date stat
+ * information in the index. It will result in less work being done on
+ * subsequent calls to get status. This is mutually exclusive with the
+ * NO_REFRESH option.
*
* Calling `git_status_foreach()` is like calling the extended version
* with: GIT_STATUS_OPT_INCLUDE_IGNORED, GIT_STATUS_OPT_INCLUDE_UNTRACKED,
@@ -141,6 +146,7 @@ typedef enum {
GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY = (1u << 10),
GIT_STATUS_OPT_RENAMES_FROM_REWRITES = (1u << 11),
GIT_STATUS_OPT_NO_REFRESH = (1u << 12),
+ GIT_STATUS_OPT_UPDATE_INDEX = (1u << 13),
} git_status_opt_t;
#define GIT_STATUS_OPT_DEFAULTS \
@@ -178,14 +184,13 @@ typedef struct {
* Initializes a `git_status_options` with default values. Equivalent to
* creating an instance with GIT_STATUS_OPTIONS_INIT.
*
- * @param opts the `git_status_options` instance to initialize.
- * @param version the version of the struct; you should pass
- * `GIT_STATUS_OPTIONS_VERSION` here.
+ * @param opts The `git_status_options` instance to initialize.
+ * @param version Version of struct; pass `GIT_STATUS_OPTIONS_VERSION`
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_status_init_options(
- git_status_options* opts,
- int version);
+ git_status_options *opts,
+ unsigned int version);
/**
* A status entry, providing the differences between the file as it exists
diff --git a/include/git2/sys/config.h b/include/git2/sys/config.h
index 3df2ba327..46bb65293 100644
--- a/include/git2/sys/config.h
+++ b/include/git2/sys/config.h
@@ -73,14 +73,13 @@ struct git_config_backend {
* Initializes a `git_config_backend` with default values. Equivalent to
* creating an instance with GIT_CONFIG_BACKEND_INIT.
*
- * @param opts the `git_config_backend` instance to initialize.
- * @param version the version of the struct; you should pass
- * `GIT_CONFIG_BACKEND_VERSION` here.
+ * @param opts the `git_config_backend` struct to initialize.
+ * @param version Version of struct; pass `GIT_CONFIG_BACKEND_VERSION`
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_config_init_backend(
- git_config_backend* backend,
- int version);
+ git_config_backend *backend,
+ unsigned int version);
/**
* Add a generic config file instance to an existing config
diff --git a/include/git2/sys/diff.h b/include/git2/sys/diff.h
index bc6cdf393..48d72f4f9 100644
--- a/include/git2/sys/diff.h
+++ b/include/git2/sys/diff.h
@@ -10,6 +10,8 @@
#include "git2/common.h"
#include "git2/types.h"
#include "git2/oid.h"
+#include "git2/diff.h"
+#include "git2/status.h"
/**
* @file git2/sys/diff.h
@@ -58,6 +60,32 @@ GIT_EXTERN(int) git_diff_print_callback__to_file_handle(
const git_diff_line *line,
void *payload); /*< payload must be a `FILE *` */
+
+typedef struct {
+ unsigned int version;
+ size_t stat_calls;
+ size_t oid_calculations;
+} git_diff_perfdata;
+
+#define GIT_DIFF_PERFDATA_VERSION 1
+#define GIT_DIFF_PERFDATA_INIT {GIT_DIFF_PERFDATA_VERSION,0,0}
+
+/**
+ * Get performance data for a diff object.
+ *
+ * @param out Structure to be filled with diff performance data
+ * @param diff Diff to read performance data from
+ * @return 0 for success, <0 for error
+ */
+GIT_EXTERN(int) git_diff_get_perfdata(
+ git_diff_perfdata *out, const git_diff *diff);
+
+/**
+ * Get performance data for diffs from a git_status_list
+ */
+GIT_EXTERN(int) git_status_list_get_perfdata(
+ git_diff_perfdata *out, const git_status_list *status);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/sys/odb_backend.h b/include/git2/sys/odb_backend.h
index 77fe0dd31..1fc3c3159 100644
--- a/include/git2/sys/odb_backend.h
+++ b/include/git2/sys/odb_backend.h
@@ -93,14 +93,13 @@ struct git_odb_backend {
* Initializes a `git_odb_backend` with default values. Equivalent to
* creating an instance with GIT_ODB_BACKEND_INIT.
*
- * @param opts the `git_odb_backend` instance to initialize.
- * @param version the version of the struct; you should pass
- * `GIT_ODB_BACKEND_VERSION` here.
+ * @param opts the `git_odb_backend` struct to initialize.
+ * @param version Version the struct; pass `GIT_ODB_BACKEND_VERSION`
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_odb_init_backend(
- git_odb_backend* backend,
- int version);
+ git_odb_backend *backend,
+ unsigned int version);
GIT_EXTERN(void *) git_odb_backend_malloc(git_odb_backend *backend, size_t len);
diff --git a/include/git2/sys/refdb_backend.h b/include/git2/sys/refdb_backend.h
index dce142c77..3b216a287 100644
--- a/include/git2/sys/refdb_backend.h
+++ b/include/git2/sys/refdb_backend.h
@@ -162,14 +162,13 @@ struct git_refdb_backend {
* Initializes a `git_refdb_backend` with default values. Equivalent to
* creating an instance with GIT_REFDB_BACKEND_INIT.
*
- * @param opts the `git_refdb_backend` instance to initialize.
- * @param version the version of the struct; you should pass
- * `GIT_REFDB_BACKEND_VERSION` here.
+ * @param opts the `git_refdb_backend` struct to initialize
+ * @param version Version of struct; pass `GIT_REFDB_BACKEND_VERSION`
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_refdb_init_backend(
- git_refdb_backend* backend,
- int version);
+ git_refdb_backend *backend,
+ unsigned int version);
/**
* Constructors for default filesystem-based refdb backend
diff --git a/include/git2/transport.h b/include/git2/transport.h
index a33146ca8..af7812b5d 100644
--- a/include/git2/transport.h
+++ b/include/git2/transport.h
@@ -314,14 +314,13 @@ struct git_transport {
* Initializes a `git_transport` with default values. Equivalent to
* creating an instance with GIT_TRANSPORT_INIT.
*
- * @param opts the `git_transport` instance to initialize.
- * @param version the version of the struct; you should pass
- * `GIT_TRANSPORT_VERSION` here.
+ * @param opts the `git_transport` struct to initialize
+ * @param version Version of struct; pass `GIT_TRANSPORT_VERSION`
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_transport_init(
- git_transport* opts,
- int version);
+ git_transport *opts,
+ unsigned int version);
/**
* Function to use to create a transport from a URL. The transport database