git-archive and core.eol
- From
Erik Faye-Lund <kusmabite@gmail.com>
- Date
- Dec 15, 2010, 22:32 UTC
- Message-ID
- <AANLkTi=kfE88F7dY5F_xtbEuh9DyUcN+ymeXqLMWztGQ@mail.gmail.com>
I recently tried the following on Windows:
$ git init Initialized empty Git repository in c:/Users/kusma/test/.git/ $ echo "foo bar" > test.txt $ git -c core.autocrlf=true add test.txt warning: LF will be replaced by CRLF in test.txt. The file will have its original line endings in your working directory. $ git commit -m. 1 files changed, 2 insertions(+), 0 deletions(-) create mode 100644 test.txt $ git -c core.autocrlf=true -c core.eol=lf archive --format=tar HEAD > test.tar $ tar xvf test.tar $ od -c test.txt 0000000 f o o \r \n b a r \r \n 0000012
Just to be sure, I checked this:
$ git show HEAD:test.txt | od -c 0000000 f o o \n b a r \n 0000010
Yep, the file has LF in the repo, as expected... the warning from git-add is a bit confusing, but OK.
Hmm, so git-archive writes CRLF even if I said I wanted LF. But then I tried this on Linux:
$ git init Initialized empty Git repository in /home/kusma/src/test/.git/ $ echo "foo bar" > test.txt $ git add test.txt $ git commit -m. [master (root-commit) c6f195e] . 1 files changed, 2 insertions(+), 0 deletions(-) create mode 100644 test.txt $ git -c core.autocrlf=true -c core.eol=crlf archive --format=tar HEAD
> test.tar
$ tar xvf test.tar test.txt $ od -c test.txt 0000000 f o o \r \n b a r \r \n 0000012
This leaves me a bit puzzled. On Linux, I can override the default new-line style CRLF for git-archive, but I can't override it to LF on Windows?
I expected it to work because sha1_file_to_archive calls convert_to_working_tree. I've tried stepping through the code, but I don't quite understand where it goes wrong. Or even how the code is supposed to work :P
Does anyone have any clue what's going on? I'm running with the current master, git version 1.7.3.3.585.g74f6e.