diff options
author | Edward Thomson <ethomson@github.com> | 2016-04-26 01:18:01 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@github.com> | 2016-06-25 23:08:30 -0400 |
commit | 1a79cd959ba2991dd3295f9940b28b606e494ccf (patch) | |
tree | e89b79913d4b3c8f95cb59858a227191e1d27bdf /src/patch_parse.c | |
parent | 9eb19381348bca66eedc4d2e541448443311007a (diff) | |
download | libgit2-1a79cd959ba2991dd3295f9940b28b606e494ccf.tar.gz |
patch: show copy information for identical copies
When showing copy information because we are duplicating contents,
for example, when performing a `diff --find-copies-harder -M100 -B100`,
then show copy from/to lines in a patch, and do not show context.
Ensure that we can also parse such patches.
Diffstat (limited to 'src/patch_parse.c')
-rw-r--r-- | src/patch_parse.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/patch_parse.c b/src/patch_parse.c index 72c4d148f..7f21e3f8e 100644 --- a/src/patch_parse.c +++ b/src/patch_parse.c @@ -310,6 +310,20 @@ static int parse_header_renameto( return parse_header_rename(&patch->rename_new_path, ctx); } +static int parse_header_copyfrom( + git_patch_parsed *patch, git_patch_parse_ctx *ctx) +{ + patch->base.delta->status = GIT_DELTA_COPIED; + return parse_header_rename(&patch->rename_old_path, ctx); +} + +static int parse_header_copyto( + git_patch_parsed *patch, git_patch_parse_ctx *ctx) +{ + patch->base.delta->status = GIT_DELTA_COPIED; + return parse_header_rename(&patch->rename_new_path, ctx); +} + static int parse_header_percent(uint16_t *out, git_patch_parse_ctx *ctx) { int32_t val; @@ -375,6 +389,8 @@ static const header_git_op header_git_ops[] = { { "rename to ", parse_header_renameto }, { "rename old ", parse_header_renamefrom }, { "rename new ", parse_header_renameto }, + { "copy from ", parse_header_copyfrom }, + { "copy to ", parse_header_copyto }, { "similarity index ", parse_header_similarity }, { "dissimilarity index ", parse_header_dissimilarity }, }; |