diff options
author | Junio C Hamano <gitster@pobox.com> | 2007-07-07 12:25:11 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-07-07 12:25:11 -0700 |
commit | 2c3fa66f3577d1305fb0fac5a181261fb2597859 (patch) | |
tree | 78b112202bbe518d5e9f2e8973674244a02fa593 /diff.c | |
parent | e0e324a4dc18a4341e1320a7cfac9733d81f8b0b (diff) | |
download | git-2c3fa66f3577d1305fb0fac5a181261fb2597859.tar.gz git-2c3fa66f3577d1305fb0fac5a181261fb2597859.tar.xz |
diff: honor binariness specified in attributes
The code shuffling mistakenly lost binariness specified with the
attribute mecahnism and made it always guess from the data.
Noticed by Johannes, with two test cases to t4020.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -1162,6 +1162,7 @@ static void setup_diff_attr_check(struct git_attr_check *check) static void diff_filespec_check_attr(struct diff_filespec *one) { struct git_attr_check attr_diff_check; + int check_from_data = 0; if (one->checked_attr) return; @@ -1179,6 +1180,8 @@ static void diff_filespec_check_attr(struct diff_filespec *one) ; else if (ATTR_FALSE(value)) one->is_binary = 1; + else + check_from_data = 1; /* funcname pattern ident */ if (ATTR_TRUE(value) || ATTR_FALSE(value) || ATTR_UNSET(value)) @@ -1187,12 +1190,13 @@ static void diff_filespec_check_attr(struct diff_filespec *one) one->funcname_pattern_ident = value; } - if (!one->data && DIFF_FILE_VALID(one)) - diff_populate_filespec(one, 0); - - if (one->data) - one->is_binary = buffer_is_binary(one->data, one->size); + if (check_from_data) { + if (!one->data && DIFF_FILE_VALID(one)) + diff_populate_filespec(one, 0); + if (one->data) + one->is_binary = buffer_is_binary(one->data, one->size); + } } int diff_filespec_is_binary(struct diff_filespec *one) |