diff --git a/magit.el b/magit.el index 5e4863d4..81aaaee4 100644 --- a/magit.el +++ b/magit.el @@ -521,9 +521,23 @@ return nil." (defun magit-name-rev (rev) "Return a human-readable name for REV. Unlike git name-rev, this will remove tags/ and remotes/ prefixes -if that can be done unambiguously." +if that can be done unambiguously. In addition, it will filter +out revs involving HEAD." (when rev (let ((name (magit-git-string "name-rev" "--no-undefined" "--name-only" rev))) + ;; There doesn't seem to be a way of filtering HEAD out from name-rev, + ;; so we have to do it manually. + ;; HEAD-based names are too transient to allow. + (when (string-match "^\\(.*\\" name)) + (setq name (magit-rev-parse ref))))) (setq rev (or name rev)) (when (string-match "^\\(?:tags\\|remotes\\)/\\(.*\\)" rev) (let ((plain-name (match-string 1 rev)))