summaryrefslogtreecommitdiff
path: root/include/git2/diff.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-11-01 10:18:03 -0700
committerRussell Belfer <rb@github.com>2013-11-01 10:20:51 -0700
commita5c16f3cfb92f1129ef13124fc70147480141d69 (patch)
tree1f5e321b95d45d4808e61514d2aac353e2a46fb5 /include/git2/diff.h
parent8e5a8ef86f1d528472884f737612083abda86e17 (diff)
downloadlibgit2-a5c16f3cfb92f1129ef13124fc70147480141d69.tar.gz
Add git_diff_options_init helper
Sometimes the static initializer for git_diff_options cannot be used and since setting them to all zeroes doesn't actually work quite right, this adds a new helper for that situation. This also adds an explicit new value to the submodule settings options to be used when those enums need static initialization.
Diffstat (limited to 'include/git2/diff.h')
-rw-r--r--include/git2/diff.h30
1 files changed, 26 insertions, 4 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h
index ac2d4b1e7..a16f86a46 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -352,10 +352,10 @@ typedef struct {
/* options controlling which files are in the diff */
- git_submodule_ignore_t ignore_submodules; /** << submodule ignore rule */
- git_strarray pathspec; /**< defaults to include all paths */
+ git_submodule_ignore_t ignore_submodules; /**< submodule ignore rule */
+ git_strarray pathspec; /**< defaults to include all paths */
git_diff_notify_cb notify_cb;
- void *notify_payload;
+ void *notify_payload;
/* options controlling how to diff text is generated */
@@ -367,9 +367,14 @@ typedef struct {
const char *new_prefix; /**< defaults to "b" */
} git_diff_options;
+/* The current version of the diff options structure */
#define GIT_DIFF_OPTIONS_VERSION 1
+
+/* Stack initializer for diff options. Alternatively use
+ * `git_diff_options_init` programmatic initialization.
+ */
#define GIT_DIFF_OPTIONS_INIT \
- {GIT_DIFF_OPTIONS_VERSION, 0, 0, {NULL,0}, NULL, NULL, 3}
+ {GIT_DIFF_OPTIONS_VERSION, 0, GIT_SUBMODULE_IGNORE_DEFAULT, {NULL,0}, NULL, NULL, 3}
/**
* When iterating over a diff, callback that will be made per file.
@@ -738,6 +743,23 @@ 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);
+
/**@}*/