summaryrefslogtreecommitdiff
path: root/src/diff_output.c
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2013-04-09 15:15:18 -0700
committerVicent Martí <vicent@github.com>2013-04-09 15:15:18 -0700
commite9b7ff602b7f4b9a7de92eb241bc0578a520dda2 (patch)
treead5caff8bd3574a31040beaf1739f3ba3b6c8d9e /src/diff_output.c
parentfc12a6b545e26e673640288418202ac802a82a3f (diff)
parentad26434b3b8a5eafab8ec52b83aa99beaf48fb03 (diff)
downloadlibgit2-e9b7ff602b7f4b9a7de92eb241bc0578a520dda2.tar.gz
Merge pull request #1460 from arrbee/fix-dirty-submodules-diff
Submodule diff tests and fixes
Diffstat (limited to 'src/diff_output.c')
-rw-r--r--src/diff_output.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/diff_output.c b/src/diff_output.c
index e8dd5b317..34a3e506c 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -675,10 +675,14 @@ cleanup:
if (!error) {
patch->flags |= GIT_DIFF_PATCH_LOADED;
+ /* patch is diffable only for non-binary, modified files where at
+ * least one side has data and there is actual change in the data
+ */
if ((delta->flags & GIT_DIFF_FLAG_BINARY) == 0 &&
delta->status != GIT_DELTA_UNMODIFIED &&
(patch->old_data.len || patch->new_data.len) &&
- !git_oid_equal(&delta->old_file.oid, &delta->new_file.oid))
+ (patch->old_data.len != patch->new_data.len ||
+ !git_oid_equal(&delta->old_file.oid, &delta->new_file.oid)))
patch->flags |= GIT_DIFF_PATCH_DIFFABLE;
}
@@ -1149,7 +1153,11 @@ static int print_patch_file(
GIT_UNUSED(progress);
- if (S_ISDIR(delta->new_file.mode))
+ if (S_ISDIR(delta->new_file.mode) ||
+ delta->status == GIT_DELTA_UNMODIFIED ||
+ delta->status == GIT_DELTA_IGNORED ||
+ (delta->status == GIT_DELTA_UNTRACKED &&
+ (pi->diff->opts.flags & GIT_DIFF_INCLUDE_UNTRACKED_CONTENT) == 0))
return 0;
if (!oldpfx)