git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.

Next: René Scharfe
Message 1 of 7 in “git-archive and core.eol”
  1. Erik Faye-LundDec 15, 2010
  2. René ScharfeJan 8, 2011
  3. Erik Faye-LundJan 8, 2011
  4. René ScharfeJan 9, 2011
  5. Erik Faye-LundJan 10, 2011
  6. Erik Faye-LundJan 10, 2011
  7. René ScharfeJan 11, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.