mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-06 10:32:56 +00:00
patch printing: include rename information
This commit is contained in:
parent
d536ceacf5
commit
19e46645af
@ -322,6 +322,26 @@ static int diff_delta_format_with_paths(
|
|||||||
return git_buf_printf(out, template, oldpfx, oldpath, newpfx, newpath);
|
return git_buf_printf(out, template, oldpfx, oldpath, newpfx, newpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int diff_delta_format_rename_header(
|
||||||
|
git_buf *out,
|
||||||
|
const git_diff_delta *delta)
|
||||||
|
{
|
||||||
|
if (delta->similarity > 100) {
|
||||||
|
giterr_set(GITERR_PATCH, "invalid similarity %d", delta->similarity);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
git_buf_printf(out,
|
||||||
|
"similarity index %d%%\n"
|
||||||
|
"rename from %s\n"
|
||||||
|
"rename to %s\n",
|
||||||
|
delta->similarity,
|
||||||
|
delta->old_file.path,
|
||||||
|
delta->new_file.path);
|
||||||
|
|
||||||
|
return git_buf_oom(out) ? -1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
int git_diff_delta__format_file_header(
|
int git_diff_delta__format_file_header(
|
||||||
git_buf *out,
|
git_buf *out,
|
||||||
const git_diff_delta *delta,
|
const git_diff_delta *delta,
|
||||||
@ -341,6 +361,9 @@ int git_diff_delta__format_file_header(
|
|||||||
git_buf_printf(out, "diff --git %s%s %s%s\n",
|
git_buf_printf(out, "diff --git %s%s %s%s\n",
|
||||||
oldpfx, delta->old_file.path, newpfx, delta->new_file.path);
|
oldpfx, delta->old_file.path, newpfx, delta->new_file.path);
|
||||||
|
|
||||||
|
if (delta->status == GIT_DELTA_RENAMED)
|
||||||
|
GITERR_CHECK_ERROR(diff_delta_format_rename_header(out, delta));
|
||||||
|
|
||||||
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)
|
||||||
|
@ -306,7 +306,7 @@ static int parse_header_rename(
|
|||||||
static int parse_header_renamefrom(
|
static int parse_header_renamefrom(
|
||||||
git_patch_parsed *patch, patch_parse_ctx *ctx)
|
git_patch_parsed *patch, patch_parse_ctx *ctx)
|
||||||
{
|
{
|
||||||
patch->base.delta->status |= GIT_DELTA_RENAMED;
|
patch->base.delta->status = GIT_DELTA_RENAMED;
|
||||||
|
|
||||||
return parse_header_rename(
|
return parse_header_rename(
|
||||||
(char **)&patch->base.delta->old_file.path,
|
(char **)&patch->base.delta->old_file.path,
|
||||||
@ -317,7 +317,7 @@ static int parse_header_renamefrom(
|
|||||||
static int parse_header_renameto(
|
static int parse_header_renameto(
|
||||||
git_patch_parsed *patch, patch_parse_ctx *ctx)
|
git_patch_parsed *patch, patch_parse_ctx *ctx)
|
||||||
{
|
{
|
||||||
patch->base.delta->status |= GIT_DELTA_RENAMED;
|
patch->base.delta->status = GIT_DELTA_RENAMED;
|
||||||
|
|
||||||
return parse_header_rename(
|
return parse_header_rename(
|
||||||
(char **)&patch->base.delta->new_file.path,
|
(char **)&patch->base.delta->new_file.path,
|
||||||
|
Loading…
Reference in New Issue
Block a user