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#52507: [PATCH] Option for vc-delete-file to keep file on disk Date: Wed, 15 Dec 2021 20:06:56 +0200 Organization: LINKOV.NET Message-ID: <861r2dzqrj.fsf@mail.linkov.net> References: <20211215095324.18195-1-ashwin@ashwink.com.np> <86a6h13j4i.fsf@mail.linkov.net> <85o85hsr3b.fsf@ashwink.com.np> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21420"; 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: 52507@debbugs.gnu.org To: Ashwin Kafle Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 15 20:23:09 2021 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 1mxZrp-0005Oz-DH for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 15 Dec 2021 20:23:09 +0100 Original-Received: from localhost ([::1]:48092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxZro-0004hb-1l for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 15 Dec 2021 14:23:08 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxYj7-0001nK-46 for bug-gnu-emacs@gnu.org; Wed, 15 Dec 2021 13:10:07 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50335) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxYj4-0000Aj-L5 for bug-gnu-emacs@gnu.org; Wed, 15 Dec 2021 13:10:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mxYj4-00052J-9C for bug-gnu-emacs@gnu.org; Wed, 15 Dec 2021 13:10:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 Dec 2021 18:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52507 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 52507-submit@debbugs.gnu.org id=B52507.163959174519284 (code B ref 52507); Wed, 15 Dec 2021 18:10:02 +0000 Original-Received: (at 52507) by debbugs.gnu.org; 15 Dec 2021 18:09:05 +0000 Original-Received: from localhost ([127.0.0.1]:33648 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mxYi9-00050y-J1 for submit@debbugs.gnu.org; Wed, 15 Dec 2021 13:09:05 -0500 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]:53893) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mxYi7-00050S-TP for 52507@debbugs.gnu.org; Wed, 15 Dec 2021 13:09:04 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 45596240009; Wed, 15 Dec 2021 18:08:54 +0000 (UTC) In-Reply-To: <85o85hsr3b.fsf@ashwink.com.np> (Ashwin Kafle's message of "Wed, 15 Dec 2021 17:41:44 +0000") 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:222440 Archived-At: >>> + (let ((backup-inhibited nil) >>> + ;; if you don't set this, then for some reason, the file is never brought back >>> + (backup-by-copying t)) >> >> I remember having the same problem while improving `vc-rename-file'. >> To solve the problem, it required adding `vc-file-clearprops'. >> Maybe it could here as well? > > There was a call to vc-file-clearprops later. I moved that earlier > before backup and that didn't seem to work. Then another question: why backup is needed at all? When the file is not going to be deleted, then there is no need to make a backup copy? >>> - (vc-resynch-buffer file nil t))) >>> + (vc-resynch-buffer file keep-file t))) >> >> It seems vc-resynch-window already uses `vc-file-clearprops' >> when `keep-file' is specified, but also on some more conditions. > > I'm sorry, but I didn't really understand the above. I don't really know > elisp to be honest. The comment before calling `vc-resynch-buffer' says it's to make sure the buffer is deleted. But it seems the buffer is already deleted at that point? Also it looks that your another change is dangerous: (defun vc-git-delete-file (file) - (vc-git-command nil 0 (vc-git--literal-pathspec file) "rm" "-f" "--")) + (vc-git-command nil 0 (vc-git--literal-pathspec file) "rm" "-f" "--cached" "--"))) because it deletes the file in the staging area that is not used by vc-git, so there is no way to commit the deletion using vc commands. Generally, you have a good idea, but it needs more careful handling with the existing vc commands.