mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-05 22:20:24 -08:00
Fix '(vc-revert-file (vc-git-root)'
* lisp/vc/vc-git.el (vc-git--file-list-is-rootdir): Merge into vc-git-command. (vc-git-command): When operating on the repository root, first bind default-directory to that root. When operating on the repository root with 'git checkout', pass "." as FILE-OR-LIST.
This commit is contained in:
parent
896449d65a
commit
0bf1eb692b
1 changed files with 48 additions and 36 deletions
|
|
@ -2711,7 +2711,7 @@ page for the meanings of these attributes."
|
|||
"A wrapper around `vc-do-command' for use in vc-git.el.
|
||||
The difference to `vc-do-command' is that this function always invokes
|
||||
`vc-git-program'."
|
||||
(let ((coding-system-for-read
|
||||
(let* ((coding-system-for-read
|
||||
(or coding-system-for-read vc-git-log-output-coding-system))
|
||||
;; Commands which pass command line arguments which might
|
||||
;; contain non-ASCII have to bind `coding-system-for-write' to
|
||||
|
|
@ -2729,27 +2729,39 @@ The difference to `vc-do-command' is that this function always invokes
|
|||
(process-environment
|
||||
(append
|
||||
`("GIT_DIR"
|
||||
,@(when vc-git-use-literal-pathspecs
|
||||
,@(and vc-git-use-literal-pathspecs
|
||||
'("GIT_LITERAL_PATHSPECS=1"))
|
||||
;; Avoid repository locking during background operations
|
||||
;; (bug#21559).
|
||||
,@(when revert-buffer-in-progress
|
||||
,@(and revert-buffer-in-progress
|
||||
'("GIT_OPTIONAL_LOCKS=0")))
|
||||
process-environment)))
|
||||
process-environment))
|
||||
(file1 (and (not (cdr-safe file-or-list))
|
||||
(or (car-safe file-or-list) file-or-list)))
|
||||
(file-list-is-rootdir (and file1
|
||||
(directory-name-p file1)
|
||||
(equal file1 (vc-git-root file1))))
|
||||
(default-directory (if file-list-is-rootdir
|
||||
file1
|
||||
default-directory)))
|
||||
(apply #'vc-do-command (or buffer "*vc*") okstatus vc-git-program
|
||||
;; https://debbugs.gnu.org/16897
|
||||
(unless (vc-git--file-list-is-rootdir file-or-list)
|
||||
file-or-list)
|
||||
;; Three cases:
|
||||
;; - operating on root directory and command is one where doing
|
||||
;; so requires passing "." to have the usual effect
|
||||
;; (e.g. 'git checkout --' will do nothing;
|
||||
;; 'git checkout -- .' will revert all files as desired)
|
||||
;; - operating on root directory and command is one where we
|
||||
;; must pass no list of files to have the usual effect
|
||||
;; (e.g. 'git log' for root logs as discussed in bug#16897)
|
||||
;; - not operating on root directory,
|
||||
;; pass FILE-OR-LIST along as normal.
|
||||
(cond ((and file-list-is-rootdir
|
||||
(member (car flags) '("checkout")))
|
||||
".")
|
||||
((not file-list-is-rootdir)
|
||||
file-or-list))
|
||||
(cons "--no-pager" flags))))
|
||||
|
||||
(defun vc-git--file-list-is-rootdir (file-or-list)
|
||||
(and (not (cdr-safe file-or-list))
|
||||
(let ((file (or (car-safe file-or-list)
|
||||
file-or-list)))
|
||||
(and file
|
||||
(directory-name-p file)
|
||||
(equal file (vc-git-root file))))))
|
||||
|
||||
(defun vc-git--empty-db-p ()
|
||||
"Check if the git db is empty (no commit done yet)."
|
||||
(let (process-file-side-effects)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue