Skip to content

Commit

Permalink
Merge pull request #733 from randy3k/diff_stat
Browse files Browse the repository at this point in the history
Enhancement: show diff stat in diff_view
  • Loading branch information
randy3k committed Aug 13, 2017
2 parents 9492dd2 + 34de565 commit 9d3a53b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion GitSavvy.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
core/git_mixins/history.py | 8 ++------
3 files changed, 10 insertions(+), 20 deletions(-)
Set to `false` if don't want to show this when view a commit.
Set to `false` if don't want to show this when view a commit or diff.
*/
"show_diffstat": true,

Expand Down
5 changes: 5 additions & 0 deletions core/commands/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def run_async(self, in_cached_mode=False, file_path=None, current_file=False, ba
"-" if base_commit is None else "--" + base_commit,
file_path or repo_path
)
savvy_settings = sublime.load_settings("GitSavvy.sublime-settings")

if view_key in diff_views and diff_views[view_key] in sublime.active_window().views():
diff_view = diff_views[view_key]
Expand All @@ -63,6 +64,7 @@ def run_async(self, in_cached_mode=False, file_path=None, current_file=False, ba
diff_view.settings().set("git_savvy.diff_view.show_word_diff", False)
diff_view.settings().set("git_savvy.diff_view.base_commit", base_commit)
diff_view.settings().set("git_savvy.diff_view.target_commit", target_commit)
diff_view.settings().set("git_savvy.diff_view.show_diffstat", savvy_settings.get("show_diffstat", True))
diff_view.settings().set("git_savvy.diff_view.disable_stage", disable_stage)
diff_views[view_key] = diff_view

Expand All @@ -87,12 +89,15 @@ def run(self, edit, cursors=None):
show_word_diff = self.view.settings().get("git_savvy.diff_view.show_word_diff")
base_commit = self.view.settings().get("git_savvy.diff_view.base_commit")
target_commit = self.view.settings().get("git_savvy.diff_view.target_commit")
show_diffstat = self.view.settings().get("git_savvy.diff_view.show_diffstat")

try:
stdout = self.git(
"diff",
"--ignore-all-space" if ignore_whitespace else None,
"--word-diff" if show_word_diff else None,
"--stat" if show_diffstat else None,
"--patch",
"--no-color",
"--cached" if in_cached_mode else None,
base_commit,
Expand Down
1 change: 1 addition & 0 deletions syntax/diff.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,4 @@ contexts:
2: markup.deleted.git-savvy.delete-block.content
3: punctuation.definition.deleted.diff

- include: "scope:git-savvy.commit-diffstat"
1 change: 0 additions & 1 deletion syntax/show_commit.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ contexts:
scope: meta.commit-header-and-stat-splitter
comment: Separator between commit message and diffstat

- include: "scope:git-savvy.commit-diffstat"
- include: "scope:git-savvy.diff"
2 changes: 1 addition & 1 deletion syntax/show_commit_diffstat.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ hidden: true
scope: git-savvy.commit-diffstat
contexts:
main:
- match: ^ (.+) \| +(\d+) (\+*)(-*)$\n?
- match: ^ (\S.+) \| +(\d+) (\+*)(-*)$\n?
comment: author and date info
scope: meta.commit-info.diffstat.line
captures:
Expand Down

0 comments on commit 9d3a53b

Please sign in to comment.