Skip to content

Copier changes CRLF to LF with jinja files on Windows #2041

Open
@kubotty

Description

@kubotty

Describe the problem

Hi,

I use Git on Windows with core.autocrlf set to true, which means line endings on my local machine are CRLF while those on the Git server are LF. However, when I use Copier to fill in variables in Jinja files, it retains the line endings as LF.

This results in significant differences being displayed for the entire Jinja file, even in sections where there are no actual changes post-Copier update. This behavior makes reviewing changes in Jinja files difficult, as the line ending changes obscure the real modifications.

Thank you!

Template

  1. On Windows, set the following in your .gitconfig:

    [core]
        autocrlf = true
  2. Clone my sample project from this repository.

  3. Run the Copier update command:

    copier update --defaults
  4. The app-template/sample-project/sample_module.py file should ideally show a diff of only one line, but due to the line ending differences, the entire file is displayed in the diff. For reference, I include app-template/sample-project/sample_module_new.py as an example of the expected result (achieved by configuring .gitattributes, but I would like to achieve this without such settings).

To Reproduce

No response

Logs

Expected behavior

I expect Copier to maintain the appropriate line endings for Jinja files by referencing the Git configuration.

Screenshots/screencasts/logs

No response

Operating system

Windows

Operating system distribution and version

Windows 11 Enterprize

Copier version

9.4.0

Python version

3.10.15

Installation method

pipx+pypi

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtriageTrying to make sure if this is valid or not

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions