From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Date: Sat, 27 Aug 2022 23:07:12 +0300 Organization: LINKOV.NET Message-ID: <86ler9labz.fsf@mail.linkov.net> References: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> <9106387a-98cf-396f-bf45-ccb04581787b@yandex.ru> <864k7kfd56.fsf@mail.linkov.net> <86fsr3uen2.fsf@mail.linkov.net> <95d2d999-49ad-13c4-9f25-0935650a1e42@yandex.ru> <8635ktjfll.fsf@mail.linkov.net> <36b963e4-5af7-dd9e-af92-4404541b9f4d@yandex.ru> <86v8xjx45h.fsf@mail.linkov.net> <861qt9h1hh.fsf@mail.linkov.net> <864jy1mrk8.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30202"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: 52349@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 27 22:13:30 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oS2BN-0007gE-CF for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Aug 2022 22:13:29 +0200 Original-Received: from localhost ([::1]:46568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oS2BM-0007IA-9U for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Aug 2022 16:13:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oS2Ax-0007HR-0e for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2022 16:13:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39182) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oS2Aw-0004Iv-OM for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2022 16:13:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oS2Aw-0003xW-Cx for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2022 16:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Aug 2022 20:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs Original-Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166163117715200 (code B ref 52349); Sat, 27 Aug 2022 20:13:02 +0000 Original-Received: (at 52349) by debbugs.gnu.org; 27 Aug 2022 20:12:57 +0000 Original-Received: from localhost ([127.0.0.1]:57163 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oS2Ar-0003x6-Dw for submit@debbugs.gnu.org; Sat, 27 Aug 2022 16:12:57 -0400 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:50305) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oS2Am-0003wc-8o for 52349@debbugs.gnu.org; Sat, 27 Aug 2022 16:12:53 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id E8AA1FF802; Sat, 27 Aug 2022 20:12:42 +0000 (UTC) In-Reply-To: (Dmitry Gutov's message of "Wed, 24 Aug 2022 23:20:59 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:240965 Archived-At: --=-=-= Content-Type: text/plain >> @@ -944,6 +944,8 @@ vc-git-checkin >> (let ((default-directory (file-name-directory file1))) >> (make-nearby-temp-file "git-msg"))))) >> (when vc-git-patch-string >> + (unless (eq (vc-git-command nil t nil "diff" "--cached" "--quiet") 0) >> + (error "Index not empty")) > > user-error, maybe? Will be fixed. >> (let ((patch-file (make-temp-file "git-patch"))) >> (with-temp-file patch-file >> (insert vc-git-patch-string)) > > Looking great otherwise. Please install whenever you think it's ready. Not yet great :) I tried to fix another long-standing problem because its solution should also define the names of new functions here. The problem is that currently using 'C-c C-d' (log-edit-show-diff) in the *vc-log* buffer doesn't show the same diff that will be really committed when different files were marked in *vc-dir* parent buffer before typing 'C-c C-c' in *vc-log*. This is because currently log-edit-diff-function is set to vc-diff that is not suitable here since it tries to deduce fileset again from *vc-dir*, but files to commit are set in the buffer-local 'vc-log-fileset' in *vc-log*. So I added a new function 'log-edit-diff-fileset' that shows the diff from 'vc-log-fileset'. Using the same naming scheme, I renamed 'vc-diff-patch' to 'log-edit-diff-patch'. This shows the difference from the previous patch, but later these changes could be committed separately: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=log-edit-diff-patch.patch diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el index e958673fea..5290616302 100644 --- a/lisp/vc/log-edit.el +++ b/lisp/vc/log-edit.el @@ -664,6 +664,19 @@ log-edit-set-common-indentation (indent-rigidly (point) (point-max) (- log-edit-common-indent common))))) +(defvar vc-patch-string) + +(autoload 'vc-diff-patch-string "vc") +(defun log-edit-diff-patch () + (vc-diff-patch-string vc-patch-string)) + +(defvar vc-log-fileset) + +(defun log-edit-diff-fileset () + "Display diffs for the files to be committed." + (interactive) + (vc-diff nil nil (list log-edit-vc-backend vc-log-fileset))) + (defun log-edit-show-diff () "Show the diff for the files to be committed." (interactive) diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index 74e624999f..36a6f27891 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -656,7 +656,7 @@ vc-log-edit (lambda (file) (file-relative-name file root)) fileset)))) (log-edit-diff-function - . ,(if vc-patch-string 'vc-diff-patch 'vc-diff)) + . ,(if vc-patch-string 'log-edit-diff-patch 'log-edit-diff-fileset)) (log-edit-vc-backend . ,backend) (vc-log-fileset . ,fileset) (vc-patch-string . ,vc-patch-string)) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index cce692f7ea..51ae10ae5c 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1795,18 +1795,16 @@ vc-diff-added-files (defvar vc-patch-string nil) -(defun vc-diff-patch () - (let ((buffer "*vc-diff*") - (patch-string vc-patch-string)) +(defun vc-diff-patch-string (patch-string) + (let ((buffer "*vc-diff*")) (vc-setup-buffer buffer) - (set-buffer buffer) (let ((buffer-undo-list t) (inhibit-read-only t)) (insert patch-string)) (setq buffer-read-only t) (diff-mode) (setq-local diff-vc-backend (vc-responsible-backend default-directory)) - (setq-local revert-buffer-function (lambda (_ _) (vc-diff-patch))) + (setq-local revert-buffer-function (lambda (_ _) (vc-diff-patch-string))) (setq-local vc-patch-string patch-string) (pop-to-buffer (current-buffer)) (vc-run-delayed (vc-diff-finish (current-buffer) nil)))) @@ -2000,7 +1998,7 @@ vc-maybe-buffer-sync (when buffer-file-name (vc-buffer-sync not-urgent)))) ;;;###autoload -(defun vc-diff (&optional historic not-urgent) +(defun vc-diff (&optional historic not-urgent fileset) "Display diffs between file revisions. Normally this compares the currently selected fileset with their working revisions. With a prefix argument HISTORIC, it reads two revision @@ -2012,7 +2010,7 @@ vc-diff (if historic (call-interactively 'vc-version-diff) (vc-maybe-buffer-sync not-urgent) - (let ((fileset (vc-deduce-fileset t))) + (let ((fileset (or fileset (vc-deduce-fileset t)))) (vc-buffer-sync-fileset fileset not-urgent) (vc-diff-internal t fileset nil nil (called-interactively-p 'interactive))))) --=-=-=--