From a9b7b63cc4e49ecd16f97900e42942c267bb9c17 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Wed, 12 Aug 2015 02:10:11 -0400 Subject: magit-insert-head-header: don't hardcode HEAD hash Despite its name, magit-insert-head-header is used by magit-cherry to insert information about a commit that is often, but not necessarily, the repo's HEAD. Previously, magit-insert-head-header inserted commit information for HEAD regardless of the BRANCH argument. As a result, giving magit-cherry a branch other than the current one as the first argument resulted in an incorrect header: Head: wrong-commit correct-branch wrong-subject Upstream: correct-commit correct-branch subject To fix this, use the BRANCH argument to retrieve the revision information if BRANCH is non-nil. --- lisp/magit.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/magit.el b/lisp/magit.el index 0c94613..8ddf49c 100644 --- a/lisp/magit.el +++ b/lisp/magit.el @@ -471,7 +471,7 @@ remote in alphabetic order." (cl-defun magit-insert-head-header (&optional (branch (magit-get-current-branch))) "Insert a header line about the `HEAD' commit." - (let ((output (magit-rev-format "%h %s" "HEAD"))) + (let ((output (magit-rev-format "%h %s" (or branch "HEAD")))) (string-match "^\\([^ ]+\\) \\(.*\\)" output) (magit-bind-match-strings (hash msg) output (magit-insert-section it (branch (or branch hash)) -- cgit v1.0