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: Wed, 08 Dec 2021 20:57:21 +0200 Organization: LINKOV.NET Message-ID: <86fsr3uen2.fsf@mail.linkov.net> References: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> <9106387a-98cf-396f-bf45-ccb04581787b@yandex.ru> <864k7kfd56.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20786"; 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: Manuel Uberti , 52349@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 08 20:32: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 1mv2ff-0005ES-AL for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Dec 2021 20:32:07 +0100 Original-Received: from localhost ([::1]:38670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mv2fb-0004hJ-VR for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Dec 2021 14:32:04 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mv2di-0003TS-Fm for bug-gnu-emacs@gnu.org; Wed, 08 Dec 2021 14:30:06 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58138) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mv2dg-0003hr-87 for bug-gnu-emacs@gnu.org; Wed, 08 Dec 2021 14:30:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mv2dg-0004Mv-5S for bug-gnu-emacs@gnu.org; Wed, 08 Dec 2021 14:30:04 -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, 08 Dec 2021 19:30:04 +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.163899177516669 (code B ref 52349); Wed, 08 Dec 2021 19:30:04 +0000 Original-Received: (at 52349) by debbugs.gnu.org; 8 Dec 2021 19:29:35 +0000 Original-Received: from localhost ([127.0.0.1]:41439 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mv2dC-0004Kn-VA for submit@debbugs.gnu.org; Wed, 08 Dec 2021 14:29:35 -0500 Original-Received: from relay8-d.mail.gandi.net ([217.70.183.201]:55211) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mv2dA-0004KV-QQ for 52349@debbugs.gnu.org; Wed, 08 Dec 2021 14:29:33 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 49D531BF20A; Wed, 8 Dec 2021 19:29:24 +0000 (UTC) In-Reply-To: (Dmitry Gutov's message of "Wed, 8 Dec 2021 05:29:11 +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:221942 Archived-At: >> The problem is that 'git apply --cached' doesn't perform the merge >> with other changes in the same file, whereas 'git stash pop' >> merges committed changes with uncommitted changes. > > This seems to address our previous discussion, rather than the difference > vs. diff-hl. > > Anyway, I don't know if it is a problem. > > E.g., you might want to edit a diff (if you know how, which is > a significant "if") to commit a slightly different change than what the > current file contents show. Actually, not quite edit, but only to delete unneeded hunks with ‘k’. The intention is to emulate the interactive command `git add --patch` that has many keys: y - stage this hunk n - do not stage this hunk q - quit; do not stage this hunk or any of the remaining ones a - stage this hunk and all later hunks in the file d - do not stage this hunk or any of the later hunks in the file g - select a hunk to go to / - search for a hunk matching the given regex j - leave this hunk undecided, see next undecided hunk J - leave this hunk undecided, see next hunk k - leave this hunk undecided, see previous undecided hunk K - leave this hunk undecided, see previous hunk s - split the current hunk into smaller hunks e - manually edit the current hunk ? - print help Instead of these numerous keys, in Emacs it should be sufficient just to type ‘k’ (diff-hunk-kill) a few times on the output of ‘C-x v D’ in the *vc-diff* buffer (and maybe some splitting). > But then, I'm not sure you'll want the applied change to be reflected in > the file on disk too (as opposed to being saved in the commit). I probably > won't (and it would let us avoid the awkward step of seeing the stashing > operation temporarily reflected in the file contents, as well as any > possible conflicts). > > Either way, the editing of the diff that's more complex than splitting > hunks and deleting some of them will probably be very rare. So the behavior > in this scenario doesn't have to affect our choice of implementation. I had in mind a different scenario: when you have uncommitted changes in one part of the file, and receive an external patch from outside of the repo with changes in another part of the file, and need to commit it. But I admit such scenario is very rare. So if using ‘git apply --cached’ is the preferred solution, then I could finish the patch with it.