diff options
| author | Dmitry Gutov | 2017-05-01 19:46:24 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2017-05-01 19:54:34 +0300 |
| commit | 8e94fb1dd952ed73ea03b1cd6d30eee4d6549e1a (patch) | |
| tree | dee14f4a592cd944cf0e4fe199c885a8693071b0 | |
| parent | c889b0998434776fbabc2a7fee0b29232ff98424 (diff) | |
| download | emacs-8e94fb1dd952ed73ea03b1cd6d30eee4d6549e1a.tar.gz emacs-8e94fb1dd952ed73ea03b1cd6d30eee4d6549e1a.zip | |
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).
| -rw-r--r-- | lisp/vc/vc-git.el | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 0e1c08c51ff..f70bbddbe7b 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el | |||
| @@ -231,6 +231,19 @@ Should be consistent with the Git config value i18n.logOutputEncoding." | |||
| 231 | (?U 'edited) ;; FIXME | 231 | (?U 'edited) ;; FIXME |
| 232 | (?T 'edited))) ;; FIXME | 232 | (?T 'edited))) ;; FIXME |
| 233 | 233 | ||
| 234 | (defvar vc-git--program-version nil) | ||
| 235 | |||
| 236 | (defun vc-git--program-version () | ||
| 237 | (or vc-git--program-version | ||
| 238 | (let ((version-string | ||
| 239 | (vc-git--run-command-string nil "version"))) | ||
| 240 | (setq vc-git--program-version | ||
| 241 | (if (and version-string | ||
| 242 | (string-match "git version \\([0-9.]+\\)$" | ||
| 243 | version-string)) | ||
| 244 | (match-string 1 version-string) | ||
| 245 | "0"))))) | ||
| 246 | |||
| 234 | (defun vc-git--git-status-to-vc-state (code-list) | 247 | (defun vc-git--git-status-to-vc-state (code-list) |
| 235 | "Convert CODE-LIST to a VC status. | 248 | "Convert CODE-LIST to a VC status. |
| 236 | 249 | ||
| @@ -268,25 +281,20 @@ in the order given by 'git status'." | |||
| 268 | 281 | ||
| 269 | (defun vc-git-state (file) | 282 | (defun vc-git-state (file) |
| 270 | "Git-specific version of `vc-state'." | 283 | "Git-specific version of `vc-state'." |
| 271 | ;; FIXME: Still can't detect `ignored', see below, and returns | 284 | ;; It can't set `needs-update' or `needs-merge'. The rough |
| 272 | ;; `up-to-date' instead. Which is rarely a problem because | ||
| 273 | ;; `vc-backend' returns nil for ignored files. | ||
| 274 | ;; | ||
| 275 | ;; It also can't set `needs-update' or `needs-merge'. The rough | ||
| 276 | ;; equivalent would be that upstream branch for current branch is in | 285 | ;; equivalent would be that upstream branch for current branch is in |
| 277 | ;; fast-forward state i.e. current branch is direct ancestor of | 286 | ;; fast-forward state i.e. current branch is direct ancestor of |
| 278 | ;; corresponding upstream branch, and the file was modified | 287 | ;; corresponding upstream branch, and the file was modified |
| 279 | ;; upstream. We'd need to check against the upstream tracking | 288 | ;; upstream. We'd need to check against the upstream tracking |
| 280 | ;; branch for that (an extra process call or two). | 289 | ;; branch for that (an extra process call or two). |
| 281 | (let ((status | 290 | (let* ((args |
| 282 | (vc-git--run-command-string file "status" "--porcelain" "-z" | 291 | `("status" "--porcelain" "-z" |
| 283 | ;; Just to be explicit, it's the | 292 | ;; Just to be explicit, it's the default anyway. |
| 284 | ;; default anyway. | 293 | "--untracked-files" |
| 285 | "--untracked-files" | 294 | ,@(when (version<= "1.7.6.3" (vc-git--program-version)) |
| 286 | ;; Requires Git 1.7.6.3 or so, | 295 | '("--ignored")) |
| 287 | ;; so does not work in CentOS 6 | 296 | "--")) |
| 288 | ;; "--ignored" | 297 | (status (apply #'vc-git--run-command-string file args))) |
| 289 | "--"))) | ||
| 290 | ;; Alternatively, the `ignored' state could be detected with 'git | 298 | ;; Alternatively, the `ignored' state could be detected with 'git |
| 291 | ;; ls-files -i -o --exclude-standard', but that's an extra process | 299 | ;; ls-files -i -o --exclude-standard', but that's an extra process |
| 292 | ;; call, and the `ignored' state is rarely needed. | 300 | ;; call, and the `ignored' state is rarely needed. |