mirror of
https://git.proxmox.com/git/libgit2
synced 2025-07-09 17:49:27 +00:00
patch: don't print some headers on pure renames
This commit is contained in:
parent
82175084e1
commit
72806f4cca
@ -349,6 +349,8 @@ int git_diff_delta__format_file_header(
|
|||||||
const char *newpfx,
|
const char *newpfx,
|
||||||
int oid_strlen)
|
int oid_strlen)
|
||||||
{
|
{
|
||||||
|
bool skip_index;
|
||||||
|
|
||||||
if (!oldpfx)
|
if (!oldpfx)
|
||||||
oldpfx = DIFF_OLD_PREFIX_DEFAULT;
|
oldpfx = DIFF_OLD_PREFIX_DEFAULT;
|
||||||
if (!newpfx)
|
if (!newpfx)
|
||||||
@ -364,11 +366,18 @@ int git_diff_delta__format_file_header(
|
|||||||
if (delta->status == GIT_DELTA_RENAMED)
|
if (delta->status == GIT_DELTA_RENAMED)
|
||||||
GITERR_CHECK_ERROR(diff_delta_format_rename_header(out, delta));
|
GITERR_CHECK_ERROR(diff_delta_format_rename_header(out, delta));
|
||||||
|
|
||||||
|
skip_index = (delta->status == GIT_DELTA_RENAMED &&
|
||||||
|
delta->similarity == 100 &&
|
||||||
|
delta->old_file.mode == 0 &&
|
||||||
|
delta->new_file.mode == 0);
|
||||||
|
|
||||||
|
if (!skip_index) {
|
||||||
GITERR_CHECK_ERROR(diff_print_oid_range(out, delta, oid_strlen));
|
GITERR_CHECK_ERROR(diff_print_oid_range(out, delta, oid_strlen));
|
||||||
|
|
||||||
if ((delta->flags & GIT_DIFF_FLAG_BINARY) == 0)
|
if ((delta->flags & GIT_DIFF_FLAG_BINARY) == 0)
|
||||||
diff_delta_format_with_paths(
|
diff_delta_format_with_paths(
|
||||||
out, delta, oldpfx, newpfx, "--- %s%s\n+++ %s%s\n");
|
out, delta, oldpfx, newpfx, "--- %s%s\n+++ %s%s\n");
|
||||||
|
}
|
||||||
|
|
||||||
return git_buf_oom(out) ? -1 : 0;
|
return git_buf_oom(out) ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user