Skip to content

Commit 0fd5a44

Browse files
authored
Merge pull request libgit2#3888 from libgit2/ethomson/doc_diff_from_buffer
diff: document `git_diff_from_buffer`
2 parents 56bbdf9 + e2e7f31 commit 0fd5a44

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ v0.24 + 1
4646
`git_repository_open_ext` with this flag will error out if either
4747
`$GIT_WORK_TREE` or `$GIT_COMMON_DIR` is set.
4848

49+
* `git_diff_from_buffer` can create a `git_diff` object from the contents
50+
of a git-style patch file.
51+
4952
### API removals
5053

5154
* `git_blob_create_fromchunks()` has been removed in favour of

include/git2/diff.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,25 @@ GIT_EXTERN(int) git_diff_buffers(
11891189
git_diff_line_cb line_cb,
11901190
void *payload);
11911191

1192+
/**
1193+
* Read the contents of a git patch file into a `git_diff` object.
1194+
*
1195+
* The diff object produced is similar to the one that would be
1196+
* produced if you actually produced it computationally by comparing
1197+
* two trees, however there may be subtle differences. For example,
1198+
* a patch file likely contains abbreviated object IDs, so the
1199+
* object IDs in a `git_diff_delta` produced by this function will
1200+
* also be abbreviated.
1201+
*
1202+
* This function will only read patch files created by a git
1203+
* implementation, it will not read unified diffs produced by
1204+
* the `diff` program, nor any other types of patch files.
1205+
*
1206+
* @param out A pointer to a git_diff pointer that will be allocated.
1207+
* @param content The contents of a patch file
1208+
* @param content_len The length of the patch file contents
1209+
* @return 0 or an error code
1210+
*/
11921211
GIT_EXTERN(int) git_diff_from_buffer(
11931212
git_diff **out,
11941213
const char *content,

0 commit comments

Comments
 (0)