Skip to content

When adding files to repo.index with GitPython SublimeMerge is showing additional bytes in the diff #1513

@brupelo

Description

@brupelo

Hi,

consider this initial Working Directory in SublimeMerge:

image

If I run $ git add -- src/version.js I'd get this Staged Files diff

image

So far so good, the diff is correct... if we look at the hex content of that file:

image

you can see crlf bytes at the end.

Now, let's unstage that file and repeat the same operation but this time using GitPython commands, if we do:

$ python
Python 3.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 18:54:59) [MSC v.1929 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ["GIT_PYTHON_TRACE"] = "full"
>>> import logging
>>> logging.basicConfig(level=logging.INFO)
>>> import git
INFO:git.cmd:git version -> 0; stdout: 'git version 2.34.1.windows.1'
INFO:git.cmd:git version -> 0; stdout: 'git version 2.34.1.windows.1'
>>> repo = git.Repo(os.getcwd())
>>> reader = repo.config_reader()
>>> repo.index.add(['src\\version.js'])
[(100644, ac3cbe8dabe6dde800e2cec55763cacdcb88a918, 0, src/version.js)]
>>>

and we look now to SublimeMerge we'll see the diff of the Staged Files looks different now 🤨

image

What's the reason of this? I don't get it.

Could you please explain what'd be way to have the same behaviour than when doing $ git add -- src/version.js? Problem is
using this repo.index.add calls will create "wrong staged diffs".

Is this related with GitPython not being able to use the existing git config maybe?

Hope you can clarify :)

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions