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

Re: crlf with git-svn driving me nuts...

From
Dmitry Potapov <dpotapov@gmail.com>
Date
Apr 16, 2008, 20:01 UTC
Message-ID
<20080416200107.GG3133@dpotapov.dyndns.org>
In-Reply-To
<320075ff0804161210m46f3e83bpf7bf9d1d5816d914@mail.gmail.com>
On Wed, Apr 16, 2008 at 08:10:26PM +0100, Nigel Magnay wrote:
Show 9 quoted lines
> We've got projects with a mixed userbase of windows / *nix; I'm trying
> to migrate some users onto git, whilst everyone else stays happy in
> their SVN repo.
> 
> However, there's one issue that has been driving me slowly insane.
> This is best illustrated thusly (on windows) :
> 
>   $ git init
>   $ git config core.autocrlf false
core.autocrlf=false is a bad choice for Windows.
Show 6 quoted lines
> 
> -->Create a file with some text content on a few lines
>   $ notepad file.txt
> 
>   $ git add file.txt
>   $ git commit -m "initial checkin"

You added a file with the CRLF ending in the repository! You are going to have problems now...

Show 8 quoted lines
> 
>   $ git status
> # On branch master
> nothing to commit (working directory clean)
> --> Yarp, what I wanted
> 
>   $ git config core.autocrlf true
>   $ git status

You should not change core.autocrlf during your work, or you are going to have some funny problems. If you really need to change it, it should be followed by "git reset --hard".

In this case, you already have a file with the wrong ending, so file.txt will be shown as changed now, because if you commit it again then it will be commited with <LF>, which should have been done in the first place.

Show 31 quoted lines
> 
> # On branch master
> nothing to commit (working directory clean)
> --> Yarp, still all good
> 
> --> Simulate non-change happened by an editor opening file...
>   $ touch file.txt
>   $ git status
> # On branch master
> # Changed but not updated:
> #   (use "git add <file>..." to update what will be committed)
> #
> #       modified:   file.txt
> #
> no changes added to commit (use "git add" and/or "git commit -a")
> 
> --> Oh Noes! I wonder what it could be
>   $ git diff file.txt
> diff --git a/file.txt b/file.txt
> index 7a2051f..31ca3a0 100644
> --- a/file.txt
> +++ b/file.txt
> @@ -1,3 +1,3 @@
> -<xml>
> -       wooot
> -</xml>
> +<xml>
> +       wooot
> +</xml>
> 
> --> Huh? ...
Actually, it is
@@ -1,3 +1,3 @@
-<xml>^M
-       wooot^M
-</xml>^M
+<xml>
+       wooot
+</xml>

where ^M is <CR>

> 
> --> WtF?
> 
> Why does it think in this instance that there is a change? It's CRLF
> in the repo, it's CRLF in the working tree, and the checkout in either
> mode ought to be identical ??

If you do not want problems, you should use core.autocrlf=true
on Windows. Then all text files will be stored in the repository
with <LF>, but they will have <CR><LF> in your work tree.
Users on *nix should set core.autocrlf=input or false, so they
will have <LF> in their work tree.

Dmitry
Previous: Nigel MagnayNext: Avery Pennarun
Message 2 of 19 in “crlf with git-svn driving me nuts...”
  1. Nigel MagnayApr 16, 2008
  2. Dmitry PotapovApr 16, 2008
  3. Avery PennarunApr 16, 2008
  4. Dmitry PotapovApr 16, 2008
  5. Nigel MagnayApr 16, 2008
  6. Martin LanghoffApr 16, 2008
  7. Avery PennarunApr 16, 2008
  8. Dmitry PotapovApr 16, 2008
  9. Avery PennarunApr 16, 2008
  10. Nigel MagnayApr 16, 2008
  11. Dmitry PotapovApr 17, 2008
  12. Avery PennarunApr 17, 2008
  13. Nigel MagnayApr 17, 2008
  14. Dmitry PotapovApr 17, 2008
  15. Nigel MagnayApr 17, 2008
  16. Dmitry PotapovApr 17, 2008
  17. Nigel MagnayApr 17, 2008
  18. Dmitry PotapovApr 17, 2008
  19. Steffen ProhaskaApr 17, 2008

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.