From e10168840674ad47cfe39b6d90261b44391d9907 Mon Sep 17 00:00:00 2001 From: 10sr <8.slashes@gmail.com> Date: Thu, 11 Oct 2018 11:59:57 +0900 Subject: [PATCH] Add --- emacs.el | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/emacs.el b/emacs.el index e978734..7fb3674 100644 --- a/emacs.el +++ b/emacs.el @@ -1,6 +1,6 @@ ;;; emacs.el --- 10sr emacs initialization -;; Time-stamp: <2018-10-11 00:27:24 JST 10sr> +;; Time-stamp: <2018-10-11 11:59:55 JST 10sr> ;;; Code: @@ -2240,12 +2240,46 @@ use for the buffer. It defaults to \"*recetf-show*\"." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; git revision +(defgroup git-revision nil + "Git revision." + :tag "GitRevision" + :prefix "git-revision-" + :group 'tools) + (defun git-revision-open-tree (treeish) "Open git tree buffer of TREEISH.") (defun git-revision-open (commit) "Open git tree buffer of COMMIT.") +(defcustom git-revision-git-executable "git" + "Git executable." + :type 'string + :group 'git-revision) + +(defun git-revision--resolve-treeish (commit) + "Get treeish id from COMMIT." + (cl-assert commit) + (cl-assert (not (string= "" commit))) + (with-temp-buffer + (let ((status (call-process git-revision-git-executable + nil + t + nil + "cat-file" + "-p" + commit))) + (unless (eq 0 + status) + (error "Failed to run cat-file for %s" commit)) + (goto-char (point-min)) + (save-match-data + (re-search-forward "^tree \\([0-9a-f]+\\)$") + (or (match-string 1) + (error "Failed to find treeish for %s" commit)))))) + +(git-revision--resolve-treeish "HEAD") + ;; Local Variables: ;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)