summaryrefslogtreecommitdiff
path: root/src/diff_print.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2020-04-01 20:00:24 +0100
committerGitHub <noreply@github.com>2020-04-01 20:00:24 +0100
commit1c7fb21246629d6d5c7dd5d6eaf646339c57ab1c (patch)
treeba9735a961dad142814692add6c56d55be789a06 /src/diff_print.c
parent85533f374b80b03a098e27123cc5f01a6cccb989 (diff)
parent5f47cb48d388279f92d339a5a791040254ee4d1c (diff)
downloadlibgit2-1c7fb21246629d6d5c7dd5d6eaf646339c57ab1c.tar.gz
Merge pull request #5466 from pks-t/pks/patch-modechange-with-rename
patch: correctly handle mode changes for renames
Diffstat (limited to 'src/diff_print.c')
-rw-r--r--src/diff_print.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/diff_print.c b/src/diff_print.c
index 369e5c1e6..a78953c32 100644
--- a/src/diff_print.c
+++ b/src/diff_print.c
@@ -359,9 +359,9 @@ int diff_delta_format_similarity_header(
abort();
if ((error = git_buf_puts(&old_path, delta->old_file.path)) < 0 ||
- (error = git_buf_puts(&new_path, delta->new_file.path)) < 0 ||
- (error = git_buf_quote(&old_path)) < 0 ||
- (error = git_buf_quote(&new_path)) < 0)
+ (error = git_buf_puts(&new_path, delta->new_file.path)) < 0 ||
+ (error = git_buf_quote(&old_path)) < 0 ||
+ (error = git_buf_quote(&new_path)) < 0)
goto done;
git_buf_printf(out,
@@ -428,8 +428,11 @@ int git_diff_delta__format_file_header(
git_buf_printf(out, "diff --git %s %s\n",
old_path.ptr, new_path.ptr);
+ if (unchanged && delta->old_file.mode != delta->new_file.mode)
+ diff_print_modes(out, delta);
+
if (delta->status == GIT_DELTA_RENAMED ||
- (delta->status == GIT_DELTA_COPIED && unchanged)) {
+ (delta->status == GIT_DELTA_COPIED && unchanged)) {
if ((error = diff_delta_format_similarity_header(out, delta)) < 0)
goto done;
}
@@ -444,9 +447,6 @@ int git_diff_delta__format_file_header(
"--- %s\n+++ %s\n", old_path.ptr, new_path.ptr);
}
- if (unchanged && delta->old_file.mode != delta->new_file.mode)
- diff_print_modes(out, delta);
-
if (git_buf_oom(out))
error = -1;