From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: master 4803fba487 1/2: 'C-x v v' on a diff buffer commits it as a patch (bug#52349) Date: Mon, 29 Aug 2022 23:36:32 +0300 Message-ID: References: <166171593185.16640.41619657947456727@vcs2.savannah.gnu.org> <20220828194533.23A6BC00889@vcs2.savannah.gnu.org> <87r10znm0y.fsf@gnus.org> <83fshfvvyn.fsf@gnu.org> <83bks3vtf5.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26131"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Cc: larsi@gnus.org, juri@jurta.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Aug 29 22:37:45 2022 Return-path: Envelope-to: ged-emacs-devel@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 1oSlVw-0006dk-T1 for ged-emacs-devel@m.gmane-mx.org; Mon, 29 Aug 2022 22:37:44 +0200 Original-Received: from localhost ([::1]:37946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSlVv-0007R8-NA for ged-emacs-devel@m.gmane-mx.org; Mon, 29 Aug 2022 16:37:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSlVE-0006hi-HS for emacs-devel@gnu.org; Mon, 29 Aug 2022 16:37:00 -0400 Original-Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:35451) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oSlVC-0001Xy-C9; Mon, 29 Aug 2022 16:37:00 -0400 Original-Received: by mail-wm1-x32c.google.com with SMTP id m17-20020a7bce11000000b003a5bedec07bso8817337wmc.0; Mon, 29 Aug 2022 13:36:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc; bh=UGsECN4EGE1RKmaF4CqfRQJo+DSJkjRzUiCQblWenSo=; b=IB2c5fNXTmYZuS4AjDzwKOdY0yvji2ItXkWRcMwZ04/reKIf/iHYsrgI+17fRUlma7 8HigQra4ncUgn5hGutCXYa8cZ6d2/5FHmV0hkexLpeB5vzUiua358Sdp17Oj8fHpddqZ +RrD/un3r9TqXOdYNHwV4u1t63H0T1MeaD5nLHuWh9nLpbqVrrS6GPBAJ/ruzWVviyNJ nEYzzNKzy7mpsxA2EkGEXTqnHcARuyMfkpsgRdVj36H3FpW4gguz7Qo6kIbUl0p1Blfl 2nNnaE0TWOtL0ekyKo6bLcrDqe9RVo0lQtZo/4UV/RWBkZk1VC4hZ0kD/HqbqXLuZonK 6y4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc; bh=UGsECN4EGE1RKmaF4CqfRQJo+DSJkjRzUiCQblWenSo=; b=hetIrmNLTuTegDO7cFPAJzS6yEsCpcDVY0cmfF+Vcni9RT4L3NvK/VgqEt1R/xB2bq cgeWrPFjJ/F6En6EN21iIjowHXx+9G6oqAUf2BXeCgcZKEZlAodMYJ/xtlWbdtwvxI33 DmY4atg6HP59sAmMZmpyqxKdhXWrVefeqS1uaZIG+ri+mRr/NdDz7XjSEltfpzavAqBW 67fVJtxNTlFVkxwhI0s7qXjZTmIuWAZO/esSPziQ1PpdlGx+YmWgxoF7E1QLyfuWO5jD nde6fZTgyrhHDm8XleWLA9dsR7DLwVG6SOWx8GLdpBQELppyQwWzdWh93RFMd1VmWju2 d4/w== X-Gm-Message-State: ACgBeo3s6CygKQmTPtIOmDe6YAKQST2NqWBuJTaFxI87HdQfLeVySm9Q uH0Vxp3pHGJBJIQJLk0DiJb9610mVOE= X-Google-Smtp-Source: AA6agR7W2jQHiXu5hWuDmSUTKzI9LWrU7kc+90IDs7RbaD1FmrB6V78IVR4aAEftJIgtmKnTEn1rXA== X-Received: by 2002:a05:600c:4e92:b0:3a5:fd90:24e3 with SMTP id f18-20020a05600c4e9200b003a5fd9024e3mr7914061wmq.59.1661805399416; Mon, 29 Aug 2022 13:36:39 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id b8-20020a5d4d88000000b002253d865715sm4769118wru.87.2022.08.29.13.36.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Aug 2022 13:36:39 -0700 (PDT) Content-Language: en-US In-Reply-To: <83bks3vtf5.fsf@gnu.org> Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=raaahh@gmail.com; helo=mail-wm1-x32c.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, GAPPY_SUBJECT=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:294312 Archived-At: On 29.08.2022 20:41, Eli Zaretskii wrote: >> Date: Mon, 29 Aug 2022 20:05:10 +0300 >> Cc: juri@jurta.org, emacs-devel@gnu.org >> From: Dmitry Gutov >> >>> Given diffs in a >>> buffer, it should be as simple as running the Patch utility via >>> shell-command-on-region, then committing the results. Git has a >>> special command for that, but we don't need a special command for >>> other VCSes, if they don't have the equivalent of "git apply". (I'm >>> guessing that "git apply" simply runs Patch under the hood.) >> >> No, 'git apply' puts the patch in a different place (index area), which >> means our implementation doesn't need to bother with moving all existing >> changes in the selected files somewhere else, then committing, and then >> restoring the previously-hidden changes. > > I don't follow, sorry. > > The implementation in vc-git.el does this, AFAICT: > > . creates a temporary file > . inserts the patch into the temporary file Note that "the patch" will usually be a subset of the current 'git diff' output. But not always (the patch can be additionally modified by hand). This feature is a replacement for the popular workflow 'git add -p; git commit', not for simply committing a patch, which is pretty easy to do already. Though the beauty of the current approach with Git is that it supports either. > . calls "git apply --cached" on the patch in the temporary file > . deletes the temporary file > > This doesn't seem to be very different from invoking Patch on the > diffs. (And using shell-command-on-region avoids the need to > explicitly create a temporary file.) 'patch < file' edits the working directory. 'git apply --cached' edits the index, keeping the files themselves unchanged. >> Personally I hope we discover some popular extension to Mercurial which >> we'll be able to use in the same way as we do Git's index area here. And >> then say job well done and keep the less-popular and outdated backends >> unsupported. > > The index thing being the problem because Git needs to have the > changes in the index before you can commit? Or is there any other > reason? Index is a solution, not the problem. The problem is other changes being present on disk. > IOW, why cannot we simply patch the files, and then run the equivalent > of vc-checkin? I suppose we could implement a scaled-down version of this feature as a fallback (the one that ensures that there are no existing changes in affected files), but I fear the difference between the backends would trip up the users. So we should start with trying to implement the "full" version first: for individual backends or (harder) in general.