Git development
 help / color / mirror / Atom feed
From: Hannu Koivisto <azure@iki.fi>
To: git@vger.kernel.org
Cc: Jeff King <peff@peff.net>
Subject: CRLF support bugs (was: Re: .gitattributes glob matching broken)
Date: Mon, 03 Nov 2008 17:05:24 +0200	[thread overview]
Message-ID: <83y700alzf.fsf_-_@kalahari.s2.org> (raw)
In-Reply-To: 20081103090932.GA18424@coredump.intra.peff.net

Jeff King <peff@peff.net> writes:

> I think your analysis is incorrect. I will try to explain what is
> happening.

Yes, you are right.  The behaviour I saw in my actual use case was
so odd that I got completely confused.

I suspect one part of that "oddness" was caused by git applying its
heuristics in checkout as it doesn't use .gitattributes at that
time.  For example, it seems that it recognized some of my .sh
files as text files and the rest as binary files.  I suppose I was
correct to assume that it would be stupid to rely on git guessing
file type and the only sensible way is to use .gitattributes.  If
it was supported in checkout too, that is.

I don't know what purpose the autodetection aims to serve but I'd
add a big warning in the core.autocrlf documentation about it and
instructions on how to configure things so that it is never applied
but instead the types must always be specified explicitly.

> The problem, again, is that we have inconsistently applied the
> gitattributes. They were _not_ applied during checkout (because
> .gitattributes did not exist yet), but they _are_ being applied here.
>
> To "fix" this, you can then do a "git reset --hard" which will respect
> your .gitattributes (since it is now checked out). And further file
> creation and checkout should work OK.

Since I'm trying to launch git in a company environment, I think I
can't rely on people remembering to do that.

Actually, even if .gitattributes were applied in checkout, I think
the whole CRLF support is broken by design because people will have
to remember to use -n in clone, then enable core.autocrlf support
and then checkout.  This makes it unneccessarily complicated to
create "quick local clones" as well.  You might suggest that
Windows users should enable core.autocrlf globally but it may not
be the right thing to do for all projects/repositories either.

I think CRLF conversion support should have some attribute (be it
.gitattributes attribute or something else) that is somehow
inherited from the parent repository.  It would basically say that
"you should use platform's native line end type for text files with
this repository and its children".  To go with that, one would
maybe have a configuration option to tell what that platform
default line end type is (just in case someone wants to pretend
Cygwin is Unix or something like that).

I also observed this problem:

# Pretend someone does this on Unix
mkdir test1
cd test1
git init
echo "*.c crlf" > .gitattributes
echo -en "foo\r\nfoo\r\nfoo\r\n" > kala.c
git add .gitattributes kala.c
git commit -m "* Initial checkin."
cd ..
# Pretend someone else does this on Windows
git clone -n test1 test2
cd test2
git config core.autocrlf true
git checkout
git status

...
#       modified:   kala.c
...

git reset --hard
git status
...
#       modified:   kala.c
...

Now, even if .gitattributes were obeyed by checkout, I suspect the end
result would be the same(?)  I'm sure someone argues that this makes
sense.  But try to put yourself in the position of a random Window
user.  I think it's far from obvious what is going on and what
should be done in this situation.

-- 
Hannu

  reply	other threads:[~2008-11-03 15:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-02 16:33 .gitattributes glob matching broken Hannu Koivisto
2008-11-03  9:09 ` Jeff King
2008-11-03 15:05   ` Hannu Koivisto [this message]
2008-11-03 15:25     ` CRLF support bugs Hannu Koivisto
2008-11-03 16:46     ` CRLF support bugs (was: Re: .gitattributes glob matching broken) Dmitry Potapov
2008-11-03 22:24       ` CRLF support bugs Hannu Koivisto
2008-11-04  5:14     ` CRLF support bugs (was: Re: .gitattributes glob matching broken) Jeff King
2008-11-04 12:37       ` CRLF support bugs (was: Re: .gitattributes glob matchingbroken) Kelly F. Hickel
2008-11-05  3:07         ` Jeff King

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83y700alzf.fsf_-_@kalahari.s2.org \
    --to=azure@iki.fi \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox