diff options
author | Gregory Herrero <gregory.herrero@oracle.com> | 2019-11-07 13:08:51 +0100 |
---|---|---|
committer | Gregory Herrero <gregory.herrero@oracle.com> | 2019-11-19 09:33:12 +0100 |
commit | b921964b25c14c8dfeb26d1a5efedb28ee9e7284 (patch) | |
tree | 4951bf22e505d7921c975f1545e692243ecb7d7b | |
parent | accd78486523ef875a941ed65b02c56902074d76 (diff) | |
download | libgit2-b921964b25c14c8dfeb26d1a5efedb28ee9e7284.tar.gz |
diff_print: add support for GIT_DIFF_FORMAT_PATCH_ID.
Git is generating patch-id using a stripped down version of a patch
where hunk header and index information are not present.
Signed-off-by: Gregory Herrero <gregory.herrero@oracle.com>
-rw-r--r-- | include/git2/diff.h | 1 | ||||
-rw-r--r-- | src/diff_print.c | 7 |
2 files changed, 7 insertions, 1 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h index 73c5e55b9..89733a770 100644 --- a/include/git2/diff.h +++ b/include/git2/diff.h @@ -1093,6 +1093,7 @@ typedef enum { GIT_DIFF_FORMAT_RAW = 3u, /**< like git diff --raw */ GIT_DIFF_FORMAT_NAME_ONLY = 4u, /**< like git diff --name-only */ GIT_DIFF_FORMAT_NAME_STATUS = 5u, /**< like git diff --name-status */ + GIT_DIFF_FORMAT_PATCH_ID = 6u, /**< git diff as used by git patch-id */ } git_diff_format_t; /** diff --git a/src/diff_print.c b/src/diff_print.c index 4124bcb2e..369e5c1e6 100644 --- a/src/diff_print.c +++ b/src/diff_print.c @@ -571,7 +571,7 @@ static int diff_print_patch_file( (pi->flags & GIT_DIFF_FORCE_BINARY); bool show_binary = !!(pi->flags & GIT_DIFF_SHOW_BINARY); int id_strlen = pi->id_strlen; - bool print_index = true; + bool print_index = (pi->format != GIT_DIFF_FORMAT_PATCH_ID); if (binary && show_binary) id_strlen = delta->old_file.id_abbrev ? delta->old_file.id_abbrev : @@ -677,6 +677,11 @@ int git_diff_print( print_hunk = diff_print_patch_hunk; print_line = diff_print_patch_line; break; + case GIT_DIFF_FORMAT_PATCH_ID: + print_file = diff_print_patch_file; + print_binary = diff_print_patch_binary; + print_line = diff_print_patch_line; + break; case GIT_DIFF_FORMAT_PATCH_HEADER: print_file = diff_print_patch_file; break; |