From 1dc5ee1bc6ffe96aa1f767d6d4490b2f086b526e Mon Sep 17 00:00:00 2001 From: Kamil Kujawinski Date: Sat, 8 Aug 2015 15:03:00 +0200 Subject: [PATCH] Allow to define custom log format. It is useful when you want to search by full changset hash --- Git.sublime-settings | 3 +++ history.py | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Git.sublime-settings b/Git.sublime-settings index acd87e81..eeef9736 100644 --- a/Git.sublime-settings +++ b/Git.sublime-settings @@ -37,4 +37,7 @@ // e.g. "Packages/Git/syntax/Git Commit Message.tmLanguage" ,"diff_syntax": "Packages/Diff/Diff.tmLanguage" + + // %H to have more convinent way to search by changeset hash + ,"log_format": "%s (%h)\\a%an <%aE>\\a%ad (%ar)" } diff --git a/history.py b/history.py index dd5019fb..1d910a7a 100644 --- a/history.py +++ b/history.py @@ -49,13 +49,18 @@ def run(self, edit=None): return self.run_log(fn != '', '--', fn) def run_log(self, follow, *args): + s = sublime.load_settings("Git.sublime-settings") + log_format_fallback = '%s (%h)\a%an <%aE>\a%ad (%ar)' + # all this to remove convert json escape \\a to \a + log_format = bytes(s.get('log_format', log_format_fallback), 'utf-8').decode('unicode_escape') + # the ASCII bell (\a) is just a convenient character I'm pretty sure # won't ever come up in the subject of the commit (and if it does then # you positively deserve broken output...) # 9000 is a pretty arbitrarily chosen limit; picked entirely because # it's about the size of the largest repo I've tested this on... and # there's a definite hiccup when it's loading that - command = ['git', 'log', '--no-color', '--pretty=%s (%h)\a%an <%aE>\a%ad (%ar)', + command = ['git', 'log', '--no-color', '--pretty=' + log_format, '--date=local', '--max-count=9000', '--follow' if follow else None] command.extend(args) self.run_command(