Skip to content

Commit

Permalink
Fix: Files are randomly marked as modified (Issue #381)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
deathaxe committed Mar 6, 2017
1 parent 55261b7 commit 527f901
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions git_gutter_handler.py
Expand Up @@ -271,6 +271,9 @@ def write_file(output):
# by exactly one file whose content we are interested in.
archive = zipfile.ZipFile(BytesIO(output))
contents = archive.read(archive.filelist[-1])
# Mangle end of lines
contents = contents.replace(b'\r\n', b'\n')
contents = contents.replace(b'\r', b'\n')
# Write the content to file
if not self._git_temp_file:
self._git_temp_file = self.tmp_file()
Expand Down

2 comments on commit 527f901

@rahul-ramadas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is true that the view will always have only \n. I think that would depend on the OS. I'm on Windows, and when I open a file that I know has CRLF line endings, GitGutter it telling me that all lines are different.

@r-stein
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Views only apply the line endings when saving and reading and use \n internally (This leads to problems with mixed line endings). Do you have the newest version from the master branch or the latest release (which does not contain this fix)?

Please sign in to comment.