aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-08-12 02:10:11 -0400
committerKyle Meyer <kyle@kyleam.com>2015-08-12 02:10:11 -0400
commita9b7b63cc4e49ecd16f97900e42942c267bb9c17 (patch)
tree34b3df04d2941ba3aaa73d9ff671290f142892a7 /lisp
parent8d0813e9f634496e1d4b8b4024888d6a6a1b9754 (diff)
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/magit.el2
1 files changed, 1 insertions, 1 deletions
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))