mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-04 11:00:45 -08:00
vc-git-state: Return `ignored' as appropriate with newer Git
* lisp/vc/vc-git.el (vc-git--program-version): New variable. (vc-git--program-version): New function. (vc-git-state): Use it to choose whether to add '--ignored' (bug#19343).
This commit is contained in:
parent
c889b09984
commit
8e94fb1dd9
1 changed files with 22 additions and 14 deletions
|
|
@ -231,6 +231,19 @@ Should be consistent with the Git config value i18n.logOutputEncoding."
|
||||||
(?U 'edited) ;; FIXME
|
(?U 'edited) ;; FIXME
|
||||||
(?T 'edited))) ;; FIXME
|
(?T 'edited))) ;; FIXME
|
||||||
|
|
||||||
|
(defvar vc-git--program-version nil)
|
||||||
|
|
||||||
|
(defun vc-git--program-version ()
|
||||||
|
(or vc-git--program-version
|
||||||
|
(let ((version-string
|
||||||
|
(vc-git--run-command-string nil "version")))
|
||||||
|
(setq vc-git--program-version
|
||||||
|
(if (and version-string
|
||||||
|
(string-match "git version \\([0-9.]+\\)$"
|
||||||
|
version-string))
|
||||||
|
(match-string 1 version-string)
|
||||||
|
"0")))))
|
||||||
|
|
||||||
(defun vc-git--git-status-to-vc-state (code-list)
|
(defun vc-git--git-status-to-vc-state (code-list)
|
||||||
"Convert CODE-LIST to a VC status.
|
"Convert CODE-LIST to a VC status.
|
||||||
|
|
||||||
|
|
@ -268,25 +281,20 @@ in the order given by 'git status'."
|
||||||
|
|
||||||
(defun vc-git-state (file)
|
(defun vc-git-state (file)
|
||||||
"Git-specific version of `vc-state'."
|
"Git-specific version of `vc-state'."
|
||||||
;; FIXME: Still can't detect `ignored', see below, and returns
|
;; It can't set `needs-update' or `needs-merge'. The rough
|
||||||
;; `up-to-date' instead. Which is rarely a problem because
|
|
||||||
;; `vc-backend' returns nil for ignored files.
|
|
||||||
;;
|
|
||||||
;; It also can't set `needs-update' or `needs-merge'. The rough
|
|
||||||
;; equivalent would be that upstream branch for current branch is in
|
;; equivalent would be that upstream branch for current branch is in
|
||||||
;; fast-forward state i.e. current branch is direct ancestor of
|
;; fast-forward state i.e. current branch is direct ancestor of
|
||||||
;; corresponding upstream branch, and the file was modified
|
;; corresponding upstream branch, and the file was modified
|
||||||
;; upstream. We'd need to check against the upstream tracking
|
;; upstream. We'd need to check against the upstream tracking
|
||||||
;; branch for that (an extra process call or two).
|
;; branch for that (an extra process call or two).
|
||||||
(let ((status
|
(let* ((args
|
||||||
(vc-git--run-command-string file "status" "--porcelain" "-z"
|
`("status" "--porcelain" "-z"
|
||||||
;; Just to be explicit, it's the
|
;; Just to be explicit, it's the default anyway.
|
||||||
;; default anyway.
|
"--untracked-files"
|
||||||
"--untracked-files"
|
,@(when (version<= "1.7.6.3" (vc-git--program-version))
|
||||||
;; Requires Git 1.7.6.3 or so,
|
'("--ignored"))
|
||||||
;; so does not work in CentOS 6
|
"--"))
|
||||||
;; "--ignored"
|
(status (apply #'vc-git--run-command-string file args)))
|
||||||
"--")))
|
|
||||||
;; Alternatively, the `ignored' state could be detected with 'git
|
;; Alternatively, the `ignored' state could be detected with 'git
|
||||||
;; ls-files -i -o --exclude-standard', but that's an extra process
|
;; ls-files -i -o --exclude-standard', but that's an extra process
|
||||||
;; call, and the `ignored' state is rarely needed.
|
;; call, and the `ignored' state is rarely needed.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue