diff --git a/Git.sublime-settings b/Git.sublime-settings index acd87e81..71ce4c04 100644 --- a/Git.sublime-settings +++ b/Git.sublime-settings @@ -9,6 +9,11 @@ // point this the installation location of git-flow ,"git_flow_command": "/usr/local/bin/git-flow" + // formatting options for the graph, these options are added to + // "git log --graph" command. "--follow" is added if generating a + // graph of a file. You'll probably want to change the syntax file. + ,"git_graph_options": "--pretty='%h -%d (%cr) (%ci) <%an> %s' --abbrev-commit --no-color --decorate --date=relative" + // use the panel for diff output, rather than a new scratch window (new tab) ,"diff_panel": false diff --git a/history.py b/history.py index 11205e83..7f65d926 100644 --- a/history.py +++ b/history.py @@ -1,6 +1,7 @@ import sublime_plugin import functools import re +import shlex import sublime from .git import GitTextCommand, GitWindowCommand, plugin_file @@ -133,11 +134,12 @@ class GitShowAllCommand(GitShow, GitWindowCommand): class GitGraph(object): def run(self, edit=None): + s = sublime.load_settings("Git.sublime-settings") + command = "git log --graph " + s.get("git_graph_options") filename = self.get_file_name() - self.run_command( - ['git', 'log', '--graph', '--pretty=%h -%d (%cr) (%ci) <%an> %s', '--abbrev-commit', '--no-color', '--decorate', '--date=relative', '--follow' if filename else None, '--', filename], - self.log_done - ) + if filename: + command = command + " --follow -- " + filename + self.run_command(shlex.split(command), self.log_done) def log_done(self, result): self.scratch(result, title="Git Log Graph", syntax=plugin_file("syntax/Git Graph.tmLanguage")) diff --git a/syntax/Git Graph.JSON-tmLanguage b/syntax/Git Graph.JSON-tmLanguage index 926b3d6b..5897a352 100644 --- a/syntax/Git Graph.JSON-tmLanguage +++ b/syntax/Git Graph.JSON-tmLanguage @@ -2,14 +2,15 @@ "scopeName": "text.git-graph", "fileTypes": ["git-graph"], "patterns": [ - { "match": "^([| *\\\\]+)([0-9a-f]{4,40}) (.*?) (\\d{4}-\\d\\d-\\d\\d \\d\\d:\\d\\d:\\d\\d [+-]\\d{4}) (?:\\(((?:[a-zA-Z0-9._\\-\\/]+(?:, )?)+)\\) )?", + { "match": "^([| *\\\\]+)([0-9a-f]{4,40}) -( \\(.*?\\))? (.*) (\\(.*) (<.*>) .*", "name": "log-entry.git-graph", "captures": { "1": {"name": "comment.git-graph" }, "2": {"name": "string.git-graph" }, "3": {"name": "support.function.git-graph" }, "4": {"name": "constant.numeric.git-graph" }, - "5": {"name": "variable.parameter.git-graph" } + "5": {"name": "variable.parameter.git-graph" }, + "6": {"name": "keyword.git-graph" } } }, { "match": "^\\|[\\|_\\/\\\\ ]+\n?$",