Re: [PATCH 2/2] submodule: Tolerate auto/safecrlf when adding .gitmodules

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

 



On Wed, Jun 20, 2012 at 02:06:43PM -0400, Brad King wrote:

> > Hmm, I have no objections against the intention of the patch. But
> > as I understand it this message will reoccur when the user e.g.
> > edits the .gitmodules file later with any editor who just writes
> > lfs and adds it.
> > 
> > I don't know terribly much about crlf support but maybe flagging
> > the .gitmodules file in .gitattributes would be a better solution
> > here? Opinions?
> 
> Once a user edits the file with an outside tool it is his/her
> responsibility to add .gitattributes for the file.  In the reported
> case Git is creating the file and already knows the crlf mode when
> creating it.
> 
> I think Junio's proposal to teach "git config" to respect crlf
> configuration is a more general solution.

I don't think so. It should not be an issue at all that .gitmodules has
CRLF or even mixed line endings; the config parser knows that its input
is a text file and ignores the CRs already.

The only problem is when adding the file, because git is not aware that
.gitmodules is, by definition, a text file.  The point of safecrlf was
to prevent accidents with files which are really binary, or for which
mixed line endings must be preserved; .gitmodules is not such a file. We
know that, but we never tell git.

We can paper over the problem by normalizing line endings when config
writes it out, but that does not cover the case of somebody editing it
manually and introducing mixed line endings. Nor does it help if
somebody checks in a .gitmodules file with CRLF, which we then checkout
on a LF-based system. Or if we do a merge between two versions with
different line endings.

The only sane thing is to have a canonical in-repo representation.
Fortunately we already have the infrastructure for that, and in theory
it should be as easy as adding ".gitmodules text" to our built-in
gitattributes (you could even do "eol=lf", but I don't see a reason not
to respect the native line endings in the working tree, given that git
can handle the CRLFs just fine).

I say "in theory" there because I am not sure whether specifying a file
as definitely text via attributes will actually suppress the safecrlf
check or not. IMHO, it should, since safecrlf is really about preventing
false positives via autocrlf or text=auto.

I don't see any reason for each individual repo to have to add these
attributes manually. This is a git-specific file, and the format is
dictated by git. We know that it's a text file, so why not help out the
user? We should possibly do the same thing for .gitattributes and
.gitignore.

-Peff
--
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]