Skip to content

Line-ending rules for nested repos do not work when the nested repo has its own .gitattributes, and repeat on each pull #231

Open

Description

@olfway

I also tested the line-ending fix from #225 (1.2.2) on my tdesktop fork.

It works for a nested repo without its own .gitattributes.
It does not work, or it adds unnecessary rules, when the nested repo has one.

Version: git-nested 1.2.2, git 2.56.1, macOS, core.autocrlf unset.

Setup: a fork of tdesktop at bf4f714.
Its root .gitattributes has * text=auto and *.bat text eol=crlf.
My fork also has Telegram/ThirdParty/** -text -eol.
I cloned three repos next to their nested copies, so the same parent rules apply:

git nested clone -b c87183a77d67f7d37e3d2d1b7eaac5e7c695e4f0 https://github.com/Cyan4973/xxHash.git Telegram/ThirdParty/xxHash-test
git nested clone -b 42a0e5dd634e638de7115e5a4cfcdd72786853a3 https://github.com/desktop-app/lib_base.git Telegram/lib_base_test
git nested clone -b 95b9cb015fa17baa749c2b396b335906e1596a9e https://github.com/martinmoene/expected-lite.git cmake/external/glib/cppgir/expected-lite-test

Each clone added -text rules for its .bat files.
I compared the result with a plain checkout of the same commit, as a submodule would have it:

Nested repo Its own .gitattributes Plain checkout After the clone Result
lib_base none LF LF correct
expected-lite * text=auto LF CRLF wrong: 9 rules, no effect
xxHash *.bat text eol=crlf CRLF CRLF correct, but 5 rules that are not necessary

1. -text has no effect when the nested repo sets text itself. A deeper .gitattributes wins, so expected-lite's * text=auto overrides the root -text. The root's eol=crlf still applies, so the files stay CRLF. -text -eol works: git check-attr then gives text: auto, eol: unset, and the files are LF.

2. Rules for files that are already correct. xxHash's own *.bat text eol=crlf writes these files with CRLF, the same as in a plain checkout. git-nested still adds -text rules for them.

3. The rules repeat on each pull that changes the repo. The next pull of xxHash-test (pull --force -b 2ec67caeb18ec15ae60c0853174331089acddfc0) added the same 5 lines again, in a new "keep ... files as upstream has them" commit. Now .gitattributes has 10 lines for 5 files. The files still match their rules, so each pull finds them again.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions