On Fri, 13 Jun 2014, Yue Lin Ho wrote:> 2014-06-12 23:39 GMT+08:00 Thomas Braun <thomas...@virtuell-zuhause.de>:
> > Am 12.06.2014 04:18, schrieb b873...@student.nsysu.edu.tw:
> > > I got a testing repository that it stores two blob of text file with
> > > mixed EOL.
> > > One is MIX-more_LF.txt -> all EOLs are LF, except EOL of line 2 is CRLF.
> > > The other on is MIX-more_CRLF.txt -> all EOLs are CRLF, except EOL of
> > > line 2 is LF.
> > > (Those files are commit under autocrlf = false)
> > > *The autocrlf is true. (set it to true)*
> > > *### Git for Windows ###*
> > > I use Git for Windows *1.9.2*.
> > > I delete those files, and run these command:
> > > $ git checkout HEAD -f -- "MIX-more_LF.txt"
> > > $ git checkout HEAD -f -- "MIX-more_CRLF.txt"
> > > I got those files back, and the EOLs of them are mixed EOLs as they are
> > > stored in repository.
> No, I have not.
> I never use Linux system.
> But I will try:
> (1) install Linux (using Virtual Box)
> (2) install git on Linux
> (3) push my testing repository to GitHub on Windows
> (4) pull my testing repository from GitHub on Linux
> (5) try the above git command on Linux
> (6) try to use some tool to check EOL on Linux
>
> right? ^_^
There's something even easier than that: Vagrant. It is essentially the
same you mentioned above, but much more convenient:
https://github.com/msysgit/msysgit/wiki/Vagrant
Ciao,
Johannes
2014-06-19 12:58 GMT+08:00 Torsten Bögershausen :Could you please raise this issue on the Git mailing list,
g...@vger.kernel.org <mailto:g...@vger.kernel.org>? It would be good
if you could accompany the report
with a *minimal* example showing the problem, and by stating
clearly what
is the behavior with libgit2-based software vs the behavior with
official
Git.
Thank you!
Johannes
Thank you~ ^_^
Sure. I mail to g...@vger.kernel.org <mailto:g...@vger.kernel.org>, but I didn't see it on http://git.661346.n2.nabble.com/
Sorry being late, I don't think there is something wrong with Git.
And the core.autocrlf is the "old" crlf handling, which has been in Git for a long time.
It may still be useful sometimes, if you exactly know what you are doing, know exactly
which tools are doing what, convince everybody who pulls or pushes to that repo to use
the same local config.
In short: I would strongly recommend to use gitattributes, please see below.
tb@msygit ~/temp
$ git clone https://github.com/YueLinHo/TestAutoCrlf.git
Cloning into 'TestAutoCrlf'...
[snip]
$ cd TestAutoCrlf/
tb@msygit ~/temp/TestAutoCrlf (master)
$ ls
CRLF.txt LF.txt MIX-more_CRLF.txt MIX-more_LF.txt Readme.md
###### Check how the file looks like:
$ od -c MIX-more_LF.txt
0000000 L i n e 1 \n l i n e ( 2 ) \r
0000020 \n l i n e 3 . \n t h i s i s
0000040 l i n e 4 \n l i n e
0000060 N o . 5 \n L i n e N u m b e
0000100 r 6 \n
0000104
####### The file has one CRLF, the rest is LF, exactly how it had been
####### commited. So this is what we expect.
####### Tell Git that the file is a text file:
$ echo MIX-more_LF.txt text >.gitattributes
####### Verify that MIX-more_LF.txt is text, all other files
####### are "binary" (or "-text" in Git language)
tb@msygit ~/temp/TestAutoCrlf (master)
$ git check-attr text *
CRLF.txt: text: unspecified
LF.txt: text: unspecified
MIX-more_CRLF.txt: text: unspecified
MIX-more_LF.txt: text: set
Readme.md: text: unspecified
####### Now ask Git to normalize the line endings in the working tree
$ rm MIX-more_LF.txt
tb@msygit ~/temp/TestAutoCrlf (master)
$ git checkout MIX-more_LF.txt
########## Check what we got:
tb@msygit ~/temp/TestAutoCrlf (master)
$ od -c MIX-more_LF.txt
0000000 L i n e 1 \r \n l i n e ( 2 )
0000020 \r \n l i n e 3 . \r \n t h i s
0000040 i s l i n e 4 \r \n l i n
0000060 e N o . 5 \r \n L i n e N
0000100 u m b e r 6 \r \n
0000111
######### (This is under Windows, under Linux I would expect only LF)
######### See core.eol for for information
##########
########## Now we need to normalize the file in the repo,
########## All line endings should be LF, otherwise Git
########## things the file is modified:
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: MIX-more_LF.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitattributes
no changes added to commit (use "git add" and/or "git commit -a")
###############
############### Do the normalization:
tb@msygit ~/temp/TestAutoCrlf (master)
$ git add MIX-more_LF.txt .gitattributes
tb@msygit ~/temp/TestAutoCrlf (master)
$ git commit -m "MIX-more_LF.txt is text"
[master 200d874] MIX-more_LF.txt is text
Committer: unknown <xxx@xxx>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email y...@example.com
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
2 files changed, 2 insertions(+), 1 deletion(-)
create mode 100644 .gitattributes
tb@msygit ~/temp/TestAutoCrlf (master)
$
######## From now on, MIX-more_LF.txt is treated as text by Git,
######## and get CRLF under Windows.
######## I think there is nothing wrong with Git here.
######## If libgit2 does something different, we need to ask
######## the libgit2 project, which is independent from Git