More diff.h comment fixes Based on feedback from the ObjectiveGit folks, these are some further updates to diff.h areas that are poorly documented.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
diff --git a/include/git2/diff.h b/include/git2/diff.h
index f1db90d..b26dd42 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -139,7 +139,8 @@ typedef enum {
* - `new_prefix` is the virtual "directory" to prefix to new file names
* in hunk headers (default "b")
* - `pathspec` is an array of paths / fnmatch patterns to constrain diff
- * - `max_size` is a file size above which a blob will be marked as binary
+ * - `max_size` is a file size (in bytes) above which a blob will be marked
+ * as binary automatically; pass a negative value to disable.
*/
typedef struct {
unsigned int version; /**< version for the struct */
@@ -148,8 +149,8 @@ typedef struct {
uint16_t interhunk_lines; /**< defaults to 0 */
const char *old_prefix; /**< defaults to "a" */
const char *new_prefix; /**< defaults to "b" */
- git_strarray pathspec; /**< defaults to show all paths */
- git_off_t max_size; /**< defaults to 512mb */
+ git_strarray pathspec; /**< defaults to include all paths */
+ git_off_t max_size; /**< defaults to 512MB */
} git_diff_options;
#define GIT_DIFF_OPTIONS_VERSION 1
@@ -157,14 +158,19 @@ typedef struct {
/**
* The diff list object that contains all individual file deltas.
+ *
+ * This is an opaque structure which will be allocated by one of the diff
+ * generator functions below (such as `git_diff_tree_to_tree`). You are
+ * responsible for releasing the object memory when done, using the
+ * `git_diff_list_free()` function.
*/
typedef struct git_diff_list git_diff_list;
/**
- * Flags that can be set for the file on side of a diff.
+ * Flags for the file object on each side of a diff.
*
- * Most of the flags are just for internal consumption by libgit2,
- * but some of them may be interesting to external users.
+ * Note: most of these flags are just for **internal** consumption by
+ * libgit2, but some of them may be interesting to external users.
*/
typedef enum {
GIT_DIFF_FILE_VALID_OID = (1 << 0), /** `oid` value is known correct */
@@ -187,34 +193,38 @@ typedef enum {
* DELETED pairs).
*/
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_TYPECHANGE = 8,
+ GIT_DELTA_UNMODIFIED = 0, /** no changes */
+ GIT_DELTA_ADDED = 1, /** entry does not exist in old version */
+ GIT_DELTA_DELETED = 2, /** entry does not exist in new version */
+ GIT_DELTA_MODIFIED = 3, /** entry content changed between old and new */
+ GIT_DELTA_RENAMED = 4, /** entry was renamed between old and new */
+ GIT_DELTA_COPIED = 5, /** entry was copied from another old entry */
+ GIT_DELTA_IGNORED = 6, /** entry is ignored item in workdir */
+ GIT_DELTA_UNTRACKED = 7, /** entry is untracked item in workdir */
+ GIT_DELTA_TYPECHANGE = 8, /** type of entry changed between old and new */
} git_delta_t;
/**
- * Description of one side of a diff.
+ * Description of one side of a diff entry.
+ *
+ * Although this is called a "file", it may actually represent a file, a
+ * symbolic link, a submodule commit id, or even a tree (although that only
+ * if you are tracking type changes or ignored/untracked directories).
*
- * The `oid` is the `git_oid` of the item. If it represents an absent side
- * of a diff (e.g. the `old_file` of a `GIT_DELTA_ADDED` delta), then the
- * oid will be zeroes.
+ * The `oid` is the `git_oid` of the item. If the entry represents an
+ * absent side of a diff (e.g. the `old_file` of a `GIT_DELTA_ADDED` delta),
+ * then the oid will be zeroes.
*
- * `path` is the NUL-terminated path to the file relative to the working
+ * `path` is the NUL-terminated path to the entry relative to the working
* directory of the repository.
*
- * `size` is the size of the file in bytes.
+ * `size` is the size of the entry in bytes.
*
* `flags` is a combination of the `git_diff_file_flag_t` types, but those
* are largely internal values.
*
- * `mode` is, roughly, the stat() st_mode value for the item. This will be
- * restricted to one of the `git_filemode_t` values.
+ * `mode` is, roughly, the stat() `st_mode` value for the item. This will
+ * be restricted to one of the `git_filemode_t` values.
*/
typedef struct {
git_oid oid;
@@ -225,7 +235,11 @@ typedef struct {
} git_diff_file;
/**
- * Description of changes to one file.
+ * Description of changes to one entry.
+ *
+ * When iterating over a diff list object, this will be passed to most
+ * callback functions and you can use the contents to understand exactly
+ * what has changed.
*
* The `old_file` repesents the "from" side of the diff and the `new_file`
* repesents to "to" side of the diff. What those means depend on the
@@ -253,6 +267,10 @@ typedef struct {
/**
* When iterating over a diff, callback that will be made per file.
+ *
+ * @param delta A pointer to the delta data for the file
+ * @param progress Goes from 0 to 1 over the diff list
+ * @param payload User-specified pointer from foreach function
*/
typedef int (*git_diff_file_cb)(
const git_diff_delta *delta,
@@ -263,10 +281,10 @@ typedef int (*git_diff_file_cb)(
* Structure describing a hunk of a diff.
*/
typedef struct {
- int old_start;
- int old_lines;
- int new_start;
- int new_lines;
+ int old_start; /** Starting line number in old_file */
+ int old_lines; /** Number of lines in old_file */
+ int new_start; /** Starting line number in new_file */
+ int new_lines; /** Number of lines in new_file */
} git_diff_range;
/**
@@ -314,12 +332,12 @@ typedef enum {
* of lines of file and hunk headers.
*/
typedef int (*git_diff_data_cb)(
- 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,
- void *payload);
+ const git_diff_delta *delta, /** delta that contains this data */
+ const git_diff_range *range, /** range of lines containing this data */
+ char line_origin, /** git_diff_list_t value from above */
+ const char *content, /** diff data - not NUL terminated */
+ size_t content_len, /** number of bytes of diff data */
+ void *payload); /** user reference data */
/**
* The diff patch is used to store all the text diffs for a delta.