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

Changing encoding of a file : What should happen to CRLF in file ?

From
ANAshish Negi <ashishnegi33@gmail.com>
Date
Nov 14, 2017, 12:31 UTC
Message-ID
<CAJ_+vJ6FXXda4fe7=1YxtDGR2d8CqP4KXN+YR6+mdQ+5jQQXug@mail.gmail.com>
Hello

I have a cross platform project. I have a utf-16 file in it. I changed its encoding to urf-8 and committed. When i pulled the file in Linux, it shows that file is modified. This means that the commit which changed the encoding does not convert crlf to lf, when new format is text based (utf-8).

Steps to reproduce:
   In windows :
    Change encoding of file from utf-16 to utf-8.
    Commit the change.
   In linux:
    Pull your branch.
    You will see the issue of file being shown as modified even though
you have not used it.

If i change the file encoding in linux and commit. Then if i do git pull in windows, i don't see the issue. In linux, during committing i get warning : warning: CRLF will be replaced by LF in …file_name..

Here are my configuration :
> git config --global --get core.autocrlf
false
> git config  --get core.autocrlf
false
> cat E:\work\WindowsFabric\.gitattributes
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
*.vcxproj eol=crlf
*.sh      eol=lf

# Denote all files that are truly binary and should not be modified. *.exe binary *.dll binary *.pdb binary *.ico binary *.png binary *.jpg binary

> git --version
git version 2.14.2.windows.2

I played around with core.autocrlf values like true and native, but that didn't help.

The behavior is inconsistent across platforms, and windows version is giving me problem.

Can someone suggest right settings for this ? Or is this a bug in Git.
Thanks
Next: Torsten Bögershausen
Message 1 of 23 in “Changing encoding of a file : What should happen to CRLF in file ?”
  1. Ashish NegiNov 14, 2017
  2. Torsten BögershausenNov 14, 2017
  3. Ashish NegiNov 14, 2017
  4. Ashish NegiNov 14, 2017
  5. Torsten BögershausenNov 14, 2017
  6. Ashish NegiNov 15, 2017
  7. Torsten BögershausenNov 15, 2017
  8. Ashish NegiNov 15, 2017
  9. Torsten BögershausenNov 16, 2017
  10. Ashish NegiNov 23, 2017
  11. Torsten BögershausenNov 23, 2017
  12. Ashish NegiNov 24, 2017
  13. Torsten BögershausenNov 14, 2017
  14. 1/1 convert: tighten the safe autocrlf handlingtboegi@web.de, Nov 24, 2017
  15. Eric SunshineNov 24, 2017
  16. Torsten BögershausenNov 24, 2017
  17. Junio C HamanoNov 25, 2017
  18. 1/1 convert: tighten the safe autocrlf handlingtboegi@web.de, Nov 26, 2017
  19. 1/2 t0027: Don't use git commit <empty-pathspec>tboegi@web.de, Dec 8, 2017
  20. Junio C HamanoDec 8, 2017
  21. Junio C HamanoDec 8, 2017
  22. Torsten BögershausenDec 8, 2017
  23. 2/2 t0027: Adapt the new MIX tests to Windowstboegi@web.de, Dec 8, 2017

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.