diff options
author | nulltoken <emeric.fermas@gmail.com> | 2012-04-25 22:23:35 +0200 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-04-25 15:37:17 -0700 |
commit | eb3d71a5bcd78cb4840e62194e8998141508af88 (patch) | |
tree | 6121c4a4dae045c693f47a3ca8fbe5355221b2a6 /src/diff_output.c | |
parent | 3fc5c65d1a072fc727226cd66a1b096df4919da5 (diff) | |
download | libgit2-eb3d71a5bcd78cb4840e62194e8998141508af88.tar.gz |
diff: fix generation of the header of a removal patch
Diffstat (limited to 'src/diff_output.c')
-rw-r--r-- | src/diff_output.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/diff_output.c b/src/diff_output.c index f4c214314..7c5b6f276 100644 --- a/src/diff_output.c +++ b/src/diff_output.c @@ -553,9 +553,16 @@ static int print_patch_file(void *data, git_diff_delta *delta, float progress) const char *oldpath = delta->old.path; const char *newpfx = pi->diff->opts.dst_prefix; const char *newpath = delta->new.path; + int result; GIT_UNUSED(progress); + if (!oldpfx) + oldpfx = DIFF_SRC_PREFIX_DEFAULT; + + if (!newpfx) + newpfx = DIFF_DST_PREFIX_DEFAULT; + git_buf_clear(pi->buf); git_buf_printf(pi->buf, "diff --git %s%s %s%s\n", oldpfx, delta->old.path, newpfx, delta->new.path); @@ -567,8 +574,8 @@ static int print_patch_file(void *data, git_diff_delta *delta, float progress) oldpath = "/dev/null"; } if (git_oid_iszero(&delta->new.oid)) { - oldpfx = ""; - oldpath = "/dev/null"; + newpfx = ""; + newpath = "/dev/null"; } if (delta->binary != 1) { @@ -579,9 +586,12 @@ static int print_patch_file(void *data, git_diff_delta *delta, float progress) if (git_buf_oom(pi->buf)) return -1; - if (pi->print_cb(pi->cb_data, GIT_DIFF_LINE_FILE_HDR, pi->buf->ptr) < 0 || - delta->binary != 1) - return -1; + result = pi->print_cb(pi->cb_data, GIT_DIFF_LINE_FILE_HDR, pi->buf->ptr); + if (result < 0) + return result; + + if (delta->binary != 1) + return 0; git_buf_clear(pi->buf); git_buf_printf( |