Commit b921964b by Gregory Herrero

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>
parent accd7848
...@@ -1093,6 +1093,7 @@ typedef enum { ...@@ -1093,6 +1093,7 @@ typedef enum {
GIT_DIFF_FORMAT_RAW = 3u, /**< like git diff --raw */ GIT_DIFF_FORMAT_RAW = 3u, /**< like git diff --raw */
GIT_DIFF_FORMAT_NAME_ONLY = 4u, /**< like git diff --name-only */ 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_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; } git_diff_format_t;
/** /**
......
...@@ -571,7 +571,7 @@ static int diff_print_patch_file( ...@@ -571,7 +571,7 @@ static int diff_print_patch_file(
(pi->flags & GIT_DIFF_FORCE_BINARY); (pi->flags & GIT_DIFF_FORCE_BINARY);
bool show_binary = !!(pi->flags & GIT_DIFF_SHOW_BINARY); bool show_binary = !!(pi->flags & GIT_DIFF_SHOW_BINARY);
int id_strlen = pi->id_strlen; int id_strlen = pi->id_strlen;
bool print_index = true; bool print_index = (pi->format != GIT_DIFF_FORMAT_PATCH_ID);
if (binary && show_binary) if (binary && show_binary)
id_strlen = delta->old_file.id_abbrev ? delta->old_file.id_abbrev : id_strlen = delta->old_file.id_abbrev ? delta->old_file.id_abbrev :
...@@ -677,6 +677,11 @@ int git_diff_print( ...@@ -677,6 +677,11 @@ int git_diff_print(
print_hunk = diff_print_patch_hunk; print_hunk = diff_print_patch_hunk;
print_line = diff_print_patch_line; print_line = diff_print_patch_line;
break; 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: case GIT_DIFF_FORMAT_PATCH_HEADER:
print_file = diff_print_patch_file; print_file = diff_print_patch_file;
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment