diff options
| author | Dmitry Gutov | 2013-05-28 03:11:21 +0400 |
|---|---|---|
| committer | Dmitry Gutov | 2013-05-28 03:11:21 +0400 |
| commit | f1a60a0f07666582843f324767f740b75c071fb9 (patch) | |
| tree | 9f2a855a99ba9895ee7e6039ca6ecc52c659f56a /lisp | |
| parent | d289938a057ab8572fc60eb5367980eeef35d600 (diff) | |
| download | emacs-f1a60a0f07666582843f324767f740b75c071fb9.tar.gz emacs-f1a60a0f07666582843f324767f740b75c071fb9.zip | |
* 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
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/vc/vc-git.el | 39 |
2 files changed, 31 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cc3122f7e6f..ecdeb49f254 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -44,6 +44,16 @@ | |||
| 44 | locally instead of changing `isearch-filter-predicate'. | 44 | locally instead of changing `isearch-filter-predicate'. |
| 45 | (wdired-isearch-filter-read-only): Don't use `isearch-filter-visible'. | 45 | (wdired-isearch-filter-read-only): Don't use `isearch-filter-visible'. |
| 46 | 46 | ||
| 47 | 2013-05-27 Dmitry Gutov <dgutov@yandex.ru> | ||
| 48 | |||
| 49 | * vc/vc-git.el (vc-git-working-revision): When in detached mode, | ||
| 50 | return the commit hash (Bug#14459). Also set the | ||
| 51 | `vc-git-detached' property. | ||
| 52 | (vc-git--rev-parse): Extract from `vc-git-previous-revision'. | ||
| 53 | (vc-git-mode-line-string): Use the same help-echo format whether | ||
| 54 | in detached mode or not, because we know the actual revision now. | ||
| 55 | When in detached mode, shorten the revision to 7 chars. | ||
| 56 | |||
| 47 | 2013-05-27 Stefan Monnier <monnier@iro.umontreal.ca> | 57 | 2013-05-27 Stefan Monnier <monnier@iro.umontreal.ca> |
| 48 | 58 | ||
| 49 | * emacs-lisp/easy-mmode.el (define-minor-mode): | 59 | * emacs-lisp/easy-mmode.el (define-minor-mode): |
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 06474cb4604..caece2ec277 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el | |||
| @@ -234,30 +234,30 @@ matching the resulting Git log output, and KEYWORDS is a list of | |||
| 234 | (vc-git--state-code diff-letter))) | 234 | (vc-git--state-code diff-letter))) |
| 235 | (if (vc-git--empty-db-p) 'added 'up-to-date)))) | 235 | (if (vc-git--empty-db-p) 'added 'up-to-date)))) |
| 236 | 236 | ||
| 237 | (defun vc-git-working-revision (_file) | 237 | (defun vc-git-working-revision (file) |
| 238 | "Git-specific version of `vc-working-revision'." | 238 | "Git-specific version of `vc-working-revision'." |
| 239 | (let* (process-file-side-effects | 239 | (let* (process-file-side-effects |
| 240 | (str (with-output-to-string | 240 | (str (vc-git--run-command-string nil "symbolic-ref" "HEAD"))) |
| 241 | (with-current-buffer standard-output | 241 | (vc-file-setprop file 'vc-git-detached (null str)) |
| 242 | (vc-git--out-ok "symbolic-ref" "HEAD"))))) | 242 | (if str |
| 243 | (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str) | 243 | (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str) |
| 244 | (match-string 2 str) | 244 | (match-string 2 str) |
| 245 | str))) | 245 | str) |
| 246 | (vc-git--rev-parse "HEAD")))) | ||
| 246 | 247 | ||
| 247 | (defun vc-git-workfile-unchanged-p (file) | 248 | (defun vc-git-workfile-unchanged-p (file) |
| 248 | (eq 'up-to-date (vc-git-state file))) | 249 | (eq 'up-to-date (vc-git-state file))) |
| 249 | 250 | ||
| 250 | (defun vc-git-mode-line-string (file) | 251 | (defun vc-git-mode-line-string (file) |
| 251 | "Return a string for `vc-mode-line' to put in the mode line for FILE." | 252 | "Return a string for `vc-mode-line' to put in the mode line for FILE." |
| 252 | (let* ((branch (vc-working-revision file)) | 253 | (let* ((rev (vc-working-revision file)) |
| 254 | (detached (vc-file-getprop file 'vc-git-detached)) | ||
| 253 | (def-ml (vc-default-mode-line-string 'Git file)) | 255 | (def-ml (vc-default-mode-line-string 'Git file)) |
| 254 | (help-echo (get-text-property 0 'help-echo def-ml))) | 256 | (help-echo (get-text-property 0 'help-echo def-ml))) |
| 255 | (if (zerop (length branch)) | 257 | (propertize (if detached |
| 256 | (propertize | 258 | (substring def-ml 0 (- 7 (length rev))) |
| 257 | (concat def-ml "!") | 259 | def-ml) |
| 258 | 'help-echo (concat help-echo "\nNo current branch (detached HEAD)")) | 260 | 'help-echo (concat help-echo "\nCurrent revision: " rev)))) |
| 259 | (propertize def-ml | ||
| 260 | 'help-echo (concat help-echo "\nCurrent branch: " branch))))) | ||
| 261 | 261 | ||
| 262 | (cl-defstruct (vc-git-extra-fileinfo | 262 | (cl-defstruct (vc-git-extra-fileinfo |
| 263 | (:copier nil) | 263 | (:copier nil) |
| @@ -943,10 +943,13 @@ or BRANCH^ (where \"^\" can be repeated)." | |||
| 943 | (point) | 943 | (point) |
| 944 | (1- (point-max))))))) | 944 | (1- (point-max))))))) |
| 945 | (or (vc-git-symbolic-commit prev-rev) prev-rev)) | 945 | (or (vc-git-symbolic-commit prev-rev) prev-rev)) |
| 946 | (with-temp-buffer | 946 | (vc-git--rev-parse (concat rev "^")))) |
| 947 | (and | 947 | |
| 948 | (vc-git--out-ok "rev-parse" (concat rev "^")) | 948 | (defun vc-git--rev-parse (rev) |
| 949 | (buffer-substring-no-properties (point-min) (+ (point-min) 40)))))) | 949 | (with-temp-buffer |
| 950 | (and | ||
| 951 | (vc-git--out-ok "rev-parse" rev) | ||
| 952 | (buffer-substring-no-properties (point-min) (+ (point-min) 40))))) | ||
| 950 | 953 | ||
| 951 | (defun vc-git-next-revision (file rev) | 954 | (defun vc-git-next-revision (file rev) |
| 952 | "Git-specific version of `vc-next-revision'." | 955 | "Git-specific version of `vc-next-revision'." |