Re: Inconsistent handling of corrupt patches based on line endings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 ?






[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux