diff options
author | nulltoken <emeric.fermas@gmail.com> | 2012-05-04 07:55:09 +0200 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2012-05-07 12:18:33 +0200 |
commit | 9a29f8d56c37803a67af3ff4bc4c8724a126366f (patch) | |
tree | b1001e3a2d24281dc489cfc16e3f108fb6e934d3 /src/diff_output.c | |
parent | 28ef7f9b28a8b58946e553090f8967d7c51ebc78 (diff) | |
download | libgit2-9a29f8d56c37803a67af3ff4bc4c8724a126366f.tar.gz |
diff: fix the diffing of two identical blobs
Diffstat (limited to 'src/diff_output.c')
-rw-r--r-- | src/diff_output.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/diff_output.c b/src/diff_output.c index dadbe284f..9c8e07972 100644 --- a/src/diff_output.c +++ b/src/diff_output.c @@ -747,6 +747,10 @@ int git_diff_blobs( delta.status = new ? (old ? GIT_DELTA_MODIFIED : GIT_DELTA_ADDED) : (old ? GIT_DELTA_DELETED : GIT_DELTA_UNTRACKED); + + if (git_oid_cmp(&delta.new_file.oid, &delta.old_file.oid) == 0) + delta.status = GIT_DELTA_UNMODIFIED; + delta.old_file.size = old_data.size; delta.new_file.size = new_data.size; @@ -762,6 +766,10 @@ int git_diff_blobs( return error; } + /* don't do hunk and line diffs if the two blobs are identical */ + if (delta.status == GIT_DELTA_UNMODIFIED) + return 0; + /* don't do hunk and line diffs if file is binary */ if (delta.binary == 1) return 0; |