def update_git_file(self):
        def write_file(contents):
            contents = contents.replace(b'\r\n', b'\n')
            contents = contents.replace(b'\r', b'\n')
            with open(self.git_temp_file, 'wb') as f:
                f.write(contents)

        if self.git_time() > self.git_file_update_interval_secs:
            with open(self.git_temp_file, 'w'):
                pass

            args = [
                settings.git_binary_path,
                '--git-dir=' + self.git_dir,
                '--work-tree=' + self.git_tree,
                'show',
                '%s:%s' %
                (settings.get_compare_against(self.view), self.git_path),
            ]

            try:
                self.update_git_time()
                return GitGutterHandler.run_command(args).then(write_file)
            except Exception:
                pass
        return Promise.resolve()
 def update_status_ui(branch_name):
     self._update_status(
         len(inserted), len(modified), len(deleted),
         settings.get_compare_against(
             self.git_handler.git_dir, self.view),
         branch_name)
 def get_compare_against(self):
     """Return the branch/commit/tag string the view is compared to."""
     return settings.get_compare_against(self._git_tree, self.view)
 def run(self):
     comparing = settings.get_compare_against(self.view)
     sublime.message_dialog('GitGutter is comparing against: %s' %
                            comparing)