diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/diff.c | 6 | ||||
-rw-r--r-- | src/diff_output.c | 13 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/diff.c b/src/diff.c index 7152683e7..37c89f3f1 100644 --- a/src/diff.c +++ b/src/diff.c @@ -542,7 +542,11 @@ static int maybe_modified( unsigned int sm_status = 0; if (git_submodule_status(&sm_status, sub) < 0) return -1; - status = GIT_SUBMODULE_STATUS_IS_UNMODIFIED(sm_status) + + /* check IS_WD_UNMODIFIED because this case is only used + * when the new side of the diff is the working directory + */ + status = GIT_SUBMODULE_STATUS_IS_WD_UNMODIFIED(sm_status) ? GIT_DELTA_UNMODIFIED : GIT_DELTA_MODIFIED; /* grab OID while we are here */ diff --git a/src/diff_output.c b/src/diff_output.c index d462142f9..34a3e506c 100644 --- a/src/diff_output.c +++ b/src/diff_output.c @@ -675,11 +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) && - ((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; } @@ -1150,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) |