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

Compare against branch indicates no changes and differs from "git diff <branch>" #568

Open
Pyrdon opened this issue Apr 26, 2022 · 4 comments

Comments

@Pyrdon
Copy link

Pyrdon commented Apr 26, 2022

Changing branch to compare against gives me no changes compared to git diff . After adding some debug printouts to git_gutter it seems like the temporary files it creates for comparison relates to a completely different project (I have several sublime projects open in parallel). Any ideas?

  • Sublime Text 4121
  • Platform: linux
  • Arch: x64
  • GitGutter 1.11.7
  • Install via PC: True
  • git version 2.20.1
  • mdpopups 4.2.1
  • markdown 3.2.2
  • pygments 2.1a0
  • jinja2 2.10.1
@deathaxe
Copy link
Collaborator

Temporary files are created using python's tempfile.mktemp() function. Maybe it returns equal names if too many files/projects are open?

@deathaxe
Copy link
Collaborator

Also note, GitGutter just calls view.set_reference_document() to give ST's internal minidiff something to compare against. So what you see on gutter may differ from plain git diff results, especially after heavy text manipulation it is known to "get out of sync" resulting in lower accuracy.

@Pyrdon
Copy link
Author

Pyrdon commented Apr 26, 2022

It was not related to the temporary files. After a few hours of debugging through print statements I found the culprit to be the encoding. The branch I was comparing with had a swedish comment and the character 0xC5 ('Å'). Fixing that and the comparison works as expected. An error printed to the console would be helpful here, or possible a message in the statusbar?

def _decode_diff(self, results):
        encoding = self.view_cache.python_friendly_encoding()
        try:
            decoded_results = results.decode(encoding)
        except AttributeError as e:
            # git returned None on stdout
            decoded_results = ''
        except UnicodeError:
            try:
                decoded_results = results.decode('utf-8')
            except UnicodeDecodeError as e:
                print("unicode: {}".format(str(e))) # Get here
                decoded_results = ''
        except LookupError:
            try:
                decoded_results = codecs.decode(results)
            except UnicodeDecodeError as e:
                decoded_results = ''
        print("Decoded '{}' for view '{}'".format(decoded_results,self.view.file_name()))
        # cache the diff result for reuse with diff_popup.
        self._git_diff_cache = decoded_results
        return self.process_diff(decoded_results)

@aashish108
Copy link

Yeah, I have this issue too. Do the devs have the time/energy/will to fix this bug by any chance?

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

No branches or pull requests

3 participants