]> git.eshelyaron.com Git - emacs.git/commitdiff
Move error check from vc-next-action to diff-vc-deduce-fileset
authorSean Whitton <spwhitton@spwhitton.name>
Wed, 2 Oct 2024 01:22:52 +0000 (09:22 +0800)
committerEshel Yaron <me@eshelyaron.com>
Thu, 3 Oct 2024 06:42:09 +0000 (08:42 +0200)
* lisp/vc/diff-mode.el (diff-vc-deduce-fileset): Signal
user-error when the buffer is narrowed.
* lisp/vc/vc.el (vc-next-action): Remove code signalling a
user-error when the buffer is narrowed.

(cherry picked from commit 7aa106b8bf382f18342975e388720399554e2968)

lisp/vc/diff-mode.el
lisp/vc/vc.el

index 48d34c86779379bbe4d5eb4a383eb8a2792cb02c..9ff7137a29788182a8d9c472347b4b53225f3996 100644 (file)
@@ -3163,6 +3163,17 @@ hunk text is not found in the source file."
 
 ;;;###autoload
 (defun diff-vc-deduce-fileset ()
+  (when (buffer-narrowed-p)
+    ;; If user used `diff-restrict-view' then we may not have the
+    ;; file header, and the commit will not succeed (bug#73387).
+    (user-error "Cannot commit patch when narrowed; consider %s"
+                (mapconcat (lambda (c)
+                             (key-description
+                              (where-is-internal c nil t)))
+                           '(widen
+                             diff-delete-other-hunks
+                             vc-next-action)
+                           " ")))
   (let ((backend (vc-responsible-backend default-directory))
         files)
     (save-excursion
index d79bb12e9173e01130bb59915f430586e1821c1f..15636048307c674f99776c653b0223e48ce80369 100644 (file)
@@ -1302,17 +1302,6 @@ from which to check out the file(s)."
      ;; Fileset comes from a diff-mode buffer, see
      ;; 'diff-vc-deduce-fileset', and the buffer is the patch to apply.
      ((eq model 'patch)
-      (when (buffer-narrowed-p)
-        ;; If user used `diff-restrict-view' then we may not have the
-        ;; file header, and the commit will not succeed (bug#73387).
-        (user-error "Cannot commit patch when narrowed; consider %s"
-                    (mapconcat (lambda (c)
-                                 (key-description
-                                  (where-is-internal c nil t)))
-                               '(widen
-                                 diff-delete-other-hunks
-                                 vc-next-action)
-                               " ")))
       (vc-checkin files backend nil nil nil (buffer-string)))
      ((or (null state) (eq state 'unregistered))
       (cond (verbose