From: Sean Whitton Date: Wed, 2 Oct 2024 01:22:52 +0000 (+0800) Subject: Move error check from vc-next-action to diff-vc-deduce-fileset X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=76960cc5e2aa71f99f2626b6e0125c652331a87b;p=emacs.git Move error check from vc-next-action to diff-vc-deduce-fileset * 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) --- diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 48d34c86779..9ff7137a297 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -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 diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index d79bb12e917..15636048307 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -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