@@ -264,10 +264,15 @@ typedef enum {
264264 * link, a submodule commit id, or even a tree (although that only if you
265265 * are tracking type changes or ignored/untracked directories).
266266 *
267- * The `oid ` is the `git_oid` of the item. If the entry represents an
267+ * The `id ` is the `git_oid` of the item. If the entry represents an
268268 * absent side of a diff (e.g. the `old_file` of a `GIT_DELTA_ADDED` delta),
269269 * then the oid will be zeroes.
270270 *
271+ * The `id_abbrev` represents the known length of the `id` field, when
272+ * converted to a hex string. It is generally `GIT_OID_HEXSZ`, unless this
273+ * delta was created from reading a patch file, in which case it may be
274+ * abbreviated to something reasonable, like 7 characters.
275+ *
271276 * `path` is the NUL-terminated path to the entry relative to the working
272277 * directory of the repository.
273278 *
@@ -280,6 +285,7 @@ typedef enum {
280285 */
281286typedef struct {
282287 git_oid id ;
288+ int id_abbrev ;
283289 const char * path ;
284290 git_off_t size ;
285291 uint32_t flags ;
@@ -448,6 +454,8 @@ typedef int (*git_diff_file_cb)(
448454 float progress ,
449455 void * payload );
450456
457+ #define GIT_DIFF_HUNK_HEADER_SIZE 128
458+
451459/**
452460 * When producing a binary diff, the binary data returned will be
453461 * either the deflated full ("literal") contents of the file, or
@@ -499,12 +507,12 @@ typedef int(*git_diff_binary_cb)(
499507 * Structure describing a hunk of a diff.
500508 */
501509typedef struct {
502- int old_start ; /**< Starting line number in old_file */
503- int old_lines ; /**< Number of lines in old_file */
504- int new_start ; /**< Starting line number in new_file */
505- int new_lines ; /**< Number of lines in new_file */
506- size_t header_len ; /**< Number of bytes in header text */
507- char header [128 ]; /**< Header text, NUL-byte terminated */
510+ int old_start ; /** Starting line number in old_file */
511+ int old_lines ; /** Number of lines in old_file */
512+ int new_start ; /** Starting line number in new_file */
513+ int new_lines ; /** Number of lines in new_file */
514+ size_t header_len ; /** Number of bytes in header text */
515+ char header [GIT_DIFF_HUNK_HEADER_SIZE ]; /** Header text, NUL-byte terminated */
508516} git_diff_hunk ;
509517
510518/**
@@ -1046,6 +1054,21 @@ GIT_EXTERN(int) git_diff_print(
10461054 git_diff_line_cb print_cb ,
10471055 void * payload );
10481056
1057+ /**
1058+ * Produce the complete formatted text output from a diff into a
1059+ * buffer.
1060+ *
1061+ * @param out A pointer to a user-allocated git_buf that will
1062+ * contain the diff text
1063+ * @param diff A git_diff generated by one of the above functions.
1064+ * @param format A git_diff_format_t value to pick the text format.
1065+ * @return 0 on success or error code
1066+ */
1067+ GIT_EXTERN (int ) git_diff_to_buf (
1068+ git_buf * out ,
1069+ git_diff * diff ,
1070+ git_diff_format_t format );
1071+
10491072/**@}*/
10501073
10511074
@@ -1166,6 +1189,11 @@ GIT_EXTERN(int) git_diff_buffers(
11661189 git_diff_line_cb line_cb ,
11671190 void * payload );
11681191
1192+ GIT_EXTERN (int ) git_diff_from_buffer (
1193+ git_diff * * out ,
1194+ const char * content ,
1195+ size_t content_len );
1196+
11691197/**
11701198 * This is an opaque structure which is allocated by `git_diff_get_stats`.
11711199 * You are responsible for releasing the object memory when done, using the
0 commit comments