X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/1505643bb70ce66e86d6c72902fe7e9199e93606..2703629711f29f6a46e2766c10df5df5863d2ab9:/lisp/vc/vc-git.el diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 1700bef10b..2bca723ce7 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1,6 +1,6 @@ ;;; vc-git.el --- VC backend for the git version control system -*- lexical-binding: t -*- -;; Copyright (C) 2006-2014 Free Software Foundation, Inc. +;; Copyright (C) 2006-2015 Free Software Foundation, Inc. ;; Author: Alexandre Julliard ;; Keywords: vc tools @@ -120,6 +120,16 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches." :version "23.1" :group 'vc-git) +(defcustom vc-git-annotate-switches nil + "String or list of strings specifying switches for Git blame under VC. +If nil, use the value of `vc-annotate-switches'. If t, use no switches." + :type '(choice (const :tag "Unspecified" nil) + (const :tag "None" t) + (string :tag "Argument String") + (repeat :tag "Argument List" :value ("") string)) + :version "25.1" + :group 'vc-git) + (defcustom vc-git-program "git" "Name of the Git executable (excluding any arguments)." :version "24.1" @@ -761,6 +771,9 @@ This prompts for a branch to merge from." (vc-git--run-command-string directory "status" "--porcelain" "--")) (lines (when status (split-string status "\n" 'omit-nulls))) files) + ;; TODO: Look into reimplementing `vc-git-state', as well as + ;; `vc-git-dir-status-files', based on this output, thus making the + ;; extra process call in `vc-git-find-file-hook' unnecessary. (dolist (line lines files) (when (string-match "\\([ MADRCU?!][ MADRCU?!]\\) \\(.+\\)\\(?: -> \\(.+\\)\\)?" line) @@ -776,7 +789,12 @@ This prompts for a branch to merge from." (save-excursion (goto-char (point-min)) (unless (re-search-forward "^<<<<<<< " nil t) - (vc-git-command nil 0 buffer-file-name "add") + (if (file-exists-p (expand-file-name ".git/MERGE_HEAD" + (vc-git-root buffer-file-name))) + ;; Doing a merge. + (vc-git-command nil 0 buffer-file-name "add") + ;; Doing something else. Likely applying a stash (bug#20292). + (vc-git-command nil 0 buffer-file-name "reset")) ;; Remove the hook so that it is not called multiple times. (remove-hook 'after-save-hook 'vc-git-resolve-when-done t)))) @@ -1013,9 +1031,11 @@ or BRANCH^ (where \"^\" can be repeated)." (defun vc-git-annotate-command (file buf &optional rev) (let ((name (file-relative-name file))) - (vc-git-command buf 'async nil "blame" "--date=iso" "-C" "-C" rev "--" name))) + (apply #'vc-git-command buf 'async nil "blame" "--date=iso" + (append (vc-switches 'git 'annotate) + (list rev "--" name))))) -(declare-function vc-annotate-convert-time "vc-annotate" (time)) +(declare-function vc-annotate-convert-time "vc-annotate" (&optional time)) (defun vc-git-annotate-time () (and (re-search-forward "[0-9a-f]+[^()]+(.* \\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\) \\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\) \\([-+0-9]+\\) +[0-9]+) " nil t)