Commit f1a60a0f authored by Dmitry Gutov's avatar Dmitry Gutov
Browse files

* lisp/vc/vc-git.el (vc-git-working-revision): When in detached mode,

return the commit hash.  Also set the `vc-git-detached' property.
(vc-git--rev-parse): Extract from `vc-git-previous-revision'.
(vc-git-mode-line-string): Use the same help-echo format whether in
detached mode or not, because we know the actual revision now.  When
in detached mode, shorten the revision to 7 chars.

Fixes: debbugs:14459
parent d289938a
......@@ -44,6 +44,16 @@
locally instead of changing `isearch-filter-predicate'.
(wdired-isearch-filter-read-only): Don't use `isearch-filter-visible'.
 
2013-05-27 Dmitry Gutov <dgutov@yandex.ru>
* vc/vc-git.el (vc-git-working-revision): When in detached mode,
return the commit hash (Bug#14459). Also set the
`vc-git-detached' property.
(vc-git--rev-parse): Extract from `vc-git-previous-revision'.
(vc-git-mode-line-string): Use the same help-echo format whether
in detached mode or not, because we know the actual revision now.
When in detached mode, shorten the revision to 7 chars.
2013-05-27 Stefan Monnier <monnier@iro.umontreal.ca>
 
* emacs-lisp/easy-mmode.el (define-minor-mode):
......
......@@ -234,30 +234,30 @@ matching the resulting Git log output, and KEYWORDS is a list of
(vc-git--state-code diff-letter)))
(if (vc-git--empty-db-p) 'added 'up-to-date))))
(defun vc-git-working-revision (_file)
(defun vc-git-working-revision (file)
"Git-specific version of `vc-working-revision'."
(let* (process-file-side-effects
(str (with-output-to-string
(with-current-buffer standard-output
(vc-git--out-ok "symbolic-ref" "HEAD")))))
(if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str)
(match-string 2 str)
str)))
(str (vc-git--run-command-string nil "symbolic-ref" "HEAD")))
(vc-file-setprop file 'vc-git-detached (null str))
(if str
(if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str)
(match-string 2 str)
str)
(vc-git--rev-parse "HEAD"))))
(defun vc-git-workfile-unchanged-p (file)
(eq 'up-to-date (vc-git-state file)))
(defun vc-git-mode-line-string (file)
"Return a string for `vc-mode-line' to put in the mode line for FILE."
(let* ((branch (vc-working-revision file))
(let* ((rev (vc-working-revision file))
(detached (vc-file-getprop file 'vc-git-detached))
(def-ml (vc-default-mode-line-string 'Git file))
(help-echo (get-text-property 0 'help-echo def-ml)))
(if (zerop (length branch))
(propertize
(concat def-ml "!")
'help-echo (concat help-echo "\nNo current branch (detached HEAD)"))
(propertize def-ml
'help-echo (concat help-echo "\nCurrent branch: " branch)))))
(propertize (if detached
(substring def-ml 0 (- 7 (length rev)))
def-ml)
'help-echo (concat help-echo "\nCurrent revision: " rev))))
(cl-defstruct (vc-git-extra-fileinfo
(:copier nil)
......@@ -943,10 +943,13 @@ or BRANCH^ (where \"^\" can be repeated)."
(point)
(1- (point-max)))))))
(or (vc-git-symbolic-commit prev-rev) prev-rev))
(with-temp-buffer
(and
(vc-git--out-ok "rev-parse" (concat rev "^"))
(buffer-substring-no-properties (point-min) (+ (point-min) 40))))))
(vc-git--rev-parse (concat rev "^"))))
(defun vc-git--rev-parse (rev)
(with-temp-buffer
(and
(vc-git--out-ok "rev-parse" rev)
(buffer-substring-no-properties (point-min) (+ (point-min) 40)))))
(defun vc-git-next-revision (file rev)
"Git-specific version of `vc-next-revision'."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment