summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2026-02-14 15:29:07 +0000
committerSean Whitton <spwhitton@spwhitton.name>2026-02-14 15:29:07 +0000
commit768c68942e89ba2ad46f08dc0148cd663f59c8b3 (patch)
treee4880f6c6e39dd9f8aa2044053c9d646f87289cd
parentbc763572a9c5e9e8bd06467c1052f5372968e59c (diff)
Fix vc-pull from buffers visiting untracked files
* lisp/vc/vc.el (vc-pull): Don't fail when called from buffers visiting unregistered or ignored files so long as there is a 'pull' function available from the backend.
-rw-r--r--lisp/vc/vc.el26
1 files changed, 19 insertions, 7 deletions
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 85f059df573..7a0e0c354a2 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -4668,13 +4668,25 @@ file, this simply replaces the work file with the latest revision
on its branch. If the file contains changes, any changes in the
tip revision are merged into the working file."
(interactive "P")
- (let* ((vc-fileset (vc-deduce-fileset t))
- (backend (car vc-fileset))
- (files (cadr vc-fileset)))
+ (let (backend files fn)
+ (condition-case ret (vc-deduce-fileset 'not-state-changing)
+ (error
+ ;; If `vc-deduce-fileset' failed then try again with
+ ;; ALLOW-UNREGISTERED non-nil, but in this case we require a
+ ;; `pull' function because that doesn't need a list of files.
+ (unless
+ (setq fn
+ (and-let* ((fileset (vc-deduce-fileset 'not-state-changing
+ 'allow-unregistered)))
+ (vc-find-backend-function (car fileset) 'pull)))
+ (signal (car ret) (cdr ret))))
+ (:success
+ (setq backend (car ret) files (cadr ret)
+ fn (vc-find-backend-function backend 'pull))))
(cond
;; If a pull operation is defined, use it.
- ((vc-find-backend-function backend 'pull)
- (vc-call-backend backend 'pull arg)
+ (fn
+ (funcall fn arg)
;; FIXME: Ideally we would only clear out the stored value for the
;; REMOTE-LOCATION from which we are pulling.
(vc-run-delayed
@@ -4687,14 +4699,14 @@ tip revision are merged into the working file."
(let ((file (buffer-file-name)))
(and file (member file files))))))
(dolist (file files)
- (if (vc-up-to-date-p file)
+ (if (vc-up-to-date-p file)
(vc-checkout file t)
(vc-maybe-resolve-conflicts
file (vc-call-backend backend 'merge-news file)))))
;; For a locking VCS, check out each file.
((eq (vc-checkout-model backend files) 'locking)
(dolist (file files)
- (if (vc-up-to-date-p file)
+ (if (vc-up-to-date-p file)
(vc-checkout file t))))
(t
(error "VC update is unsupported for `%s'" backend)))))