Re: Surprising interaction of "binary" and "eol" gitattributes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/05/2015 11:08 PM, Junio C Hamano wrote:
Michael Haggerty <mhagger@xxxxxxxxxxxx> writes:

I would expect that the following .gitattributes file

     *       eol=crlf
     *.png   -text

would leave EOL translation turned off for PNG files. In other words, I
would expect that explicitly setting "-text" would take precedence over
the fact that setting "eol" implies that a file should be considered to
be "text".

I would even more strongly expect

     *       eol=crlf
     *.png   binary

to turn off EOL translation for PNG files.

But in fact, in both of the above cases, EOL translation is turned *on*
for PNG files.

I propose that "-text" should override any setting for "eol" (which
would of course fix both problems, since "binary" is equivalent to
"-diff -merge -text"). What do people think?
Hmm, is there really something that needs a new proposal and
opinions?

The way I read the flow in convert.c is:

     convert_to_git() uses input_crlf_action() to figure out what
     crlf_to_git() conversion is necessary.

     input_crlf_action() looks at text_attr and says CRLF_BINARY when
     it is CRLF_BINARY without looking at eol_attr at all.

     text_attr above is ca.crlf_action in convert_to_git().

     The whole ca.* comes from convert_attrs() inspecting attributes
     on the incoming path.

     convert_attrs() inspects "eol" and "text" attributes, among
     others, and sets crlf_action by calling git_path_check_crlf().

     git_path_check_crlf() looks at the 'text' attribute; if it is
     set to false, it returns CRLF_BINARY.

     crlf_to_git() when given crlf_action==CRLF_BINARY is a no-op.

So, with the above attributes where anything is eol=crlf by default
and in addition *.png is binary (which contains -text), we shouldn't
get any crlf munging.  Am I reading/following the code incorrectly?

Puzzled....
--

I need to admit that I can't reproduce it here,
the following should trigger it, but all test cases pass


diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh

index 452320d..22f031d 100755
--- a/t/t0027-auto-crlf.sh
+++ b/t/t0027-auto-crlf.sh
@@ -37,7 +37,8 @@ create_gitattributes () {
                echo "*.txt text" >.gitattributes
                ;;
                -text)
-               echo "*.txt -text" >.gitattributes
+               echo "* eol=crlf" >.gitattributes
+               echo "*.txt -text" >>.gitattributes
                ;;
                crlf)
                echo "*.txt eol=crlf" >.gitattributes

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]