Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@
"caption": "Git: Diff Tool All",
"command": "git_raw", "args": { "command": "git difftool", "may_change_files": false }
}
,{
"caption": "Git: Diff Branch",
"command": "git_diff_branch"
}
,{
"caption": "Git: Diff Current File with Branch",
"command": "git_diff_branch", "args": { "current_file": true }
}
,{
"caption": "Git: Commit",
"command": "git_commit"
Expand Down
25 changes: 25 additions & 0 deletions diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,31 @@ class GitDiffCommitCommand(GitDiffCommit, GitWindowCommand):
pass


class GitDiffBranchCommand(GitDiff, GitWindowCommand):
may_change_files = False
on_file = []

def run(self, edit=None, ignore_whitespace=False, current_file=False):
self.ignore_whitespace = ignore_whitespace
if current_file and self._active_file_name():
self.on_file = ['--', self._active_file_name()]
self.run_command(['git', 'branch', '--no-color'], self.branch_done)

def branch_done(self, result):
self.results = result.rstrip().split('\n')
self.quick_panel(self.results, self.panel_done,
sublime.MONOSPACE_FONT)

def panel_done(self, picked):
if 0 > picked < len(self.results):
return
picked_branch = self.results[picked].strip()
command = ['git', 'diff', '--no-color']
if self.ignore_whitespace:
command.extend(('--ignore-all-space', '--ignore-blank-lines'))
self.run_command(command + ['..'+picked_branch] + self.on_file, self.diff_done)


class GitGotoDiff(sublime_plugin.TextCommand):
def __init__(self, view):
self.view = view
Expand Down