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

Re: Inconsistent handling of corrupt patches based on line endings

From
Torsten Bögershausen <tboegi@web.de>
Date
Oct 29, 2024, 16:32 UTC
Message-ID
<20241029163218.GA30259@tb-raspi4>
In-Reply-To
<CAExmRTbMCayh+vHW3g=2p=FMb=VKXomEbn7_0t+kK-eF79JnEA@mail.gmail.com>
On Mon, Oct 28, 2024 at 05:57:54PM +0100, Peregi Tamás wrote:
> Hi all,
[]

Thanks for an extensive bug (?) report. I can not answer, if this a bug or working as designed.

However, please allow a few words:
>
> While the example seems contrived, it has been encountered in the wild when
> I was copying a port from https://github.com/microsoft/vcpkg (set up with
> autocrlf=false and all files treated as binaries in .gitattributes) to my
[]

That very repo is not in a shape I would like to see it. Basically, Git is designed to work with line endings using LF and nothing else. You can configure Git to see CRLF in the working tree, if needed. But all the diff machinery, and git-apply, is build on this assumption.

If I look into the repo, this very commit
===========================
    commit ebdb41039450383ec7f41bd5f589cc46b7fd6a59
    Author: ...
    Date:   Mon Feb 26 18:18:05 2018 -0800
        [everything] Use -text to ensure consistent files across machines.
        If you experience trouble, you can use the following to renormalize your local working directory:
        git add --renormalize .
        git reset .
        git checkout .
===========================
is probably made with good intentions.
However, `git add --renormalize .` will not do anything at all.
All files are marked as "-text", so there is nothing to normalize.
The commit message here is simply wrong.
Something like this would have made more sense:
===========================
* text=auto eol=crlf

# Declare files that will always have LF line endings on checkout. *.patch text eol=lf scripts/ci.baseline.txt text eol=lf

ports/** -linguist-detectable =========================== (But I didn't check each and every file).

After changing the .gitattributes file, run git add --renormalize . git add . warning: in the working copy of 'crlf', LF will be replaced by CRLF the next time Git touches it git commit -m "all files with LF in the repo"

git ls-files | xargs rm git checkout .gitattributes git checkout .

After this, we can fine-tune: git ls-files --eol | egrep -v "json|cmake|patch" shows that we can add lines like *.exe binary and may be scripts/vcpkg_completion* text eol=lf to .gitattributes

Does this makes sense ?
Previous: Junio C Hamano
Message 6 of 6 in “Inconsistent handling of corrupt patches based on line endings”
  1. Peregi TamásOct 28, 2024
  2. Taylor BlauOct 28, 2024
  3. Elijah NewrenOct 28, 2024
  4. René ScharfeOct 28, 2024
  5. Junio C HamanoOct 28, 2024
  6. Torsten BögershausenOct 29, 2024

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.