mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 06:20:56 +00:00
patch: zero id and abbrev length for empty files
This commit is contained in:
parent
33ae876239
commit
853e585fb1
@ -933,20 +933,32 @@ static int check_filenames(git_patch_parsed *patch)
|
|||||||
|
|
||||||
static int check_patch(git_patch_parsed *patch)
|
static int check_patch(git_patch_parsed *patch)
|
||||||
{
|
{
|
||||||
|
git_diff_delta *delta = patch->base.delta;
|
||||||
|
|
||||||
if (check_filenames(patch) < 0)
|
if (check_filenames(patch) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (patch->base.delta->old_file.path &&
|
if (delta->old_file.path &&
|
||||||
patch->base.delta->status != GIT_DELTA_DELETED &&
|
delta->status != GIT_DELTA_DELETED &&
|
||||||
!patch->base.delta->new_file.mode)
|
!delta->new_file.mode)
|
||||||
patch->base.delta->new_file.mode = patch->base.delta->old_file.mode;
|
delta->new_file.mode = delta->old_file.mode;
|
||||||
|
|
||||||
if (patch->base.delta->status == GIT_DELTA_MODIFIED &&
|
if (delta->status == GIT_DELTA_MODIFIED &&
|
||||||
!(patch->base.delta->flags & GIT_DIFF_FLAG_BINARY) &&
|
!(delta->flags & GIT_DIFF_FLAG_BINARY) &&
|
||||||
patch->base.delta->new_file.mode == patch->base.delta->old_file.mode &&
|
delta->new_file.mode == delta->old_file.mode &&
|
||||||
git_array_size(patch->base.hunks) == 0)
|
git_array_size(patch->base.hunks) == 0)
|
||||||
return parse_err("patch with no hunks");
|
return parse_err("patch with no hunks");
|
||||||
|
|
||||||
|
if (delta->status == GIT_DELTA_ADDED) {
|
||||||
|
memset(&delta->old_file.id, 0x0, sizeof(git_oid));
|
||||||
|
delta->old_file.id_abbrev = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delta->status == GIT_DELTA_DELETED) {
|
||||||
|
memset(&delta->new_file.id, 0x0, sizeof(git_oid));
|
||||||
|
delta->new_file.id_abbrev = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user