diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-03-12 23:21:36 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-12 23:21:36 -0700 |
commit | 60f335b87f005c5f6c2eee1787eed9037b90c053 (patch) | |
tree | 05a41a0772006def96b8f0734c20afd0f2411116 /diff.c | |
parent | 6c621015f2b5028b8743da0b13293cc99fb2be6b (diff) | |
parent | 12426e114b252d130d83c3f098c4ceae3cf217e3 (diff) | |
download | git-60f335b87f005c5f6c2eee1787eed9037b90c053.tar.gz |
Merge branch 'jc/diff-populate-filespec-size-only-fix'
"git diff --quiet" relies on the size field in diff_filespec to be
correctly populated, but diff_populate_filespec() helper function
made an incorrect short-cut when asked only to populate the size
field for paths that need to go through convert_to_git() (e.g. CRLF
conversion).
* jc/diff-populate-filespec-size-only-fix:
diff: do not short-cut CHECK_SIZE_ONLY check in diff_populate_filespec()
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -2870,8 +2870,25 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags) s->should_free = 1; return 0; } - if (size_only) + + /* + * Even if the caller would be happy with getting + * only the size, we cannot return early at this + * point if the path requires us to run the content + * conversion. + */ + if (size_only && !would_convert_to_git(s->path)) return 0; + + /* + * Note: this check uses xsize_t(st.st_size) that may + * not be the true size of the blob after it goes + * through convert_to_git(). This may not strictly be + * correct, but the whole point of big_file_threshold + * and is_binary check being that we want to avoid + * opening the file and inspecting the contents, this + * is probably fine. + */ if ((flags & CHECK_BINARY) && s->size > big_file_threshold && s->is_binary == -1) { s->is_binary = 1; |