From: Michael Haggerty <mhagger@alum.mit.edu>
To: "Torsten Bögershausen" <tboegi@web.de>,
"Junio C Hamano" <gitster@pobox.com>
Cc: git discussion list <git@vger.kernel.org>
Subject: Re: Surprising interaction of "binary" and "eol" gitattributes
Date: Fri, 06 Mar 2015 18:51:03 +0100 [thread overview]
Message-ID: <54F9E907.4040703@alum.mit.edu> (raw)
In-Reply-To: <54F9422D.2020800@web.de>
On 03/06/2015 06:59 AM, Torsten Bögershausen wrote:
> On 03/05/2015 11:08 PM, Junio C Hamano wrote:
>> Michael Haggerty <mhagger@alum.mit.edu> 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
>
Oops, I misunderstood an internal bug report. In seems that it is the
following scenario that is incorrect:
*.png text=auto eol=crlf
when applied to a binary file.
I'm currently studying documentation and writing tests to figure out the
exact current behavior. But honestly, this end-of-line conversion stuff
is bewildering, so it might take a while.
Sorry for the half-cocked bug report. I'll report back when I know more.
Michael
--
Michael Haggerty
mhagger@alum.mit.edu
next prev parent reply other threads:[~2015-03-06 17:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-05 16:38 Surprising interaction of "binary" and "eol" gitattributes Michael Haggerty
2015-03-05 20:49 ` Torsten Bögershausen
2015-03-05 22:08 ` Junio C Hamano
2015-03-06 5:59 ` Torsten Bögershausen
2015-03-06 17:51 ` Michael Haggerty [this message]
2015-03-06 21:30 ` Torsten Bögershausen
2015-03-10 19:25 ` Michael Haggerty
2015-03-10 20:01 ` Junio C Hamano
2015-03-10 22:16 ` Michael Haggerty
2015-03-10 22:54 ` Junio C Hamano
2015-03-11 5:54 ` Torsten Bögershausen
2015-03-11 17:59 ` Junio C Hamano
2015-03-11 20:30 ` Johannes Sixt
2015-03-11 21:31 ` Junio C Hamano
2015-03-11 21:43 ` Junio C Hamano
2015-03-10 20:26 ` Torsten Bögershausen
2015-03-10 22:24 ` Michael Haggerty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54F9E907.4040703@alum.mit.edu \
--to=mhagger@alum.mit.edu \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=tboegi@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).