All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Torsten Bögershausen" <tboegi@web.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: Vladimir Nikishkin <lockywolf@gmail.com>, git@vger.kernel.org
Subject: Re: core.safecrlf warning is confusing[improvement suggestion?]
Date: Wed, 22 Nov 2017 15:56:32 +0100	[thread overview]
Message-ID: <20171122145632.GA22931@tor.lan> (raw)
In-Reply-To: <xmqqine3xea5.fsf@gitster.mtv.corp.google.com>

On Wed, Nov 22, 2017 at 11:01:22AM +0900, Junio C Hamano wrote:
> Torsten Bögershausen <tboegi@web.de> writes:
> 
> >> I want to have LF line endings in the repository and CRLF endings in
> >> the working copy. (Because I use windows-exclusive tools to develop.)
> >
> > Side note: If you ever want to push your repository somewhere,
> > it would be good practice to have a .gitattributes file:
> > ...
> 
> Now we got your attention ;-)
> 
> What would be the BCP we would give if somebody has just a tarball
> without .git that has LF endings?
> 
>     $ git init a-project
>     $ cd a-project
>     $ tar xf ../a-project.tar
>     $ git add .
>     $ git commit -m 'Initial import'

There is room for small improvements:
     $ cd /tmp
     $ git init a-project
     $ cd a-project
     $ tar xf ../a-project.tar
     $ git -c core.autocrlf=false add .
     $ git commit -m 'Initial import'
     # Make up your mind: is it truly cross-platform ?
       $ echo "* text=auto" >.gitattributes
       # E.g. if you have shell scripts:
       $ echo "*.sh text eol=lf" >>.gitattributes
       # E.g. if you are a git developer:
       $ echo "/GIT-VERSION-GEN eol=lf" >>.gitattributes   
      # Or, is it e.g. a project where a tool needs some line endings
      # visual studio is one example, there are many others:
       $ echo "* -text" >.gitattributes
      # in any case, we need to commit: 
      $ git add .gitattributes && git commit -m "Add .gitattributes"

# Now we have the repo. I we don't want the hammer, simply clone it:
     $ cd $HOME
     $ git clone /tmp/a-project

That should work for project small enough not to fill the disk.
And other adjustments may be needed to the .gitattributes file.
A final check with
$ git ls-files --eol
may give inspiration.

> 
> would achieve one half of the original wish (i.e. "I want to end up
> with repository data in LF eol"); disabling the "safe crlf" before
> running that "git add ." step may also not be a bad idea, because it
> reduces the number of things that can get in the way by one.
> 
> But the above also leaves the "working tree" files in LF eol
> (i.e. it goes against "I want to work with CRLF in my working
> tree").  What would be our recommendation?
> 
> One big-hammer way I can think of is
> 
>     $ git rm -f .
>     $ git reset --hard
> 
> and that actually may be a good enough solution, given that you'd be
> doing this just once at the beginning of "your" project that starts
> from an inherited code drop.

      reply	other threads:[~2017-11-22 14:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21  5:18 core.safecrlf warning is confusing[improvement suggestion?] Vladimir Nikishkin
2017-11-21  5:44 ` Junio C Hamano
2017-11-21  5:49 ` Junio C Hamano
2017-11-21 16:18 ` Torsten Bögershausen
2017-11-22  2:01   ` Junio C Hamano
2017-11-22 14:56     ` Torsten Bögershausen [this message]

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=20171122145632.GA22931@tor.lan \
    --to=tboegi@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=lockywolf@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.