git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Lars Hjemli" <hjemli@gmail.com>
To: "Edward Z. Yang" <edwardzyang@thewritingpot.com>
Cc: git@vger.kernel.org
Subject: Re: [Bug?] git submodule add doesn't respect core.autocrlf
Date: Thu, 26 Jun 2008 10:40:16 +0200	[thread overview]
Message-ID: <8c5c35580806260140g3133817ele6683d56699a9199@mail.gmail.com> (raw)
In-Reply-To: <g3vaaq$pm1$1@ger.gmane.org>

On Thu, Jun 26, 2008 at 7:43 AM, Edward Z. Yang
<edwardzyang@thewritingpot.com> wrote:
> mkdir test
> cd test
> git init
> git config core.safecrlf true
> git config core.autocrlf true

You can work around the problem by issuing the following commands at this point:

echo ".gitattributes -crlf" >> .gitattributes
echo ".gitmodules -crlf" >> .gitattributes
git add .gitattributes

> git submodule add http://repo.or.cz/w/htmlpurifier.git htmlpurifier
>
> You get: "fatal: LF would be replaced by CRLF in .gitmodules" and inspecting .gitmodules reveals that it uses LF, instead of CRLF.
>
> Can anyone reproduce? Thanks.

Yes, this also fails on linux (without the workaround).

To fix it "properly", git-config needs to choose between lf and crlf
(git-submodule uses git-config to write .gitmodules). But this depends
on
* whether the 'configfile' is (or will be!) tracked by git (e.g. .gitmodules)
* whether a crlf-attribute is specified for the 'configfile'
* the setting of core.autocrlf

A simpler solution might be to treat .gitmodules specially in
check_safe_crlf(), maybe something like this (possibly wrapped by
gmail...):

diff --git a/convert.c b/convert.c
index 1c66844..254a99b 100644
--- a/convert.c
+++ b/convert.c
@@ -91,6 +91,15 @@ static void check_safe_crlf(const char *path, int action,
        if (!checksafe)
                return;

+       /* Dirty hack: git-submodule uses git-config to update .gitmodules, and
+        * there's no reasonable way for git-config to know if the user prefers
+        * crlf or lf line endings for this file. And since it really doesn't
+        * matter, lets just ignore that the line endings might be modified by
+        * a later checkout.
+        */
+       if (!strcmp(path, ".gitmodules"))
+               return;
+
        if (action == CRLF_INPUT || auto_crlf <= 0) {
                /*
                 * CRLFs would not be restored by checkout:

--
larsh

  reply	other threads:[~2008-06-26  8:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-26  5:43 [Bug?] git submodule add doesn't respect core.autocrlf Edward Z. Yang
2008-06-26  8:40 ` Lars Hjemli [this message]
2008-06-26 11:58 ` [TEASER PATCH] write .gitmodules according to core.autocrlf Johannes Schindelin

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=8c5c35580806260140g3133817ele6683d56699a9199@mail.gmail.com \
    --to=hjemli@gmail.com \
    --cc=edwardzyang@thewritingpot.com \
    --cc=git@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).