Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random files marked as modified #381

Closed
atomtigerzoo opened this issue Mar 6, 2017 · 16 comments
Closed

Random files marked as modified #381

atomtigerzoo opened this issue Mar 6, 2017 · 16 comments
Assignees
Labels

Comments

@atomtigerzoo
Copy link

I used GitGutter without any problems until today's automatic update to the latest version.

Now Git Gutter marks all lines in random files as modified (yellow) and I cannot reproduce why. I tried removing the package, updated git on my system - still marking whole files as modified. I have the problem in multiple projects. When I use git on the command line nothing is modified, branch is clean, still Git Gutter shows modifications.

I am using ST3 with the latest GitGutter installed with Package Control.

@sbalgas
Copy link

sbalgas commented Mar 6, 2017

Hi, I have the same problem now.
I tried changing the Line Endings, Unix, Windows and Mac and it does not work.
I also tried with git reset.

I am using ST3 3126.

@paranat
Copy link

paranat commented Mar 6, 2017

Having a similar problem with 1.5.0 where all lines of files are marked with red.

Running on Linux ST3 3126.

@r-stein r-stein added the bug label Mar 6, 2017
@deathaxe
Copy link
Collaborator

deathaxe commented Mar 6, 2017

This issue may most likely be caused by different line endings of the working file and its copy in the git repository. GitGutter uses git archive command to read the file from repository, which should do correct translations but this seems not to work in your case.

To check whether this is the reason, please try the following:

  1. Open command pallet

  2. Type: Preferences: GitGutter Settings

  3. Add the following entry to the GitGutter.sublime-settings

    "ignore_whitespace": "eol",

This will call git diff with --ignore-space-at-eol switch.

@paranat
Copy link

paranat commented Mar 6, 2017

Yep, this seems to be the case for me. Using that setting gets rid of the incorrect change markings.

@deathaxe
Copy link
Collaborator

deathaxe commented Mar 6, 2017

I am not quite sure if --ignore-space-at-eol ignores \r\n <-> \n differences only. I guess it also ignores tabs and spaces.

That's why I created a PR which might solve the issue even with "ignore_whitespace": "none",.

@sbalgas
Copy link

sbalgas commented Mar 6, 2017

Hi, I put "ignore_whitespace": "eol", in my GitGutter Settings and I have the same problem.
But, when I change the EOL in the SublimeText, my smartgit and git status shows me this change.

EOL changed
image

Without changes
image

Only works when I put EOL: Unix

Regards

@alecive
Copy link

alecive commented Mar 6, 2017

@deathaxe ignore_whitespace fixed the issue to me, but why this issue appeared only now in the first place? Also, I am not quite sure if there is a difference in end-of-lines in my repositories at all (at least, not that I'm aware of).

deathaxe added a commit that referenced this issue Mar 6, 2017
Issue:

With introducing `git archive` command it was considered save to remove the
eol mangling as correct translations should happen by this command.

This seems not to apply sometimes.

Solution:

Reintroduce eol mangling for the files read from repository.

Note:

As the temporary view file is created from text, it should be written to disk
with `\n` and thus shouldn't need mangling.
@deathaxe
Copy link
Collaborator

deathaxe commented Mar 6, 2017

GitGutter creates 2 temp files one for the content of the view and one for the file from index. They are passed to a git diff --no-index to get the changes.

I guess the issue is caused by the way the temporary files are created.

The view content is read via Sublime API as python string, encoded with the view's encoding (utf-8 by default) and written to disk. The lines of the string we get from ST are always terminated with \n. No matter what line-ending is set by the user in the front end. This makes sense as I normally don't want to struggle with that. As a result the temporary file contains \n while the file read from git may contain \r\n as you can see from @sbalgas`s screenshots.

I was not aware of that when I worked on the fix for issue #74.

@deathaxe
Copy link
Collaborator

deathaxe commented Mar 6, 2017

I put "ignore_whitespace": "eol", in my GitGutter Settings and I have the same problem.

@sbalgas: Did you restart ST? GitGutter reads 'eol' setting only on startup at the moment.

@ssddanbrown
Copy link

ssddanbrown commented Mar 6, 2017

This issue popped up for me (ST3 / Ubuntu 16.10). ignore_whitespace worked for me after restarting ST. Thanks @deathaxe.

@atomtigerzoo
Copy link
Author

atomtigerzoo commented Mar 7, 2017

Thank you for your fast reaction @deathaxe :) Problem solved!

@UnicodeTreason
Copy link

Adding "ignore_whitespace": "eol", to settings solved the issue for me.

@deathaxe
Copy link
Collaborator

Fix for the issue released with GitGutter 1.5.1

@gerardroche
Copy link
Contributor

@atomtigerzoo are you ignoring files on export in gitattributes file, see #409

@kikithedeveloper
Copy link

kikithedeveloper commented Jun 16, 2017

@deathaxe Adding "ignore_whitespace": "eol" to my GitGutter.sublime-settings - User did not solve anything for me. All lines in certain files still show as modified after I just git pushed everything up to date. My gitgutter version is 1.7.2.

@deathaxe
Copy link
Collaborator

The "ignore_whitespace": "eol" was proposed as I accidently removed the line-feed mangling in on of the older versions (1.5.0 I guess).

... still show as modified ...

Really modified or green + signs?

... pushed everything up to date ...

Does it mean, you saved a modified file in ST, than staged and commited it using git from shell or one of ST's git packages like GitSavvy? And after all file is still displayed as modified?

Which git version do you use? Some user recently concerned about file modifications at the end of lines not being tracked correctly, which was finally caused by his old git version.

If you set "debug": true in the GitGutter.sublime-settings you'll maybe get some messages which could help to find the reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants