From: Raja R Harinath <harinath@hurrynot.org>
To: git@vger.kernel.org
Cc: msysgit@googlegroups.com
Subject: Re: [msysGit] Re: Git for Windows and line endings
Date: Sun, 04 Nov 2012 18:07:53 +0530 [thread overview]
Message-ID: <878vahee72.fsf@hariville.hurrynot.org> (raw)
In-Reply-To: CADKp0pxuFsSEeZoeemyaqhSJEcsjj1arEOsF4Ub8=76y7tkwHg@mail.gmail.com
Hi,
Chris B <chris.blaszczynski@gmail.com> writes:
[snip]
> - Windows has been able to cope with UNIX line endings a long time; no
> developer is using a default Notepad to open files with high
> expectations. Any Windows development tool and editor worth anything
> I've used is able to handle both just fine.
> - VIM also handles Windows line endings just fine as well. I just
> tested it on a Linux machine. Maybe old version? (pure VI is not even
> on this machine but hard to press these days it can't handle it.)
> - The files in .git folder are in UNIX format anyway, so why are those
> not also included in line ending changes? Isn't is because there is a
> Windows app (msysgit) running on Windows that expects the UNIX line
> ending? So in the same manor, someone might have a Windows system
> using some Cygwin components perhaps, or a Windows C program possibly
> poorly written or just old, that demand some text files to be left
> alone in the format we saved it.
There are several subtleties in LF handling with mixed systems. Here's
my write-up in:
https://github.com/mono/mono/blob/master/.gitattributes
for an example set of trade-offs. Quoting in full since it's fairly short.
- Hari
# CRLF Handling
# -------------
#
# The ideal situation would be to do no EOL normalization. Each file
# would have a default EOL, and tools on Windows and Linux would handle
# both EOL formats.
#
# We're not in the ideal world. A popular editor on Windows (possibly
# Visual Studio) silently introduces EOL corruption -- it displays an
# LF-file normally, but any newly added lines have CRLF. On Linux,
# Emacs and versions of VI handle LF-files and CRLF-files properly.
# However, emacs doesn't like files with both LF and CRLF EOLs. Editing
# the file without additional action will increase the EOL corruption
# in the file.
#
# Another vector for mixed EOLs is scripts. We mostly don't have scripts
# that add new lines -- so we rarely see this. However, one major event
# in the tree was the addition of copyright headers using a script. That
# script introduced EOL corruption.
#
# Any automated EOL normalization of files already in the repository will
# cause difficulties in traversing histories, assigning blame, etc. So, we
# don't want to change what's in the repository significantly, even if it
# causes trouble.
#
# What we do now:
#
# a) we ensure that there's no further corruption of LF-files. So, we use
# git's 'crlf' attribute on those files to ensure that things are fine
# when we work on Windows. We could use 'crlf=input', but it doesn't buy
# us much -- we might as well be working with consistent EOLs for files in
# working directories as well as in the repository
#
# b) if the file already of CRLFs, we don't do any normalization. We use '-crlf'
# so that git doesn't do any EOL-conversion of the file. As I said, this
# is mostly harmless on Linux. We can't mark these files as 'crlf' or use
# the new (git 1.7.2) 'eol=crlf' attribute, since it changes the contents
# _inside_ the repository [1], and hence makes history traversal annoying.
# So, we live with occasional EOL corruption.
#
# c) We can handle mixed-EOL files on a case-by-case basis, converting them to
# LF- or CRLF-files based on which causes fewer lines to change
#
# d) We try to ensure no further headaches, by declaring EOL normalization on
# code files, and Unix-flavoured files, like shell-scripts, makefiles, etc.
#
# [1] GIT use LFs as the normalized internal representation.
prev parent reply other threads:[~2012-11-04 12:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-18 22:13 Git for Windows and line endings Chris B
2012-10-18 22:40 ` Erik Faye-Lund
2012-10-19 6:09 ` Johannes Schindelin
2012-10-19 14:39 ` [msysGit] " Chris B
2012-10-19 17:22 ` Junio C Hamano
2012-10-19 20:59 ` Jeff King
2012-10-19 21:53 ` [msysGit] " John Szakmeister
2012-11-04 12:37 ` Raja R Harinath [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
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=878vahee72.fsf@hariville.hurrynot.org \
--to=harinath@hurrynot.org \
--cc=git@vger.kernel.org \
--cc=msysgit@googlegroups.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.
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).