Skip to content

Commit cf56cde

Browse files
committed
New commend: show commit by hash
1 parent 18f0a56 commit cf56cde

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

Default.sublime-commands

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,13 @@
194194
"command": "git_push_current_branch"
195195
}
196196
,{
197-
"caption": "Git: Show Current File",
197+
"caption": "Git: Show Previous Version of Current File",
198198
"command": "git_show"
199199
}
200+
,{
201+
"caption": "Git: Show Commit By Hash",
202+
"command": "git_show_commit"
203+
}
200204
,{
201205
"caption": "Git: Toggle Annotations",
202206
"command": "git_toggle_annotations"

git/history.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,23 @@ class GitShowAllCommand(GitShow, GitWindowCommand):
139139
pass
140140

141141

142+
class GitShowCommitCommand(GitWindowCommand):
143+
def run(self, edit=None):
144+
self.window.show_input_panel("Commit to show:", "", self.input_done, None, None)
145+
146+
def input_done(self, commit):
147+
commit = commit.strip()
148+
149+
self.run_command(['git', 'show', commit, '--'], self.show_done, commit=commit)
150+
151+
def show_done(self, result, commit):
152+
if result.startswith('fatal:'):
153+
self.panel(result)
154+
return
155+
self.scratch(result, title="Git Commit: %s" % commit,
156+
syntax=plugin_file("syntax/Git Commit View.tmLanguage"))
157+
158+
142159
class GitGraph(object):
143160
def run(self, edit=None):
144161
filename = self.get_file_name()

0 commit comments

Comments
 (0)