[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: git log question
From: |
Stephen Berman |
Subject: |
Re: git log question |
Date: |
Thu, 30 Nov 2017 20:11:23 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Thanks for all the instructive responses. The magit and gitk displays
contain the information I want, but also much more than I want, and gitk
takes rather long to load, in addition to not being inside emacs (magit
I have yet to try). I've actually been using an Elisp command I defined
some time ago, but it didn't show the branches (because, as I mentioned
in my OP, I had (wrongly) assumed that `git log' only show commits on
the "branch" it is invoked on); I've now revised it to do that. Here it
is, for anyone who's interested:
(defun srb-git-log (&optional repo commit)
"Check REPO for COMMIT and if it exists, display its commit message.
Interactively, prompt for REPO, defaulting to emacs-master, and
for COMMIT, defaulting to the commit hash at point."
(interactive "p")
(let* ((git-dir (if repo
(read-directory-name "Repo: " "/mnt/data/steve/git/"
nil t "emacs-master")
"/mnt/data/steve/git/emacs-master"))
(commit0 (or commit (read-string "Commit: " nil nil (word-at-point))))
(default-directory git-dir)
(output-buffer (get-buffer-create "*git log*"))
(proc (progn
(with-current-buffer output-buffer (erase-buffer))
(call-process "git" nil output-buffer nil
"branch" "--contains" commit0))))
(when proc
(with-current-buffer output-buffer
(goto-char (point-min))
(unless (looking-at "[ *]")
(user-error "%s is not on branch %s" commit0
(file-name-base git-dir)))
(insert "Branches:\n")
(goto-char (point-max))
(call-process "git" nil output-buffer nil "log" "-1" commit0)
(pop-to-buffer output-buffer)))))
Steve Berman