diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2015-05-25 20:03:59 -0400 |
|---|---|---|
| committer | Edward Thomson <ethomson@microsoft.com> | 2015-06-12 09:39:20 -0400 |
| commit | 8147b1aff56c0f36f6afee9b8810fc74776e1f58 (patch) | |
| tree | 298396fb80a973b990e21084e29b0466ceafe5ed /src/diff_patch.h | |
| parent | ac7012a81f0bdc472a3d22393291eb7d130705d1 (diff) | |
| download | libgit2-8147b1aff56c0f36f6afee9b8810fc74776e1f58.tar.gz | |
diff: introduce binary diff callbacks
Introduce a new binary diff callback to provide the actual binary
delta contents to callers. Create this data from the diff contents
(instead of directly from the ODB) to support binary diffs including
the workdir, not just things coming out of the ODB.
Diffstat (limited to 'src/diff_patch.h')
| -rw-r--r-- | src/diff_patch.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/diff_patch.h b/src/diff_patch.h index df2ba4c31..f6ce57ddd 100644 --- a/src/diff_patch.h +++ b/src/diff_patch.h @@ -13,6 +13,38 @@ #include "array.h" #include "git2/patch.h" + /* cached information about a hunk in a diff */ +typedef struct diff_patch_hunk { + git_diff_hunk hunk; + size_t line_start; + size_t line_count; +} diff_patch_hunk; + +enum { + GIT_DIFF_PATCH_ALLOCATED = (1 << 0), + GIT_DIFF_PATCH_INITIALIZED = (1 << 1), + GIT_DIFF_PATCH_LOADED = (1 << 2), + GIT_DIFF_PATCH_DIFFABLE = (1 << 3), + GIT_DIFF_PATCH_DIFFED = (1 << 4), + GIT_DIFF_PATCH_FLATTENED = (1 << 5), +}; + +struct git_patch { + git_refcount rc; + git_diff *diff; /* for refcount purposes, maybe NULL for blob diffs */ + git_diff_options diff_opts; + git_diff_delta *delta; + size_t delta_index; + git_diff_file_content ofile; + git_diff_file_content nfile; + uint32_t flags; + git_diff_binary binary; + git_array_t(diff_patch_hunk) hunks; + git_array_t(git_diff_line) lines; + size_t content_size, context_size, header_size; + git_pool flattened; +}; + extern git_diff *git_patch__diff(git_patch *); extern git_diff_driver *git_patch__driver(git_patch *); @@ -23,6 +55,7 @@ extern void git_patch__new_data(char **, size_t *, git_patch *); extern int git_patch__invoke_callbacks( git_patch *patch, git_diff_file_cb file_cb, + git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb line_cb, void *payload); @@ -31,6 +64,7 @@ typedef struct git_diff_output git_diff_output; struct git_diff_output { /* these callbacks are issued with the diff data */ git_diff_file_cb file_cb; + git_diff_binary_cb binary_cb; git_diff_hunk_cb hunk_cb; git_diff_line_cb data_cb; void *payload; |
