|
96 | 96 | * diff hunks. |
97 | 97 | *) |
98 | 98 | GIT_DIFF_INDENT_HEURISTIC = (1 shl 18); |
99 | | - (** Ignore blank lines *) |
100 | | - GIT_DIFF_IGNORE_BLANK_LINES = (1 shl 19); |
| 99 | + (** Ignore blank lines *) |
| 100 | + GIT_DIFF_IGNORE_BLANK_LINES = (1 shl 19); |
101 | 101 | (** Treat all files as text, disabling binary attributes & detection *) |
102 | 102 | GIT_DIFF_FORCE_TEXT = (1 shl 20); |
103 | 103 | (** Treat all files as binary, disabling text diffs *) |
|
234 | 234 | mode: uint16_t; |
235 | 235 | (** |
236 | 236 | * Represents the known length of the `id` field, when |
237 | | - * converted to a hex string. It is generally `GIT_OID_SHA1_HEXSIZE`, unless this |
| 237 | + * converted to a hex string. It is generally `GIT_OID_SHA1_HEXSIZE`, unless this |
238 | 238 | * delta was created from reading a patch file, in which case it may be |
239 | 239 | * abbreviated to something reasonable, like 7 characters. |
240 | 240 | *) |
@@ -374,6 +374,21 @@ type |
374 | 374 | * the hunks will be merged into one. Defaults to 0. |
375 | 375 | *) |
376 | 376 | interhunk_lines: uint32_t; |
| 377 | + (** |
| 378 | + * The object ID type to emit in diffs; this is used by functions |
| 379 | + * that operate without a repository - namely `git_diff_buffers`, |
| 380 | + * or `git_diff_blobs` and `git_diff_blob_to_buffer` when one blob |
| 381 | + * is `NULL`. |
| 382 | + * |
| 383 | + * This may be omitted (set to `0`). If a repository is available, |
| 384 | + * the object ID format of the repository will be used. If no |
| 385 | + * repository is available then the default is `GIT_OID_SHA`. |
| 386 | + * |
| 387 | + * If this is specified and a repository is available, then the |
| 388 | + * specified `oid_type` must match the repository's object ID |
| 389 | + * format. |
| 390 | + *) |
| 391 | + oid_type: git_oid_t; |
377 | 392 | (** |
378 | 393 | * The abbreviation length to use when formatting object ids. |
379 | 394 | * Defaults to the value of 'core.abbrev' from the config, or 7 if unset. |
|
700 | 715 | *) |
701 | 716 | copy_threshold: uint16_t; |
702 | 717 | (** |
703 | | - * Threshold below which similar files will be split into a delete/add pair. |
| 718 | + * Threshold below which similar files will be split into a delete/add pair. |
704 | 719 | * This is equivalent to the last part of the -B option. Defaults to 60. |
705 | 720 | *) |
706 | 721 | break_rewrite_threshold: uint16_t; |
@@ -1075,7 +1090,7 @@ function git_diff_to_buf(out_: Pgit_buf; diff: Pgit_diff; format: git_diff_forma |
1075 | 1090 | (**@} *) |
1076 | 1091 |
|
1077 | 1092 | (* |
1078 | | - * Misc |
| 1093 | + * Low-level file comparison, invoking callbacks per difference. |
1079 | 1094 | *) |
1080 | 1095 |
|
1081 | 1096 | (** |
@@ -1168,27 +1183,53 @@ function git_diff_buffers(old_buffer: Pointer; old_len: size_t; old_as_path: PAn |
1168 | 1183 | binary_cb: git_diff_binary_cb; hunk_cb: git_diff_hunk_cb; line_cb: git_diff_line_cb; |
1169 | 1184 | payload: Pointer): Integer; cdecl; external libgit2_dll; |
1170 | 1185 |
|
| 1186 | +(* Patch file parsing. *) |
| 1187 | + |
1171 | 1188 | (** |
1172 | | - * Read the contents of a git patch file into a `git_diff` object. |
1173 | | - * |
1174 | | - * The diff object produced is similar to the one that would be |
1175 | | - * produced if you actually produced it computationally by comparing |
1176 | | - * two trees, however there may be subtle differences. For example, |
1177 | | - * a patch file likely contains abbreviated object IDs, so the |
1178 | | - * object IDs in a `git_diff_delta` produced by this function will |
1179 | | - * also be abbreviated. |
1180 | | - * |
1181 | | - * This function will only read patch files created by a git |
1182 | | - * implementation, it will not read unified diffs produced by |
1183 | | - * the `diff` program, nor any other types of patch files. |
1184 | | - * |
1185 | | - * @param out A pointer to a git_diff pointer that will be allocated. |
1186 | | - * @param content The contents of a patch file |
1187 | | - * @param content_len The length of the patch file contents |
1188 | | - * @return 0 or an error code |
| 1189 | + * Options for parsing a diff / patch file. |
1189 | 1190 | *) |
| 1191 | +type |
| 1192 | + git_diff_parse_options = record |
| 1193 | + version: Cardinal; |
| 1194 | + oid_type: git_oid_t; |
| 1195 | + end; |
| 1196 | + Pgit_diff_parse_options = ^git_diff_parse_options; |
| 1197 | + |
| 1198 | + (* The current version of the diff parse options structure *) |
| 1199 | +const |
| 1200 | + GIT_DIFF_PARSE_OPTIONS_VERSION = 1; |
| 1201 | + |
| 1202 | + (* Stack initializer for diff parse options. Alternatively use |
| 1203 | + * `git_diff_parse_options_init` programmatic initialization. |
| 1204 | + *) |
| 1205 | + //#define GIT_DIFF_PARSE_OPTIONS_INIT \ |
| 1206 | + // { GIT_DIFF_PARSE_OPTIONS_VERSION, GIT_OID_DEFAULT } |
| 1207 | + |
| 1208 | + (** |
| 1209 | + * Read the contents of a git patch file into a `git_diff` object. |
| 1210 | + * |
| 1211 | + * The diff object produced is similar to the one that would be |
| 1212 | + * produced if you actually produced it computationally by comparing |
| 1213 | + * two trees, however there may be subtle differences. For example, |
| 1214 | + * a patch file likely contains abbreviated object IDs, so the |
| 1215 | + * object IDs in a `git_diff_delta` produced by this function will |
| 1216 | + * also be abbreviated. |
| 1217 | + * |
| 1218 | + * This function will only read patch files created by a git |
| 1219 | + * implementation, it will not read unified diffs produced by |
| 1220 | + * the `diff` program, nor any other types of patch files. |
| 1221 | + * |
| 1222 | + * @param out A pointer to a git_diff pointer that will be allocated. |
| 1223 | + * @param content The contents of a patch file |
| 1224 | + * @param content_len The length of the patch file contents |
| 1225 | + * @return 0 or an error code |
| 1226 | + *) |
1190 | 1227 |
|
1191 | | -function git_diff_from_buffer(out_: PPgit_diff; content: PAnsiChar; content_len: size_t): Integer; cdecl; external libgit2_dll; |
| 1228 | +function git_diff_from_buffer(out_: PPgit_diff; content: PAnsiChar; content_len: size_t |
| 1229 | + {$IFDEF GIT_EXPERIMENTAL_SHA256} |
| 1230 | + ; opts: Pgit_diff_parse_options |
| 1231 | + {$ENDIF} |
| 1232 | + ): Integer; cdecl; external libgit2_dll; |
1192 | 1233 |
|
1193 | 1234 | (** |
1194 | 1235 | * This is an opaque structure which is allocated by `git_diff_get_stats`. |
@@ -1229,6 +1270,7 @@ type |
1229 | 1270 | type |
1230 | 1271 | PPgit_diff_stats = ^Pgit_diff_stats; |
1231 | 1272 | Pgit_diff_stats = ^git_diff_stats; |
| 1273 | + |
1232 | 1274 | function git_diff_get_stats(out_: PPgit_diff_stats; diff: Pgit_diff): Integer; cdecl; external libgit2_dll; |
1233 | 1275 |
|
1234 | 1276 | (** |
@@ -1334,5 +1376,3 @@ function git_diff_patchid(out_: Pgit_oid; diff: Pgit_diff; opts: Pgit_diff_patch |
1334 | 1376 |
|
1335 | 1377 | (** @} *) |
1336 | 1378 |
|
1337 | | - |
1338 | | - |
|
0 commit comments