From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Manuel Uberti Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Dec 2021 09:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 52349@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16388675728817 (code B ref -1); Tue, 07 Dec 2021 09:00:02 +0000 Received: (at submit) by debbugs.gnu.org; 7 Dec 2021 08:59:32 +0000 Received: from localhost ([127.0.0.1]:36337 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1muWJw-0002I9-Du for submit@debbugs.gnu.org; Tue, 07 Dec 2021 03:59:32 -0500 Received: from lists.gnu.org ([209.51.188.17]:53192) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1muWJu-0002I2-Pv for submit@debbugs.gnu.org; Tue, 07 Dec 2021 03:59:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muWJu-0007H8-7K for bug-gnu-emacs@gnu.org; Tue, 07 Dec 2021 03:59:30 -0500 Received: from [2001:888:2000:56::19] (port=20387 helo=latitanza.investici.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muWJr-0005TY-0g for bug-gnu-emacs@gnu.org; Tue, 07 Dec 2021 03:59:30 -0500 Received: from mx3.investici.org (unknown [127.0.0.1]) by latitanza.investici.org (Postfix) with ESMTP id 4J7Z3w0WTmzGp4j for ; Tue, 7 Dec 2021 08:59:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inventati.org; s=stigmate; t=1638867564; bh=8ho1PUiw3cC5crSr/NnfAsr3YDBPfQC31b59tYyfJFI=; h=To:Subject:From:Date:From; b=Z81zb+blckpcR3MmosXFHKi38yWG/+HC2fhly3VtJIpnw+CC1vMbJoC7GPsGI27q9 koESZJmKW/NQUzzFRw89YrIqcZRWK5umtN9s4pHoWVObhslLzDtjCY6qudtHRIguye EJmbg7tNBtrb+/NqAPxUbKDR0G3X8HcNvtGOYSBA= Received: from [82.94.249.234] (mx3.investici.org [82.94.249.234]) (Authenticated sender: manuel.uberti@inventati.org) by localhost (Postfix) with ESMTPSA id 4J7Z3v6s3nzGp4X for ; Tue, 7 Dec 2021 08:59:23 +0000 (UTC) From: Manuel Uberti Message-ID: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> Date: Tue, 7 Dec 2021 09:59:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2001:888:2000:56::19 (failed) Received-SPF: pass client-ip=2001:888:2000:56::19; envelope-from=manuel.uberti@inventati.org; helo=latitanza.investici.org X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) I don't know if I am missing something, but I don't think staging specific hunks from vc-git-mode or diff-mode is possible at the moment. Is adding such a capability to one (or both) of these modes worth considering? I know Magit does it, and I remember something similar in a git-gutter package. It's probably something diff-hl does as well by now (I have not checked). I feel like it'd be a nice improvement to VC, what do you think? Thank you In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.18, cairo version 1.16.0) of 2021-12-07 built on hathaway Repository revision: 9a1e87ba4486df19259abf3564a0281d8be25e64 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12009000 System Description: Ubuntu 20.04 LTS Configured using: 'configure --with-harfbuzz --with-native-compilation' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB Important settings: value of $LC_MONETARY: it_IT.UTF-8 value of $LC_NUMERIC: it_IT.UTF-8 value of $LC_TIME: it_IT.UTF-8 value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: VC dir Minor modes in effect: vc-parent-buffer: .emacs.d/*vc-dir* shell-dirtrack-mode: t electric-pair-mode: t vc-dir-git-mode: t savehist-mode: t global-so-long-mode: t global-subword-mode: t subword-mode: t windmove-mode: t winner-mode: t global-company-mode: t company-mode: t envrc-global-mode: t envrc-mode: t fido-vertical-mode: t icomplete-vertical-mode: t icomplete-mode: t fido-mode: t delete-selection-mode: t tooltip-mode: t global-eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t window-divider-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t column-number-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: /home/manuel/.emacs.d/elpa/transient-0.3.7.0.20211107.234631/transient hides /usr/local/share/emacs/29.0.50/lisp/transient Features: (shadow sort mail-extr help-fns radix-tree emacsbug sendmail tramp-cmds mm-archive message yank-media rfc822 mml mml-sec epa gnus-util rmail rmail-loaddefs mailabbrev gmm-utils mailheader mm-decode mm-bodies mm-encode mail-utils mule-util gnutls url-cache epg rfc6068 epg-config hl-line finder-inf misearch multi-isearch pkg-info url-http url-auth url-gw find-func epl network-stream puny nsm rmc cider tramp-sh cider-debug cider-browse-ns cider-repl-history pulse derived sh-script smie executable find-dired cider-mode cider-find cider-inspector cider-completion cider-profile cider-eval cider-repl cider-resolve cider-eldoc cider-test cider-stacktrace cider-doc advice cider-browse-spec cider-clojuredocs cider-overlays cider-jar arc-mode archive-mode cider-client cider-common cider-connection cider-util color cider-popup sesman-browser nrepl-client tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat shell pcomplete parse-time iso8601 ls-lisp format-spec queue nrepl-dict cider-compat spinner parseedn parseclj-parser parseclj-lex parseclj-alist flymake-kondor sesman clojure-mode align imenu smerge-mode diff vc-dir ewoc time-date noutline outline checkdoc lisp-mnt mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr dired-x dired dired-loaddefs elec-pair flymake-proc flymake compile text-property-search comint flyspell ispell goto-addr thingatpt pp vc-git diff-mode easy-mmode vc vc-dispatcher cursor-sensor server modus-operandi-theme modus-themes delight comp comp-cstr warnings cl-extra help-mode savehist so-long cap-words superword subword windmove winner company-oddmuse company-keywords company-etags etags fileloop generator xref project ring company-gtags company-dabbrev-code company-dabbrev company-files company-clang company-capf company-cmake company-semantic company-template company-bbdb company pcase envrc inheritenv ansi-color icomplete rx delsel info tex-site package browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map url-vars seq gv subr-x byte-opt bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 539597 325220) (symbols 48 27815 1) (strings 32 136565 77490) (string-bytes 1 5745034) (vectors 16 47250) (vector-slots 8 1113451 95518) (floats 8 236 658) (intervals 56 2079 129) (buffers 992 30)) -- Manuel Uberti www.manueluberti.eu From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Dec 2021 17:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Manuel Uberti Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.163889664120021 (code B ref 52349); Tue, 07 Dec 2021 17:05:01 +0000 Received: (at 52349) by debbugs.gnu.org; 7 Dec 2021 17:04:01 +0000 Received: from localhost ([127.0.0.1]:38510 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mudsn-0005Cn-AI for submit@debbugs.gnu.org; Tue, 07 Dec 2021 12:04:01 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:59345) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mudsh-0005CR-N7 for 52349@debbugs.gnu.org; Tue, 07 Dec 2021 12:03:58 -0500 Received: (Authenticated sender: juri@linkov.net) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 9BA1B4000B; Tue, 7 Dec 2021 17:03:48 +0000 (UTC) From: Juri Linkov Organization: LINKOV.NET References: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> Date: Tue, 07 Dec 2021 19:03:22 +0200 In-Reply-To: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> (Manuel Uberti via's message of "Tue, 7 Dec 2021 09:59:23 +0100") Message-ID: <86r1aogxn5.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > I don't know if I am missing something, but I don't think staging specific > hunks from vc-git-mode or diff-mode is possible at the moment. > > Is adding such a capability to one (or both) of these modes worth > considering? I know Magit does it, and I remember something similar in > a git-gutter package. It's probably something diff-hl does as well by now > (I have not checked). > > I feel like it'd be a nice improvement to VC, what do you think? I tried to do what is described in the second part of https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg00207.html Is this the same that you request here? From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Manuel Uberti Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Dec 2021 17:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.163889692820494 (code B ref 52349); Tue, 07 Dec 2021 17:09:01 +0000 Received: (at 52349) by debbugs.gnu.org; 7 Dec 2021 17:08:48 +0000 Received: from localhost ([127.0.0.1]:38514 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mudxP-0005KU-Ue for submit@debbugs.gnu.org; Tue, 07 Dec 2021 12:08:48 -0500 Received: from devianza.investici.org ([198.167.222.108]:25821) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mudxL-0005KJ-4m for 52349@debbugs.gnu.org; Tue, 07 Dec 2021 12:08:46 -0500 Received: from mx2.investici.org (unknown [127.0.0.1]) by devianza.investici.org (Postfix) with ESMTP id 4J7mwT6FQsz6xWR; Tue, 7 Dec 2021 17:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inventati.org; s=stigmate; t=1638896921; bh=ooOFHkaGw/OoDgyYxxSyjuR8JcpUXdlyByyineOIXJE=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=oAeeIVYBYlQWSu44duaFKho5uXnIu9+t4NV3uzv1EBzh2Qh3M5Mn3i7zYIHQyarNh HiTV2XDtijU1EVHhjOineiHKdold0K8mGcmh9qmG//+S5GNBq5Z9EmuBFaNtKVTLSV e3CHlK9C1cifnlJ+AffOfyDTPVi4xVIJbicsoa/I= Received: from [198.167.222.108] (mx2.investici.org [198.167.222.108]) (Authenticated sender: manuel.uberti@inventati.org) by localhost (Postfix) with ESMTPSA id 4J7mwT4xgWz6vVp; Tue, 7 Dec 2021 17:08:41 +0000 (UTC) References: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> <86r1aogxn5.fsf@mail.linkov.net> From: Manuel Uberti Message-ID: <73d90309-3e8b-f4ca-e237-f48e5d90fb31@inventati.org> Date: Tue, 7 Dec 2021 18:08:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <86r1aogxn5.fsf@mail.linkov.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Spam-Score: -0.1 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) On 07/12/21 18:03, Juri Linkov wrote: > I tried to do what is described in the second part of > https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg00207.html > Is this the same that you request here? It does look like the same approach. I was only thinking of staging specific hunks, while you suggest killing them as well, which would be just as useful I guess. My use-case is the following: I often do different changes to a file (or in a project) and it may happen that I have to stage, commit, and push just some of them, while keep working on the others. If this matches your proposal somehow, then we are saying the same thing indeed. -- Manuel Uberti www.manueluberti.eu From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Dec 2021 17:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Manuel Uberti , 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.163889709720772 (code B ref 52349); Tue, 07 Dec 2021 17:12:02 +0000 Received: (at 52349) by debbugs.gnu.org; 7 Dec 2021 17:11:37 +0000 Received: from localhost ([127.0.0.1]:38518 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mue09-0005Oy-J1 for submit@debbugs.gnu.org; Tue, 07 Dec 2021 12:11:37 -0500 Received: from mail-lf1-f49.google.com ([209.85.167.49]:38445) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mue07-0005Oi-Ku for 52349@debbugs.gnu.org; Tue, 07 Dec 2021 12:11:36 -0500 Received: by mail-lf1-f49.google.com with SMTP id bi37so35177733lfb.5 for <52349@debbugs.gnu.org>; Tue, 07 Dec 2021 09:11:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=X58rUJUSQjG2XoU7xFjhPNa8hTuTceCoXky40vNKcK0=; b=I4sdU/clUyJAKutdVZeh+Rec0NtIYpnzHgAbHrgdcxdJcomeaTj3wzMNAR+mA4Cles xfh27ZDjgvvJ3BktMs0s//wZy1oG979FFz4cr8FqPAjP1d6Py/s/Ne+/vCRHsyG6Bsis 3Wm/cpRCYyFUmZQx/eyz362IwpZFCfRN6gLNlgjRJUSCGyXAq6HN7FapQ4wcvEhxCF4Z tVrY69+7b9pZvnTftBoKtoM2MThip7UHB77zhLCMD32nz5VrHP2ce2ha45/mwa3OZRAl f7dfhJVu/s5X9xx8Mzr/S3bD/rSeR8RvMIFbGgQWJvybp6cKZEh/qXY69n4JzJxCwnNe o1Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=X58rUJUSQjG2XoU7xFjhPNa8hTuTceCoXky40vNKcK0=; b=Gto4UokE9LZimnxS0YnSBYEd7rg7wYtDtI7MFk9eQrkrtjTp1AZoJyHj2kSbERZAR4 pEgb+RseD2KzdCK8PgntPw8OqaRD//gZe4jxtGa9n5D+YA0i9KgCcz11yn00mIVA2XtL PIspSlQtE+3dMYSnCn4+wb1V7qRsklZ7A7E1z+BXS2xay6CciBIldVGhXwoFHnr0MdAW 1bYDW4Ks+dmZCb2Owijf1aQFf9tQ+3hTMxgnYbhtVLJkGhwIzQTm8Fljt2zHKLdcc/cj opPQ5I+m5SZP/lubImqzi67D5AQs4NXv5y9YpA5IUzfCjhkYaQQD4jNW1H7tBn06z/uY 2e5A== X-Gm-Message-State: AOAM532Q3Rl0U1EK+NoIwn3WYHo0hDmWOppd/bTle+0bOhkKl3W9kqn8 wB5kc3wkDD42JQjbGwt82QaJ4B91z5s= X-Google-Smtp-Source: ABdhPJzKit37rRcWTh8JZqOGrVwwcoXUdA2Lxa1g0mQ/StRj8XGKiGY4CQt0W0CZOjJB9GL/DQ0YLw== X-Received: by 2002:a05:6512:3e04:: with SMTP id i4mr43293375lfv.167.1638897089525; Tue, 07 Dec 2021 09:11:29 -0800 (PST) Received: from [192.168.0.103] ([5.18.233.185]) by smtp.googlemail.com with ESMTPSA id j21sm10458lji.88.2021.12.07.09.11.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Dec 2021 09:11:29 -0800 (PST) References: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> From: Dmitry Gutov Message-ID: <9106387a-98cf-396f-bf45-ccb04581787b@yandex.ru> Date: Tue, 7 Dec 2021 20:10:54 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.4 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) On 07.12.2021 11:59, Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > It's probably something diff-hl does as well by now (I have not checked). It does, since recently. But Juri's approach seems like it will fit VC's design better, given that we don't have a semantic way to "show all stages hunks" or commit them only (or instruct Emacs to do that). From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Dec 2021 19:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Manuel Uberti Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.1638904421818 (code B ref 52349); Tue, 07 Dec 2021 19:14:01 +0000 Received: (at 52349) by debbugs.gnu.org; 7 Dec 2021 19:13:41 +0000 Received: from localhost ([127.0.0.1]:38660 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mufuH-0000D8-BT for submit@debbugs.gnu.org; Tue, 07 Dec 2021 14:13:41 -0500 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:53533) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mufuC-0000Co-8I for 52349@debbugs.gnu.org; Tue, 07 Dec 2021 14:13:40 -0500 Received: (Authenticated sender: juri@linkov.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 9D2121C0012; Tue, 7 Dec 2021 19:13:28 +0000 (UTC) From: Juri Linkov Organization: LINKOV.NET References: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> <86r1aogxn5.fsf@mail.linkov.net> <73d90309-3e8b-f4ca-e237-f48e5d90fb31@inventati.org> Date: Tue, 07 Dec 2021 21:04:20 +0200 In-Reply-To: <73d90309-3e8b-f4ca-e237-f48e5d90fb31@inventati.org> (Manuel Uberti's message of "Tue, 7 Dec 2021 18:08:41 +0100") Message-ID: <86k0ggfd8r.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >> I tried to do what is described in the second part of >> https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg00207.html >> Is this the same that you request here? > > It does look like the same approach. I was only thinking of staging > specific hunks, while you suggest killing them as well, which would be just > as useful I guess. > > My use-case is the following: I often do different changes to a file (or in > a project) and it may happen that I have to stage, commit, and push just > some of them, while keep working on the others. If this matches your > proposal somehow, then we are saying the same thing indeed. This is exactly my use case as well: when some parts of the file are not yet ready to commit, then these hunks can be deleted from the output of 'C-x v D'. Then the remaining patch in the *vc-diff* buffer could be committed after temporarily moving all file changes into the stash. After committing the selected changes, the stash should be returned back by using `stash pop`. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Dec 2021 19:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: Manuel Uberti , 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.1638904425834 (code B ref 52349); Tue, 07 Dec 2021 19:14:01 +0000 Received: (at 52349) by debbugs.gnu.org; 7 Dec 2021 19:13:45 +0000 Received: from localhost ([127.0.0.1]:38662 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mufuK-0000DN-Ih for submit@debbugs.gnu.org; Tue, 07 Dec 2021 14:13:45 -0500 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:46269) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mufuE-0000Cr-Uw for 52349@debbugs.gnu.org; Tue, 07 Dec 2021 14:13:43 -0500 Received: (Authenticated sender: juri@linkov.net) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id D199D20009; Tue, 7 Dec 2021 19:13:31 +0000 (UTC) From: Juri Linkov Organization: LINKOV.NET References: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> <9106387a-98cf-396f-bf45-ccb04581787b@yandex.ru> Date: Tue, 07 Dec 2021 21:06:29 +0200 In-Reply-To: <9106387a-98cf-396f-bf45-ccb04581787b@yandex.ru> (Dmitry Gutov's message of "Tue, 7 Dec 2021 20:10:54 +0300") Message-ID: <864k7kfd56.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >> It's probably something diff-hl does as well by now (I have not checked). > > It does, since recently. > > But Juri's approach seems like it will fit VC's design better, given that > we don't have a semantic way to "show all stages hunks" or commit them only > (or instruct Emacs to do that). 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. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Dec 2021 20:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 52349@debbugs.gnu.org Cc: Manuel Uberti Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.16389076746298 (code B ref 52349); Tue, 07 Dec 2021 20:08:02 +0000 Received: (at 52349) by debbugs.gnu.org; 7 Dec 2021 20:07:54 +0000 Received: from localhost ([127.0.0.1]:38713 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mugkj-0001dW-Rt for submit@debbugs.gnu.org; Tue, 07 Dec 2021 15:07:54 -0500 Received: from quimby.gnus.org ([95.216.78.240]:53346) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mugki-0001dJ-NY for 52349@debbugs.gnu.org; Tue, 07 Dec 2021 15:07:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Mtzx8gw3U7ReQxXk0B10Iku/egWly49OPC2ORw5+T9I=; b=Pz/iSj6t/yXUgqf2vGcNcHUdUg uXZatYdiMAhu/y5d+NPoDiRm4NhPYnah3byO4F6jVm5avqh4EpjouPomTQQvuo+3/iv3W1IIYbkVP ZIcoU2SLuG3QHV/sAwRtYcvU/Vap/y5mVihfWgvPKLtSUFAsZa0S+6f4a6VKNdhv2w7U=; Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mugkZ-00020C-JA; Tue, 07 Dec 2021 21:07:46 +0100 From: Lars Ingebrigtsen References: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAD1BMVEXBt6OWiXOFeWVM Rjr///91XVO0AAAAAWJLR0QEj2jZUQAAAAd0SU1FB+UMBxM5NZQtoZkAAAGMSURBVDjLdZMLlsIw CEVpZwMN2YDABhT2vzf5JGkcZ+rxaHuBxyMUDuZGKGamjISmJGhiAti1tQE8woz947fQRF5FlFpj BxHkAC8xZgfKAxSB67S4YYmECTRK9QJZqb0kwVMMzgDEcQVg5aoFJ0cGBqB2Qf5JcBTABFCA74zm d0i8gwPTcyaYA1qAwlqJf2XYo7R9OCyMZTC6DdceqqG1nNdk3AP7bEIhI3fQqP7aF7CPC+on5uQk kjSbmhlECVJ3gPAsnBl+XvFM8gsxi/k8bFg+lspYAAEOFzGdoEiMPYAtjQkQGnCXHXh1Jm6HxvqM LRkZiXEzWBlM/wBJGRpAJvBwLf0iPDXIV7TAcZcah1prhecvMDoze21AFomZ3wBvYH0/qAlUWX8+ wIx3sB96+NAU8DfL/gS8taR3Ka1XclzPCYxq60e46DQofnR3S8940SNDar9vhZwuqoOPRk37AOzr L5u0LeCb2e0hcy1tlgp3ptcaeecBLu8J4FwG3aspuG/fswPJi1WpWtM3HWupy85LmzoAAAAldEVY dGRhdGU6Y3JlYXRlADIwMjEtMTItMDdUMTk6NTc6NTMrMDA6MDAHh4+sAAAAJXRFWHRkYXRlOm1v ZGlmeQAyMDIxLTEyLTA3VDE5OjU3OjUzKzAwOjAwdto3EAAAAABJRU5ErkJggg== X-Now-Playing: Japan's _Tin Drum (1)_: "Sons of Pioneers" Date: Tue, 07 Dec 2021 21:07:39 +0100 In-Reply-To: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> (Manuel Uberti via's message of "Tue, 7 Dec 2021 09:59:23 +0100") Message-ID: <87ilw0fab8.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Manuel Uberti via "Bug reports for GNU Emacs, the Swiss army knife of text editors" writes: > I feel like it'd be a nice improvement to VC, what do you think? Yes, it'd be a very welcome feature. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Manuel Uberti via "Bug reports for GNU Emacs, the Swiss army knife of text editors" writes: > I feel like it'd be a nice improvement to VC, what do you think? Yes, it'd be a very welcome feature. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Dec 2021 02:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: Manuel Uberti , 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.16389306155434 (code B ref 52349); Wed, 08 Dec 2021 02:31:02 +0000 Received: (at 52349) by debbugs.gnu.org; 8 Dec 2021 02:30:15 +0000 Received: from localhost ([127.0.0.1]:39268 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mumil-0001Pa-2u for submit@debbugs.gnu.org; Tue, 07 Dec 2021 21:30:15 -0500 Received: from mail-lf1-f49.google.com ([209.85.167.49]:45978) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mumih-0001OG-8C for 52349@debbugs.gnu.org; Tue, 07 Dec 2021 21:30:14 -0500 Received: by mail-lf1-f49.google.com with SMTP id m27so2504326lfj.12 for <52349@debbugs.gnu.org>; Tue, 07 Dec 2021 18:30:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=6dfDpCsvcJiFOW43EgpSz6QLN3CZICH8M0v5EmRFr9c=; b=ZgusflCiiFpytZXld/57+nGd7rSnjPMpdtwWk5cWi8FlOfcLgH9JVLbEwMwQHxZikp DAMx2uKUWzGpJ+e4KkPckJKC0DleXNjm2X89NFwxF3stltTMakbS4I+SZAYtTGPdVeog Z97Wv3WP39mfw+6wydSjP3AQijWpCwioiCm3jwgdfVS0W4tu0jTbUI/qQT2O+tEv/edY O3CMQrPVjLk2JTJA1/Jir2ACvzQvKaSC9l1d07f/VjwDtVoqgV+vQMJEB+w2k3sc6wYM aymtYolP1QadFQj1YbrZkxzkwPwTQ+g5yQmMIMoXEMeLemFq5HUYP0Dmmy6XQXb7iW+7 Y+Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=6dfDpCsvcJiFOW43EgpSz6QLN3CZICH8M0v5EmRFr9c=; b=SfVgFZCUn3ClNo5I6axPHPo16+TO6QaXUx9KHMk1+O/ALynHC6/VAPROrvCLumE1I5 BLw1DldRJsfiylV0+FvF2z3kI2NWyv+5Njs70aWvksZEz0KJpyGwt+rkNfdDN31qy1en pmv09NOqifdJF4JBfBSkyvkKqBhQ4OFqH7SYZ87nH1dtI16ZIxHZQqDnDby+FMrSGEkd M8LT5OIFT5+brMSKtH3QJs++dzKOVRMMzb3KVCH8W8XoyATlmqI0jRTODb6wASc1xuoK SPwWARb4/znWpprYgHcx655auv7GQMDs2w21U8RpNipCWUR4BRgf1j7as5y576dzu7IA Xz4g== X-Gm-Message-State: AOAM5319apSL1U9GSjoVda8zxzpVSZhzF+us5cjrPAcKFLQrwkqo4DZ2 R3KfX6p10fENHWFje4uifoYK5agHMCs= X-Google-Smtp-Source: ABdhPJzkET/PAr3SecQ1oWLL+acwXQvP0TTRFI4tCX9ANHIQ4YOpssMrRnYsEy0xKxplmm2CTVJWug== X-Received: by 2002:a19:c7d2:: with SMTP id x201mr44577811lff.684.1638930604936; Tue, 07 Dec 2021 18:30:04 -0800 (PST) Received: from [192.168.0.103] ([5.18.233.185]) by smtp.googlemail.com with ESMTPSA id 190sm131205ljf.4.2021.12.07.18.30.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Dec 2021 18:30:04 -0800 (PST) References: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> <9106387a-98cf-396f-bf45-ccb04581787b@yandex.ru> <864k7kfd56.fsf@mail.linkov.net> From: Dmitry Gutov Message-ID: Date: Wed, 8 Dec 2021 05:29:11 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <864k7kfd56.fsf@mail.linkov.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.4 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) On 07.12.2021 22:06, Juri Linkov wrote: > 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. 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. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks 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 X-GNU-PR-Keywords: To: Dmitry Gutov Cc: Manuel Uberti , 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.163899177516669 (code B ref 52349); Wed, 08 Dec 2021 19:30:04 +0000 Received: (at 52349) by debbugs.gnu.org; 8 Dec 2021 19:29:35 +0000 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 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 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) From: Juri Linkov Organization: LINKOV.NET References: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> <9106387a-98cf-396f-bf45-ccb04581787b@yandex.ru> <864k7kfd56.fsf@mail.linkov.net> Date: Wed, 08 Dec 2021 20:57:21 +0200 In-Reply-To: (Dmitry Gutov's message of "Wed, 8 Dec 2021 05:29:11 +0300") Message-ID: <86fsr3uen2.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >> 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. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 09 Dec 2021 23:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: Manuel Uberti , 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.163909190020797 (code B ref 52349); Thu, 09 Dec 2021 23:19:02 +0000 Received: (at 52349) by debbugs.gnu.org; 9 Dec 2021 23:18:20 +0000 Received: from localhost ([127.0.0.1]:45000 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mvSg7-0005PN-Kd for submit@debbugs.gnu.org; Thu, 09 Dec 2021 18:18:19 -0500 Received: from mail-lf1-f46.google.com ([209.85.167.46]:39737) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mvSg6-0005PA-71 for 52349@debbugs.gnu.org; Thu, 09 Dec 2021 18:18:18 -0500 Received: by mail-lf1-f46.google.com with SMTP id d10so14962192lfg.6 for <52349@debbugs.gnu.org>; Thu, 09 Dec 2021 15:18:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=MMoZVCx3kiwchafhLcazmgw9MaJWrZplZ2E5kLfIuuI=; b=Xa2nJtE6PdwfowRufeBdvcZHray0vwt6P0ijrp9pWCP+QSfz+sL7OvheNPuBvvSLId 3lp3J5DjVAwQ+0RysrkK9a2QBiTYFXuVY/VHVmR+d+F62REtOENOoDyzdY40roQi5bPv +lr61FBLOnIL81PDblBI6HO+vo2mGIjU16X8CXj8MnqRVen2MO+m2j6fFWuWBeFsCOu1 RSWoCiMldpRSlg99EMSi0rAq/VuH35sM+TFscI3bEP6cdu7HSanIv/BIw3FZ5eOmuXqW 1dEsl61qirD9ACUt8NQtT8R3nVxXDA9pBBnKvW7/I21DInwRNN8It47h3igpR9v/ewLh Tl1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=MMoZVCx3kiwchafhLcazmgw9MaJWrZplZ2E5kLfIuuI=; b=4M/mhNqstXR/27OfE1fOi3butkHNUn1gGIBCBjB1ZgD2StgIRR+ot5UF3tlOLQWDxM dFdBXccxp41BJnavAYF+b3XITbGHfLygqVcHI1w2JnNf+ExRETyHTMmcFP0MQfQ39yvg 7zYAY4GJ+mYwair3LsO7qNiPfo1SLh2a2mmX9xRh9cs8+o16Jw90FMxzOpalO1xX2Ppc EnweNs++JiVNL198abqbiplcAivsUEYUU4CqLDzOngM+XvOOHUVEtKc+e9AUjTe9Qyjs vod6xnWhr0dF3q6cY1Flm51CWWdTGKJ6kcw9/miomFTARwkQcZepynK/xv3ON4W0B6ej kovQ== X-Gm-Message-State: AOAM530TYGEtapy6LNABgyeE1RP5ugJpsp2BL+Lc447PlvnQebCXJIZE Rn5zgbz3iGn37OV7KzYNzUSJAZMTAN4= X-Google-Smtp-Source: ABdhPJy5zuMhdahnRqT/UYgFo9hZt4xK4EglWNDiShmjNs7MKT9TkZa8TbSiddSlorMx3Lv4pQ4i5Q== X-Received: by 2002:a05:6512:3213:: with SMTP id d19mr8886296lfe.519.1639091892188; Thu, 09 Dec 2021 15:18:12 -0800 (PST) Received: from [192.168.0.103] ([5.18.233.185]) by smtp.googlemail.com with ESMTPSA id n9sm133767lji.131.2021.12.09.15.18.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Dec 2021 15:18:11 -0800 (PST) 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> From: Dmitry Gutov Message-ID: <95d2d999-49ad-13c4-9f25-0935650a1e42@yandex.ru> Date: Fri, 10 Dec 2021 02:17:18 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <86fsr3uen2.fsf@mail.linkov.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.4 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) On 08.12.2021 21:57, Juri Linkov wrote: >>> 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’. Then it will probably be fine, most of the time? > 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). Yes, the commit-patch (external package) workflow. It totally sounds fine to me, though it might require some additional explanation when a random user tries to take advantage of it (Git's interactive command UI is more self-explanatory). >> 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. Couldn't you 'git apply external/patch/file/name.ext' first? > 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. I don't have a particularly strong opinion, but the approach with 'git apply --cached' followed by 'git commit' seems easier to implement and avoids changing the file contents on disk, or risking any of the stashes. So I'd try implementing it first and then see if the remaining problems are worth the trouble of doing it in a more difficult way. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 08 Feb 2022 20:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.16443505178179 (code B ref 52349); Tue, 08 Feb 2022 20:02:02 +0000 Received: (at 52349) by debbugs.gnu.org; 8 Feb 2022 20:01:57 +0000 Received: from localhost ([127.0.0.1]:48739 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHWgX-00027r-CJ for submit@debbugs.gnu.org; Tue, 08 Feb 2022 15:01:57 -0500 Received: from relay11.mail.gandi.net ([217.70.178.231]:34503) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHWgV-00027Z-44 for 52349@debbugs.gnu.org; Tue, 08 Feb 2022 15:01:56 -0500 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 55E8A100004; Tue, 8 Feb 2022 20:01:46 +0000 (UTC) From: Juri Linkov Organization: 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> Date: Tue, 08 Feb 2022 21:57:58 +0200 In-Reply-To: <95d2d999-49ad-13c4-9f25-0935650a1e42@yandex.ru> (Dmitry Gutov's message of "Fri, 10 Dec 2021 02:17:18 +0300") Message-ID: <8635ktjfll.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi Dmitry, >> So if using ‘git apply --cached’ is the preferred solution, >> then I could finish the patch with it. > > I don't have a particularly strong opinion, but the approach with 'git > apply --cached' followed by 'git commit' seems easier to implement and > avoids changing the file contents on disk, or risking any of the > stashes. So I'd try implementing it first and then see if the remaining > problems are worth the trouble of doing it in a more difficult way. This is implemented now, and I'm already using it without problems. Please review this patch: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=vc-git-checkin-from-diff.patch diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 0bf7899246..84128d40b8 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2860,6 +2860,17 @@ diff-syntax-fontify-props (nreverse props))) +;;;###autoload +(defun diff-vc-deduce-fileset () + (let ((backend (vc-responsible-backend default-directory)) + files) + (save-excursion + (goto-char (point-min)) + (while (progn (diff-file-next) (not (eobp))) + (push (diff-find-file-name nil t) files))) + (list backend (nreverse files) nil nil 'patch))) + + (defun diff--filter-substring (str) (when diff-font-lock-prettify ;; Strip the `display' properties added by diff-font-lock-prettify, diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index 5c664d58f1..5400352efe 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -753,7 +753,8 @@ vc-finish-logentry (defun vc-dispatcher-browsing () "Are we in a directory browser buffer?" (or (derived-mode-p 'vc-dir-mode) - (derived-mode-p 'dired-mode))) + (derived-mode-p 'dired-mode) + (derived-mode-p 'diff-mode))) ;; These are unused. ;; (defun vc-dispatcher-in-fileset-p (fileset) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 208cbee0e6..ddadca2084 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -942,13 +942,23 @@ vc-git-checkin ;; message. Handle also remote files. (if (eq system-type 'windows-nt) (let ((default-directory (file-name-directory file1))) - (make-nearby-temp-file "git-msg"))))) + (make-nearby-temp-file "git-msg")))) + (patch-buffer (derived-mode-p 'diff-mode))) + (when patch-buffer + (let ((patch-string (buffer-string)) + (patch-file (make-temp-file "git-patch"))) + (with-temp-file patch-file + (insert patch-string)) + (unwind-protect + (apply #'vc-git-command nil 0 patch-file + (list "apply" "--cached")) + (delete-file patch-file)))) (cl-flet ((boolean-arg-fn (argument) (lambda (value) (when (equal value "yes") (list argument))))) ;; When operating on the whole tree, better pass "-a" than ".", since "." ;; fails when we're committing a merge. - (apply #'vc-git-command nil 0 (if only files) + (apply #'vc-git-command nil 0 (if (and only (not patch-buffer)) files) (nconc (if msg-file (list "commit" "-F" (file-local-name msg-file)) (list "commit" "-m")) @@ -966,7 +976,8 @@ vc-git-checkin (write-region (car args) nil msg-file)) (setq args (cdr args))) args) - (if only (list "--only" "--") '("-a"))))) + (unless patch-buffer + (if only (list "--only" "--") '("-a")))))) (if (and msg-file (file-exists-p msg-file)) (delete-file msg-file)))) (defun vc-git-find-revision (file rev buffer) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index a6124acadd..d55cf64b3d 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1098,6 +1098,8 @@ vc-deduce-fileset-1 state-model-only-files) (let (backend) (cond + ((derived-mode-p 'diff-mode) + (diff-vc-deduce-fileset)) ((derived-mode-p 'vc-dir-mode) (vc-dir-deduce-fileset state-model-only-files)) ((derived-mode-p 'dired-mode) @@ -1114,7 +1116,8 @@ vc-deduce-fileset-1 (or (buffer-file-name vc-parent-buffer) (with-current-buffer vc-parent-buffer (or (derived-mode-p 'vc-dir-mode) - (derived-mode-p 'dired-mode))))) + (derived-mode-p 'dired-mode) + (derived-mode-p 'diff-mode))))) (progn ;FIXME: Why not `with-current-buffer'? --Stef. (set-buffer vc-parent-buffer) (vc-deduce-fileset-1 not-state-changing allow-unregistered state-model-only-files))) @@ -1230,6 +1233,7 @@ vc-next-action (error "Fileset files are missing, so cannot be operated on")) ((eq state 'ignored) (error "Fileset files are ignored by the version-control system")) + ((eq model 'patch) (vc-checkin files backend)) ((or (null state) (eq state 'unregistered)) (cond (verbose (let ((backend (vc-read-backend "Backend to register to: "))) @@ -1800,7 +1804,11 @@ vc-diff-internal (orig-diff-buffer-clone (if revert-buffer-in-progress-p (clone-buffer - (generate-new-buffer-name " *vc-diff-clone*") nil)))) + (generate-new-buffer-name " *vc-diff-clone*") nil))) + (patch-buffer (and (buffer-live-p vc-parent-buffer) + (with-current-buffer vc-parent-buffer + (derived-mode-p 'diff-mode)) + vc-parent-buffer))) ;; On MS-Windows and MS-DOS, Diff is likely to produce DOS-style ;; EOLs, which will look ugly if (car files) happens to have Unix ;; EOLs. @@ -1837,8 +1845,11 @@ vc-diff-internal (if async 'async 1) "diff" file (append (vc-switches nil 'diff) `(,(null-device))))))) (setq files (nreverse filtered)))) - (vc-call-backend (car vc-fileset) 'diff files rev1 rev2 buffer async) + (unless patch-buffer + (vc-call-backend (car vc-fileset) 'diff files rev1 rev2 buffer async)) (set-buffer buffer) + (when patch-buffer + (insert (with-current-buffer patch-buffer (buffer-string)))) ;; Make the *vc-diff* buffer read only, the diff-mode key ;; bindings are nicer for read only buffers. pcl-cvs does the ;; same thing. --=-=-=-- From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Feb 2022 01:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.164463023928889 (code B ref 52349); Sat, 12 Feb 2022 01:44:01 +0000 Received: (at 52349) by debbugs.gnu.org; 12 Feb 2022 01:43:59 +0000 Received: from localhost ([127.0.0.1]:33026 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nIhSA-0007Vt-Uu for submit@debbugs.gnu.org; Fri, 11 Feb 2022 20:43:59 -0500 Received: from mail-wr1-f54.google.com ([209.85.221.54]:38538) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nIhS9-0007Vg-Qt for 52349@debbugs.gnu.org; Fri, 11 Feb 2022 20:43:58 -0500 Received: by mail-wr1-f54.google.com with SMTP id d27so14109759wrb.5 for <52349@debbugs.gnu.org>; Fri, 11 Feb 2022 17:43:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=yfTSV7yQCbpP4/vlx3l6GzFZ7m4FuZKI/jCnk2dhYwk=; b=fAvQTid1Gq7FHLRkLEZ4x1zlNAZcCFc7Xqv1KTVFdeMXDmSEq9SCnZyrawrpbtx0iw MsRWI87T4heOUPszBrb5bhL2rvZlpudD5n4rULXLte1PaLXC8UUwNWaTBaBNKXilWoCq QU7F85Az+jukndYqpXDhEm0i97ufUC/qXgROJnxOtm4A8peYFBMOH1kNo2jqPIVmPRRd sBV6CrULSXErSqFyawhProOC+j1N5VcLJglS3U4jdfWRT09sgs13pXzclx0+8DFjIOLi gVyIUkX/gJO29fqYWcG8um7K+DazRDevJztOB7YRHN7ngM3B3Mg1MP1l9QFjARisJrfb KvHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=yfTSV7yQCbpP4/vlx3l6GzFZ7m4FuZKI/jCnk2dhYwk=; b=PyKnUa/Qdmmt8yEg/sGvs64c5FREykik58I5kNHdbrjPVv4F0valHMw9H/EKBQGpsb 9zoxbjRGDmmq1F/FNZDz7BQ+M9GVHkR6n4NQU7IKhvSmmyfdxdWkIeRHBJEBPy+0Y1hZ baDbnZUpneQntOmGDY1dRniOw3lttp5RxwwPuFGQxZ9YJn1bNjFqX5rCQZOtIJm8qjzW Effj/cn+nSGz4l9qxYW969F9zN+fBkewkJb7HxLgO75jSdWAdz+wgiHrgJwGenktsxuT e52ZTPBYP7wO1FITe8+0tTDN5OxyGykN8co/zSdqc+gXMoj8m+XjGApPQfF950i6aWFx 5PeA== X-Gm-Message-State: AOAM532+qDGq+ZOhrFtmGG8jGB9c5EVnF1yHKnWp9XN9w1Ia2NmeM0Fp fEksDeCBCBjgevj3KwIvhVw= X-Google-Smtp-Source: ABdhPJzC7Ztd7eLkjoTXZbfycBboR37SJzuNUCbw+86F4FUozqhLr4LduVXeYsC7ljWKID2eEdrGgg== X-Received: by 2002:a5d:4b8d:: with SMTP id b13mr3184709wrt.571.1644630231928; Fri, 11 Feb 2022 17:43:51 -0800 (PST) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id y14sm25264257wrd.91.2022.02.11.17.43.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Feb 2022 17:43:51 -0800 (PST) Message-ID: <36b963e4-5af7-dd9e-af92-4404541b9f4d@yandex.ru> Date: Sat, 12 Feb 2022 03:43:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-US 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> From: Dmitry Gutov In-Reply-To: <8635ktjfll.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) Hi Juri! On 08.02.2022 21:57, Juri Linkov wrote: > This is implemented now, and I'm already using it without problems. > Please review this patch: Looking good. But could you explain the case when the changes to 'vc-diff-internal' are going to be used? If those are only for log-edit-show-diff, I think it'd be better if the new logic was implemented in the new value of log-edit-diff-function, rather than having it spliced into the common code path. Would that result in a lot of code duplication? It might also be worth it to thread the 'patch-buffer' value through the backend method arguments (the actual value will be the patch string), so that vc-git-checkin gets it in the 4th argument, rather than having it call (derived-mode-p 'diff-mode) (this feels a little brittle: I suppose which buffer is current during this call might change in the future). It would also automatically weed out backends which don't support this feature, rather than having an attempt to commit from a diff buffer using Hg fail silently. But the current method is decent too, up to you. Finally, we'd should probably have at least one test in vc-tests.el which exercises the new functionality. Though I guess it might be tricky to set up. > +;;;###autoload > +(defun diff-vc-deduce-fileset () > + (let ((backend (vc-responsible-backend default-directory)) > + files) > + (save-excursion > + (goto-char (point-min)) > + (while (progn (diff-file-next) (not (eobp))) > + (push (diff-find-file-name nil t) files))) > + (list backend (nreverse files) nil nil 'patch))) > + > + Very nitpicky nitpick: please drop the extra empty lines before and after this function. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Feb 2022 19:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.16446952848852 (code B ref 52349); Sat, 12 Feb 2022 19:49:02 +0000 Received: (at 52349) by debbugs.gnu.org; 12 Feb 2022 19:48:04 +0000 Received: from localhost ([127.0.0.1]:35694 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nIyNI-0002Ig-5P for submit@debbugs.gnu.org; Sat, 12 Feb 2022 14:48:04 -0500 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:46207) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nIyNG-0002HW-Df for 52349@debbugs.gnu.org; Sat, 12 Feb 2022 14:48:03 -0500 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 45A7D60003; Sat, 12 Feb 2022 19:47:54 +0000 (UTC) From: Juri Linkov Organization: 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> Date: Sat, 12 Feb 2022 21:42:50 +0200 In-Reply-To: <36b963e4-5af7-dd9e-af92-4404541b9f4d@yandex.ru> (Dmitry Gutov's message of "Sat, 12 Feb 2022 03:43:49 +0200") Message-ID: <86v8xjx45h.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit > But could you explain the case when the changes to 'vc-diff-internal' are > going to be used? If those are only for log-edit-show-diff, I think it'd be > better if the new logic was implemented in the new value of > log-edit-diff-function, rather than having it spliced into the common code > path. Would that result in a lot of code duplication? Not much code duplication, thanks for the suggestion, the patch below sets log-edit-diff-function for log-edit-show-diff. > It might also be worth it to thread the 'patch-buffer' value through the > backend method arguments (the actual value will be the patch string), so > that vc-git-checkin gets it in the 4th argument, rather than having it call > (derived-mode-p 'diff-mode) (this feels a little brittle: I suppose which > buffer is current during this call might change in the future). It would > also automatically weed out backends which don't support this feature, > rather than having an attempt to commit from a diff buffer using Hg fail > silently. I agree that in the first version ‘(derived-mode-p 'diff-mode)’ was brittle. But changing the established API with a new argument doesn't look right. So the next version below uses the buffer-local variable ‘vc-patch-string’. In other backends such as Hg it shouldn't fail silently, but it will be just less granular, and will commit whole files instead of edited diffs. There is a new problem however. After starting vc-log-edit from *vc-diff*, and using log-edit-show-diff, it reuses the original buffer *vc-diff*. This is not a problem, because the buffer-local variable ‘vc-patch-string’ is saved in the *vc-log* buffer. But after deleting *vc-diff*, log-edit-done fails on the deleted vc-parent-buffer with Debugger entered--Lisp error: (error "Selecting deleted buffer") vc-finish-logentry() funcall-interactively(vc-finish-logentry) log-edit-done() But this is an old problem. The same error is signaled after typing ‘v’ in *vc-dir* buffer, then deleting the original *vc-dir* buffer, and trying to type ‘C-c C-c’ (log-edit-done) in the *vc-log* buffer. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=vc-patch-string.patch diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 0bf7899246..50f68bef70 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2859,6 +2859,15 @@ diff-syntax-fontify-props (forward-line 1))) (nreverse props))) +;;;###autoload +(defun diff-vc-deduce-fileset () + (let ((backend (vc-responsible-backend default-directory)) + files) + (save-excursion + (goto-char (point-min)) + (while (progn (diff-file-next) (not (eobp))) + (push (diff-find-file-name nil t) files))) + (list backend (nreverse files) nil nil 'patch))) (defun diff--filter-substring (str) (when diff-font-lock-prettify diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index 5c664d58f1..dc141fd650 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -653,9 +653,14 @@ vc-log-edit (mapcar (lambda (file) (file-relative-name file root)) ',fileset)))) - (log-edit-diff-function . vc-diff) + (log-edit-diff-function + . ,(if (buffer-local-value 'vc-patch-buffer vc-parent-buffer) + 'vc-diff-patch 'vc-diff)) (log-edit-vc-backend . ,backend) - (vc-log-fileset . ,fileset)) + (vc-log-fileset . ,fileset) + ,@(if (buffer-local-value 'vc-patch-buffer vc-parent-buffer) + `((vc-patch-string . ,(with-current-buffer vc-parent-buffer + (buffer-string)))))) nil mode) (set-buffer-modified-p nil) @@ -753,7 +758,8 @@ vc-finish-logentry (defun vc-dispatcher-browsing () "Are we in a directory browser buffer?" (or (derived-mode-p 'vc-dir-mode) - (derived-mode-p 'dired-mode))) + (derived-mode-p 'dired-mode) + (derived-mode-p 'diff-mode))) ;; These are unused. ;; (defun vc-dispatcher-in-fileset-p (fileset) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 208cbee0e6..4eb114633d 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -943,12 +943,20 @@ vc-git-checkin (if (eq system-type 'windows-nt) (let ((default-directory (file-name-directory file1))) (make-nearby-temp-file "git-msg"))))) + (when vc-patch-string + (let ((patch-file (make-temp-file "git-patch"))) + (with-temp-file patch-file + (insert vc-patch-string)) + (unwind-protect + (apply #'vc-git-command nil 0 patch-file + (list "apply" "--cached")) + (delete-file patch-file)))) (cl-flet ((boolean-arg-fn (argument) (lambda (value) (when (equal value "yes") (list argument))))) ;; When operating on the whole tree, better pass "-a" than ".", since "." ;; fails when we're committing a merge. - (apply #'vc-git-command nil 0 (if only files) + (apply #'vc-git-command nil 0 (if (and only (not vc-patch-string)) files) (nconc (if msg-file (list "commit" "-F" (file-local-name msg-file)) (list "commit" "-m")) @@ -966,7 +974,8 @@ vc-git-checkin (write-region (car args) nil msg-file)) (setq args (cdr args))) args) - (if only (list "--only" "--") '("-a"))))) + (unless vc-patch-string + (if only (list "--only" "--") '("-a")))))) (if (and msg-file (file-exists-p msg-file)) (delete-file msg-file)))) (defun vc-git-find-revision (file rev buffer) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index a6124acadd..1b30e9b671 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1102,6 +1102,8 @@ vc-deduce-fileset-1 (vc-dir-deduce-fileset state-model-only-files)) ((derived-mode-p 'dired-mode) (dired-vc-deduce-fileset state-model-only-files not-state-changing)) + ((derived-mode-p 'diff-mode) + (diff-vc-deduce-fileset)) ((setq backend (vc-backend buffer-file-name)) (if state-model-only-files (list backend (list buffer-file-name) @@ -1114,7 +1116,8 @@ vc-deduce-fileset-1 (or (buffer-file-name vc-parent-buffer) (with-current-buffer vc-parent-buffer (or (derived-mode-p 'vc-dir-mode) - (derived-mode-p 'dired-mode))))) + (derived-mode-p 'dired-mode) + (derived-mode-p 'diff-mode))))) (progn ;FIXME: Why not `with-current-buffer'? --Stef. (set-buffer vc-parent-buffer) (vc-deduce-fileset-1 not-state-changing allow-unregistered state-model-only-files))) @@ -1230,6 +1233,9 @@ vc-next-action (error "Fileset files are missing, so cannot be operated on")) ((eq state 'ignored) (error "Fileset files are ignored by the version-control system")) + ((eq model 'patch) + (setq-local vc-patch-buffer t) + (vc-checkin files backend)) ((or (null state) (eq state 'unregistered)) (cond (verbose (let ((backend (vc-read-backend "Backend to register to: "))) @@ -1779,6 +1785,24 @@ vc-diff-finish (defvar vc-diff-added-files nil "If non-nil, diff added files by comparing them to /dev/null.") +(defvar vc-patch-buffer nil) +(defvar vc-patch-string nil) + +(defun vc-diff-patch () + (let ((buffer "*vc-diff*") + (patch-string vc-patch-string)) + (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))) + (pop-to-buffer (current-buffer)) + (vc-run-delayed (vc-diff-finish (current-buffer) nil)))) + (defun vc-diff-internal (async vc-fileset rev1 rev2 &optional verbose buffer) "Report diffs between two revisions of a fileset. Output goes to the buffer BUFFER, which defaults to *vc-diff*. --=-=-=-- From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Feb 2022 01:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.164471595028066 (code B ref 52349); Sun, 13 Feb 2022 01:33:01 +0000 Received: (at 52349) by debbugs.gnu.org; 13 Feb 2022 01:32:30 +0000 Received: from localhost ([127.0.0.1]:36033 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJ3kb-0007Ic-K1 for submit@debbugs.gnu.org; Sat, 12 Feb 2022 20:32:29 -0500 Received: from mail-wr1-f43.google.com ([209.85.221.43]:46056) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJ3ka-0007IP-4b for 52349@debbugs.gnu.org; Sat, 12 Feb 2022 20:32:28 -0500 Received: by mail-wr1-f43.google.com with SMTP id p9so706175wra.12 for <52349@debbugs.gnu.org>; Sat, 12 Feb 2022 17:32:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Z4+rUrGUQzquC17QyHw93bVEagP1mz1eN6P81f7aobY=; b=YweW52HT9z9HrZpqTaaE3OIfeA88GC7uovZSi5pohFyVqzEeoDUCExTRF81GoTco2b yFIiU1f6W2O3cv8/S1MU/flCu4bq7KX9fz3849bqXn9zd7Hpe4MCJkX6Ujn7+6pFIMbB 4N83nKqOaBdTm2vqXr5P0vbPTntgK69fVEiBIpPb1Ubvf2gbmZ07ZysyD9eFB7el6hI0 +EABB/ASqMX3QBaU+l1jKzlqtfYRnCILI7Ljr8fpFueW1WYTIxnuYmOhFIMuKzwkw2MX v+V2ZdtRkXSnCFZZlUsskAY2xS2liS237cmRO9hWMxr9WSTzq/4qVwnVA4iHzWpKoBDo PApg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Z4+rUrGUQzquC17QyHw93bVEagP1mz1eN6P81f7aobY=; b=WEqk89Xx+zKWdYuKy2kKxSKM3eRYbmDRWPaNALR1aPkxzXUwgxexzMrBI+lblLy5t4 7awl65gbTTXtWB91XpNCVuC/EKoBhiWCKeigrSbB2qok+G0hBL2za/QFzjW+/mLMGJF9 jUgvyebBBH23MgWnWWttWVkvUgqE01eyshf5I3f80uCeeGfG/Zr7B/swG8PG204jwUFX BtZyJkDFGBHOz6glIdsHEulxgchDjI6nlMS1iLgtoj4tX/E6Yj3yI1Wt7Pl3+qadL1Zp 7/hldx+KyRLsUX1KPLVSw9e+K76oEZskJ95UCQwugn1TrPDwrb/szSADw+Drj+7bzcrS qwvg== X-Gm-Message-State: AOAM532OFV0m8/rUaGFOSfMgh1+Ejznv6/14i2QSeDUw9K91JN00VlRt ooTc7qy14my2C+XXvydi9c0= X-Google-Smtp-Source: ABdhPJzf5uIF93GUwHMBWTyK1axEXhKppQyHpisoEHutwza298pzpyqYLLp8DTS6BOubG8TWeF5hOQ== X-Received: by 2002:a5d:5043:: with SMTP id h3mr6150253wrt.394.1644715941806; Sat, 12 Feb 2022 17:32:21 -0800 (PST) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id az13sm4129253wrb.39.2022.02.12.17.32.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 12 Feb 2022 17:32:21 -0800 (PST) Message-ID: Date: Sun, 13 Feb 2022 03:32:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-US 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> From: Dmitry Gutov In-Reply-To: <86v8xjx45h.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On 12.02.2022 21:42, Juri Linkov wrote: >> But could you explain the case when the changes to 'vc-diff-internal' are >> going to be used? If those are only for log-edit-show-diff, I think it'd be >> better if the new logic was implemented in the new value of >> log-edit-diff-function, rather than having it spliced into the common code >> path. Would that result in a lot of code duplication? > > Not much code duplication, thanks for the suggestion, the patch below > sets log-edit-diff-function for log-edit-show-diff. Nice. >> It might also be worth it to thread the 'patch-buffer' value through the >> backend method arguments (the actual value will be the patch string), so >> that vc-git-checkin gets it in the 4th argument, rather than having it call >> (derived-mode-p 'diff-mode) (this feels a little brittle: I suppose which >> buffer is current during this call might change in the future). It would >> also automatically weed out backends which don't support this feature, >> rather than having an attempt to commit from a diff buffer using Hg fail >> silently. > > I agree that in the first version ‘(derived-mode-p 'diff-mode)’ was brittle. > But changing the established API with a new argument doesn't look right. We could make sure to call the function with the current number of arguments when a patch-buffer is not used, and with the additional one when it is used. Which would automatically force an abort when a backend does not support this feature. > So the next version below uses the buffer-local variable ‘vc-patch-string’. > In other backends such as Hg it shouldn't fail silently, but it will be > just less granular, and will commit whole files instead of edited diffs. That's not the worst approach, but it's bound to trip up some users who get used to the new feature's behavior with Git repos, and then try it with a different one that does not support this feature properly (such as Hg). Without any warning, they will see a different behavior. What do people think? Is that not a problem? > There is a new problem however. After starting vc-log-edit from *vc-diff*, > and using log-edit-show-diff, it reuses the original buffer *vc-diff*. > This is not a problem, because the buffer-local variable ‘vc-patch-string’ > is saved in the *vc-log* buffer. But after deleting *vc-diff*, log-edit-done > fails on the deleted vc-parent-buffer with > > Debugger entered--Lisp error: (error "Selecting deleted buffer") > vc-finish-logentry() > funcall-interactively(vc-finish-logentry) > log-edit-done() > > But this is an old problem. The same error is signaled > after typing ‘v’ in *vc-dir* buffer, then deleting the > original *vc-dir* buffer, and trying to type ‘C-c C-c’ > (log-edit-done) in the *vc-log* buffer. Seems like a slightly different issue, though. Speaking of myself only, I can see myself casually killing the vc-diff buffer (especially if I just displayed it with C-c C-d), but it seems less likely that I would kill the vc-dir buffer when completing the commit. I suppose 'vc-diff-patch' could use a different buffer name than "*vc-diff*" and thus avoid reusing that buffer? If it brings other problems somehow, oh well. An old bug is something we can live with. But also note that if the patch string was passed as an argument to the backend action, this problem might be avoided as well. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Feb 2022 20:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.16447835373296 (code B ref 52349); Sun, 13 Feb 2022 20:19:02 +0000 Received: (at 52349) by debbugs.gnu.org; 13 Feb 2022 20:18:57 +0000 Received: from localhost ([127.0.0.1]:38976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJLKi-0000r4-Qe for submit@debbugs.gnu.org; Sun, 13 Feb 2022 15:18:57 -0500 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:36209) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJLKg-0000qk-JA for 52349@debbugs.gnu.org; Sun, 13 Feb 2022 15:18:55 -0500 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 4D0B6240006; Sun, 13 Feb 2022 20:18:46 +0000 (UTC) From: Juri Linkov Organization: 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> Date: Sun, 13 Feb 2022 21:48:09 +0200 In-Reply-To: (Dmitry Gutov's message of "Sun, 13 Feb 2022 03:32:19 +0200") Message-ID: <86h792ttqu.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit > We could make sure to call the function with the current number of > arguments when a patch-buffer is not used, and with the additional one when > it is used. Which would automatically force an abort when a backend does > not support this feature. This is fine, so this patch does this: (if patch-string (vc-call-backend backend 'checkin files comment rev patch-string) (vc-call-backend backend 'checkin files comment rev)) Also I added the new arg ‘patch-string’ to vc-checkin and vc-start-logentry. These are not API calls, so they could use a buffer-local variables instead of args, but I'm not sure about this less important technical detail. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=vc-checkin-patch-string.patch diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 0bf7899246..50f68bef70 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2859,6 +2859,15 @@ diff-syntax-fontify-props (forward-line 1))) (nreverse props))) +;;;###autoload +(defun diff-vc-deduce-fileset () + (let ((backend (vc-responsible-backend default-directory)) + files) + (save-excursion + (goto-char (point-min)) + (while (progn (diff-file-next) (not (eobp))) + (push (diff-find-file-name nil t) files))) + (list backend (nreverse files) nil nil 'patch))) (defun diff--filter-substring (str) (when diff-font-lock-prettify diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index 5c664d58f1..d000e8eedc 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -653,15 +655,17 @@ vc-log-edit (mapcar (lambda (file) (file-relative-name file root)) ',fileset)))) - (log-edit-diff-function . vc-diff) + (log-edit-diff-function + . ,(if vc-patch-string 'vc-diff-patch 'vc-diff)) (log-edit-vc-backend . ,backend) - (vc-log-fileset . ,fileset)) + (vc-log-fileset . ,fileset) + (vc-patch-string . ,vc-patch-string)) nil mode) (set-buffer-modified-p nil) (setq buffer-file-name nil)) -(defun vc-start-logentry (files comment initial-contents msg logbuf mode action &optional after-hook backend) +(defun vc-start-logentry (files comment initial-contents msg logbuf mode action &optional after-hook backend patch-string) "Accept a comment for an operation on FILES. If COMMENT is nil, pop up a LOGBUF buffer, emit MSG, and set the action on close to ACTION. If COMMENT is a string and @@ -688,6 +692,7 @@ vc-start-logentry (setq-local vc-parent-buffer parent) (setq-local vc-parent-buffer-name (concat " from " (buffer-name vc-parent-buffer))) + (setq-local vc-patch-string patch-string) (vc-log-edit files mode backend) (make-local-variable 'vc-log-after-operation-hook) (when after-hook @@ -753,7 +758,8 @@ vc-finish-logentry (defun vc-dispatcher-browsing () "Are we in a directory browser buffer?" (or (derived-mode-p 'vc-dir-mode) - (derived-mode-p 'dired-mode))) + (derived-mode-p 'dired-mode) + (derived-mode-p 'diff-mode))) ;; These are unused. ;; (defun vc-dispatcher-in-fileset-p (fileset) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 208cbee0e6..aa8bf5ca44 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -53,7 +53,7 @@ ;; - responsible-p (file) OK ;; - receive-file (file rev) NOT NEEDED ;; - unregister (file) OK -;; * checkin (files rev comment) OK +;; * checkin (files comment rev patch-string) OK ;; * find-revision (file rev buffer) OK ;; * checkout (file &optional rev) OK ;; * revert (file &optional contents-done) OK @@ -921,7 +921,7 @@ vc-git-log-edit-mode "Major mode for editing Git log messages. It is based on `log-edit-mode', and has Git-specific extensions.") -(defun vc-git-checkin (files comment &optional _rev) +(defun vc-git-checkin (files comment &optional _rev patch-string) (let* ((file1 (or (car files) default-directory)) (root (vc-git-root file1)) (default-directory (expand-file-name root)) @@ -943,12 +943,20 @@ vc-git-checkin (if (eq system-type 'windows-nt) (let ((default-directory (file-name-directory file1))) (make-nearby-temp-file "git-msg"))))) + (when patch-string + (let ((patch-file (make-temp-file "git-patch"))) + (with-temp-file patch-file + (insert patch-string)) + (unwind-protect + (apply #'vc-git-command nil 0 patch-file + (list "apply" "--cached")) + (delete-file patch-file)))) (cl-flet ((boolean-arg-fn (argument) (lambda (value) (when (equal value "yes") (list argument))))) ;; When operating on the whole tree, better pass "-a" than ".", since "." ;; fails when we're committing a merge. - (apply #'vc-git-command nil 0 (if only files) + (apply #'vc-git-command nil 0 (if (and only (not patch-string)) files) (nconc (if msg-file (list "commit" "-F" (file-local-name msg-file)) (list "commit" "-m")) @@ -966,7 +974,8 @@ vc-git-checkin (write-region (car args) nil msg-file)) (setq args (cdr args))) args) - (if only (list "--only" "--") '("-a"))))) + (unless patch-string + (if only (list "--only" "--") '("-a")))))) (if (and msg-file (file-exists-p msg-file)) (delete-file msg-file)))) (defun vc-git-find-revision (file rev buffer) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index a6124acadd..6834de503f 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -239,7 +239,7 @@ ;; Unregister FILE from this backend. This is only needed if this ;; backend may be used as a "more local" backend for temporary editing. ;; -;; * checkin (files comment &optional rev) +;; * checkin (files comment &optional rev patch-string) ;; ;; Commit changes in FILES to this backend. COMMENT is used as a ;; check-in comment. The implementation should pass the value of @@ -1102,6 +1102,8 @@ vc-deduce-fileset-1 (vc-dir-deduce-fileset state-model-only-files)) ((derived-mode-p 'dired-mode) (dired-vc-deduce-fileset state-model-only-files not-state-changing)) + ((derived-mode-p 'diff-mode) + (diff-vc-deduce-fileset)) ((setq backend (vc-backend buffer-file-name)) (if state-model-only-files (list backend (list buffer-file-name) @@ -1114,7 +1116,8 @@ vc-deduce-fileset-1 (or (buffer-file-name vc-parent-buffer) (with-current-buffer vc-parent-buffer (or (derived-mode-p 'vc-dir-mode) - (derived-mode-p 'dired-mode))))) + (derived-mode-p 'dired-mode) + (derived-mode-p 'diff-mode))))) (progn ;FIXME: Why not `with-current-buffer'? --Stef. (set-buffer vc-parent-buffer) (vc-deduce-fileset-1 not-state-changing allow-unregistered state-model-only-files))) @@ -1230,6 +1233,8 @@ vc-next-action (error "Fileset files are missing, so cannot be operated on")) ((eq state 'ignored) (error "Fileset files are ignored by the version-control system")) + ((eq model 'patch) + (vc-checkin files backend nil nil nil (buffer-string))) ((or (null state) (eq state 'unregistered)) (cond (verbose (let ((backend (vc-read-backend "Backend to register to: "))) @@ -1615,7 +1620,7 @@ vc-steal-lock ".\n") (message "Please explain why you stole the lock. Type C-c C-c when done."))) -(defun vc-checkin (files backend &optional comment initial-contents rev) +(defun vc-checkin (files backend &optional comment initial-contents rev patch-string) "Check in FILES. COMMENT is a comment string; if omitted, a buffer is popped up to accept a comment. If INITIAL-CONTENTS is non-nil, then COMMENT is used as the initial contents of the log @@ -1643,7 +1650,9 @@ vc-checkin ;; vc-checkin-switches, but 'the' local buffer is ;; not a well-defined concept for filesets. (progn - (vc-call-backend backend 'checkin files comment rev) + (if patch-string + (vc-call-backend backend 'checkin files comment rev patch-string) + (vc-call-backend backend 'checkin files comment rev)) (mapc #'vc-delete-automatic-version-backups files)) `((vc-state . up-to-date) (vc-checkout-time . ,(file-attribute-modification-time @@ -1651,7 +1660,8 @@ vc-checkin (vc-working-revision . nil))) (message "Checking in %s...done" (vc-delistify files))) 'vc-checkin-hook - backend)) + backend + patch-string)) ;;; Additional entry points for examining version histories @@ -1779,6 +1789,23 @@ vc-diff-finish (defvar vc-diff-added-files nil "If non-nil, diff added files by comparing them to /dev/null.") +(defvar vc-patch-buffer nil) + +(defun vc-diff-patch () + (let ((buffer "*vc-diff*") + (patch-string vc-patch-string)) + (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))) + (pop-to-buffer (current-buffer)) + (vc-run-delayed (vc-diff-finish (current-buffer) nil)))) + (defun vc-diff-internal (async vc-fileset rev1 rev2 &optional verbose buffer) "Report diffs between two revisions of a fileset. Output goes to the buffer BUFFER, which defaults to *vc-diff*. --=-=-=-- From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Feb 2022 20:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.16447835373302 (code B ref 52349); Sun, 13 Feb 2022 20:19:02 +0000 Received: (at 52349) by debbugs.gnu.org; 13 Feb 2022 20:18:57 +0000 Received: from localhost ([127.0.0.1]:38978 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJLKj-0000r7-Cr for submit@debbugs.gnu.org; Sun, 13 Feb 2022 15:18:57 -0500 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:40773) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJLKh-0000qn-P6 for 52349@debbugs.gnu.org; Sun, 13 Feb 2022 15:18:56 -0500 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id AF1AC240005; Sun, 13 Feb 2022 20:18:49 +0000 (UTC) From: Juri Linkov Organization: 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> Date: Sun, 13 Feb 2022 21:56:28 +0200 In-Reply-To: (Dmitry Gutov's message of "Sun, 13 Feb 2022 03:32:19 +0200") Message-ID: <86y22esesn.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >> There is a new problem however. After starting vc-log-edit from *vc-diff*, >> and using log-edit-show-diff, it reuses the original buffer *vc-diff*. >> This is not a problem, because the buffer-local variable ‘vc-patch-string’ >> is saved in the *vc-log* buffer. But after deleting *vc-diff*, log-edit-done >> fails on the deleted vc-parent-buffer with >> Debugger entered--Lisp error: (error "Selecting deleted buffer") >> vc-finish-logentry() >> funcall-interactively(vc-finish-logentry) >> log-edit-done() >> But this is an old problem. The same error is signaled >> after typing ‘v’ in *vc-dir* buffer, then deleting the >> original *vc-dir* buffer, and trying to type ‘C-c C-c’ >> (log-edit-done) in the *vc-log* buffer. > > Seems like a slightly different issue, though. Speaking of myself only, > I can see myself casually killing the vc-diff buffer (especially if I just > displayed it with C-c C-d), but it seems less likely that I would kill the > vc-dir buffer when completing the commit. > > I suppose 'vc-diff-patch' could use a different buffer name than > "*vc-diff*" and thus avoid reusing that buffer? > > If it brings other problems somehow, oh well. An old bug is something we > can live with. Indeed, other buffer names might break user configuration. > But also note that if the patch string was passed as an argument to the > backend action, this problem might be avoided as well. I can't imagine how the problem might be avoided using an argument. The problem is in these lines in vc-finish-logentry: (pop-to-buffer vc-parent-buffer) ;; OK, do it to it (save-excursion (funcall log-operation log-fileset log-entry)) It expects to pop to the original buffer where vc-next-action was initiated. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Feb 2022 22:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.164479183525329 (code B ref 52349); Sun, 13 Feb 2022 22:38:01 +0000 Received: (at 52349) by debbugs.gnu.org; 13 Feb 2022 22:37:15 +0000 Received: from localhost ([127.0.0.1]:39111 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJNUZ-0006aT-0f for submit@debbugs.gnu.org; Sun, 13 Feb 2022 17:37:15 -0500 Received: from mail-wr1-f53.google.com ([209.85.221.53]:37455) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJNUV-0006aD-S5 for 52349@debbugs.gnu.org; Sun, 13 Feb 2022 17:37:13 -0500 Received: by mail-wr1-f53.google.com with SMTP id w11so24063516wra.4 for <52349@debbugs.gnu.org>; Sun, 13 Feb 2022 14:37:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=ITorDO8p6ancGJNnQXhPB3O6WjW3ew2vOAqEaoQ8JgM=; b=NzFPY4H9YuwVt/LUq/AIqJ58t6sPPmhk6UMH1FQ4Uj6d9LcLMsrJ/hVkjQPjY2Oet4 eGTN/5NZifmYqE9ImsONGID5UbQ2+HUm9rGrrPllIR5RBMR5Tcxe0P3jEjngLvP4PYOJ B11vy9PaSykAMSDkBAUpGCdlM8WvWxHrzJB/2P7XEtD73hQ8Sl1OdCSDzRm+x1vsTgod IWfP2CV9fGj/e29kxTJvtsB/ITHeiPm6QZxW4Aj9SyBwyVXvt55u1INrIB1VwUKx5Ial /nGporY00IksGnTCYWf/OHVYnlTyNoGJgLVj0UIrHGydKl38jeXk8CNtx1kF0Jqlj7Lc QnXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=ITorDO8p6ancGJNnQXhPB3O6WjW3ew2vOAqEaoQ8JgM=; b=h1/wZ6B6z339bmBguti/lVadevS8X669diScfBqsFhs1UiC7Rt60eCjmDnY+834rAB qEHXkuynT4pyHMTwpvA1c13/gJP5c2HoxPcwfui3huxKB7uQCiN5gsHvj498zWWxfHHF EinoFWmlvT7nXvOdktT1Elr4RYjtP/qk+bZsHf6p9so6pfW2LdSQaoe0spFJbbJok78A dojAVSmtYQGeSA5pBVDwlAJH9Y2fOMDv1SPAiwMABdN4T9yk9z1EzVuIjXCDqxCxqak8 VNPlIJNVQdk0/ahs3Vu3HyZyXO6GY8zfVZAbqm+UOf79/XbZYOeUa6aLI4W30+8oLSxO E/CA== X-Gm-Message-State: AOAM532PjOduTBTC8lRb99EgaEniIYi9jAjnrmAuPOipj4NcoGxB4/5K mWa9GmyNDpAW8HxFMYJ1Fk4= X-Google-Smtp-Source: ABdhPJxLUC1ANQHsnbG1GVZYOzXMxxTW0QUv5zwFV4Y7f6Pzz8n7gJs0z3u24WWJ/u1zIRZfcwa3xw== X-Received: by 2002:a5d:560c:: with SMTP id l12mr9297743wrv.647.1644791825849; Sun, 13 Feb 2022 14:37:05 -0800 (PST) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id az2sm15386000wmb.2.2022.02.13.14.37.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 13 Feb 2022 14:37:05 -0800 (PST) Message-ID: Date: Mon, 14 Feb 2022 00:37:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-US From: Dmitry Gutov 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> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On 13.02.2022 03:32, Dmitry Gutov wrote: >> But changing the established API with a new argument doesn't look right. > > We could make sure to call the function with the current number of > arguments when a patch-buffer is not used, and with the additional one > when it is used. Which would automatically force an abort when a backend > does not support this feature. Another solution for making sure the current backend supports the new feature is to add a new backend function. Call it 'checkin-patch' or `checkin-diff`. vc-git-checkin and vc-git-checking patch can share some implementation, so most of code duplication can be avoided. But when a backend does not support this, the user will see a more-or-less understandable error like "not supported". From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Feb 2022 22:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.164479207425731 (code B ref 52349); Sun, 13 Feb 2022 22:42:01 +0000 Received: (at 52349) by debbugs.gnu.org; 13 Feb 2022 22:41:14 +0000 Received: from localhost ([127.0.0.1]:39120 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJNYP-0006gx-PH for submit@debbugs.gnu.org; Sun, 13 Feb 2022 17:41:13 -0500 Received: from mail-wr1-f44.google.com ([209.85.221.44]:40921) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJNYO-0006gj-2S for 52349@debbugs.gnu.org; Sun, 13 Feb 2022 17:41:12 -0500 Received: by mail-wr1-f44.google.com with SMTP id j26so13221837wrb.7 for <52349@debbugs.gnu.org>; Sun, 13 Feb 2022 14:41:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=5SdEAWXji/aCOvr7k0cUMDbm9bZ+bsRhPsvT/TUaRPo=; b=dO9cfcf+V6GFIsiTm5AkKlz7VHNBvBJkLgf7tBHvbcRhG4d93idn3hKCRw5Y4YOEBU XzZs4w0J6gQ3Tt3vznRD/Fu6cnvlsSjlOp7GuafG6YbV//I+o9HGzDELuGweLeOThdhF RIGIYRtZLbZU05hNL5/JWcGLODa29McbdmnAEl7T63EDzqqTPJ7qbo8vOc6r5L+MWOMk OGumJX07nvwxGbCnexReIeOYjqrn3EbvbLjxtmfwRqknFFImT40rMXFDuoj3q/MZbQT5 5vb+f0rkxM5UysxAVwQFoiqYRu3Bf5QRfmNh3iW+IiZxElKCJ4g3LWUbAWQMiki40+3F +waQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=5SdEAWXji/aCOvr7k0cUMDbm9bZ+bsRhPsvT/TUaRPo=; b=RHmCIA8W7Irc6601IN2guYjqOqq/RjXM1n1nududOHR1BlMy+dIG21lUvxRFsQ+i0T kDjrzB8TPI++N/UEbPBhhOixhjBF77xG9d22TXMceWTTQxz1w+Jq5HOG78h6N+WfeSdU cmcxB9XDAkgbdjBBfyLU/hVUbjM0SAnz0teDb2vRWXFFxdCfe2o9CWU5vTPl0r0xuC80 gsLZqw03c2pniVZthL1hrYoT8xRFyJzy1/xwwKSGhBePGA+Ar2IHyT1s0bW/5Y6o9A57 r6lVqUnn32CgJxv21hC+0y63Lz9L6QAVkhJ7hmn3sTxtZ2+Y+ut1lYvS36a+NJQxdpRt zU8w== X-Gm-Message-State: AOAM5318ptzC6C2HGk4OR0TUi+ovScgC/BsdKTiamgJxSo5RmvoUlTlo 4CKUoNDMaC864kI173G67kk= X-Google-Smtp-Source: ABdhPJyr75O2e04BdFErnoQH2piD7NkfWiEu+Jr378VlREX4dWjvHY6tPJuBCrqHszi2/BoGCHeNVA== X-Received: by 2002:a05:6000:508:: with SMTP id a8mr9050696wrf.578.1644792066342; Sun, 13 Feb 2022 14:41:06 -0800 (PST) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id y1sm11823400wmi.36.2022.02.13.14.41.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 13 Feb 2022 14:41:06 -0800 (PST) Message-ID: <0415499a-d5c9-fabc-c8e5-34d2b3b3ffad@yandex.ru> Date: Mon, 14 Feb 2022 00:41:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-US 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> <86y22esesn.fsf@mail.linkov.net> From: Dmitry Gutov In-Reply-To: <86y22esesn.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On 13.02.2022 21:56, Juri Linkov wrote: >> I suppose 'vc-diff-patch' could use a different buffer name than >> "*vc-diff*" and thus avoid reusing that buffer? >> >> If it brings other problems somehow, oh well. An old bug is something we >> can live with. > Indeed, other buffer names might break user configuration. > >> But also note that if the patch string was passed as an argument to the >> backend action, this problem might be avoided as well. > I can't imagine how the problem might be avoided using an argument. > The problem is in these lines in vc-finish-logentry: > > (pop-to-buffer vc-parent-buffer) > ;; OK, do it to it > (save-excursion > (funcall log-operation > log-fileset > log-entry)) > > It expects to pop to the original buffer where vc-next-action was initiated. OK, I see. Then I would try the other suggested option (using a different buffer name). If you're sure it will cause problems, I'm not going to press the issue, but FWIW I don't have (or know of) any customizations that this would break. Worst case, people would end up adding an additional entry to display-buffer-alist. And maybe to some similar vars as well. We could postpone solving this problem until later anyway, perhaps when someone complains. Or either of us gets bitten by it in practice. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Feb 2022 22:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.164479272626729 (code B ref 52349); Sun, 13 Feb 2022 22:53:02 +0000 Received: (at 52349) by debbugs.gnu.org; 13 Feb 2022 22:52:06 +0000 Received: from localhost ([127.0.0.1]:39125 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJNiv-0006x3-QI for submit@debbugs.gnu.org; Sun, 13 Feb 2022 17:52:05 -0500 Received: from mail-wr1-f49.google.com ([209.85.221.49]:37725) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJNis-0006wW-Ca for 52349@debbugs.gnu.org; Sun, 13 Feb 2022 17:52:04 -0500 Received: by mail-wr1-f49.google.com with SMTP id w11so24096103wra.4 for <52349@debbugs.gnu.org>; Sun, 13 Feb 2022 14:52:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=6lfjraDxsoDK/3p9CBJncdJNSp/cHgp0XyvfMy43+Zc=; b=gZu3egz22xBow1Fs794Atoq/5rQHb/EyqL/vaI5QP7RqnefJeGNQBdCkiH1O4Dx9LQ GbEWzzPYBupHhFn0tZPqBLjHflHPsi/GNXAlqi0ganqi11auxK6m5MqhhtyG+MD0Wrus 3mXYr7GFaN6PFN3XX8OikYyeYmSLyCbpVjMhJ3f20uByewinICtdbJrrVts8W9jwuJoz CsyyWEo7CID1ueZZ5PjFAyojD3ACn8AEN7zKO5eH9pTC2Mh+tX0qTrvtW5rHMrS63mWR ofEaWgFSwOMEGgpV0DOx9yjS+VPibt8Z6hO3YurWElwcpc51GXvhX6Et62y/LPjsarLE Hg6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=6lfjraDxsoDK/3p9CBJncdJNSp/cHgp0XyvfMy43+Zc=; b=Gki35WCLBwbXM8jZrKwYyw1ZxotAeQotFco3SGlS2qhyctlKwjX3h2vLEupKluVE2K uZHywYDA3Yrsun8S1PfWSlcvz5FGM9XWy4WD3gdFMf3Fg8LP4qqo5tm6aZpoj6TEMsqI zq7xxDH/aupbndiukphikpuMP1/5UPOnMSqoz7w0FC3tBO+e09PfeP64dYN1uMLCXm1K LSMNSzKGubiLOKG4aeba5pA/fLa54QW17RYuoos3RmJkOPwPYhsKmtzNA0dUidFjv/ZH /muVmpQzAe/xDeIroNhqS9YjCAD9Bs3CUo/bJR9TgLgOk456GqkukcUesQqs03BTsu47 GjUw== X-Gm-Message-State: AOAM531CxIEpqDOK6mMZUZQII67vY+t148Iefy0G31jixrdsUZ1fBqnA 79xR6adhCdTx7BXVAHwe5yc= X-Google-Smtp-Source: ABdhPJwtP9H6oZCduntloLic47GyKWRAFS52oI+rOT+rmiWDai9/zcRjoKYMo7FQUbs2qu/QMeYeCA== X-Received: by 2002:adf:d1c7:: with SMTP id b7mr3301030wrd.683.1644792716536; Sun, 13 Feb 2022 14:51:56 -0800 (PST) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id r2sm14505290wmq.0.2022.02.13.14.51.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 13 Feb 2022 14:51:56 -0800 (PST) Message-ID: <3e3269cc-6d88-a03c-8fa4-04f6b349e553@yandex.ru> Date: Mon, 14 Feb 2022 00:51:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-US 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> <86h792ttqu.fsf@mail.linkov.net> From: Dmitry Gutov In-Reply-To: <86h792ttqu.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On 13.02.2022 21:48, Juri Linkov wrote: > This is fine, so this patch does this: > > (if patch-string > (vc-call-backend backend 'checkin files comment rev patch-string) > (vc-call-backend backend 'checkin files comment rev)) Looks good, thanks! Sorry, I haven't noticed your emails today before I wrote my own. See if you like the suggestion in there, but this patch is also fine with me. Though we might try catching the wrong-number-of-arguments error to report a friendlier explanation to the user. > Also I added the new arg ‘patch-string’ to vc-checkin and vc-start-logentry. > These are not API calls, so they could use a buffer-local variables instead > of args, but I'm not sure about this less important technical detail. Since the new args are optional, should be fine. > + (when patch-string > + (let ((patch-file (make-temp-file "git-patch"))) > + (with-temp-file patch-file > + (insert patch-string)) > + (unwind-protect > + (apply #'vc-git-command nil 0 patch-file > + (list "apply" "--cached")) > + (delete-file patch-file)))) Perhaps we should also check that there are no existing staged changes for those files, and if so, abort? This way we won't commit anything else by accident. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 21 Aug 2022 16:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166110059724345 (code B ref 52349); Sun, 21 Aug 2022 16:50:01 +0000 Received: (at 52349) by debbugs.gnu.org; 21 Aug 2022 16:49:57 +0000 Received: from localhost ([127.0.0.1]:36646 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oPo97-0006Kb-J5 for submit@debbugs.gnu.org; Sun, 21 Aug 2022 12:49:57 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:39281) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oPo92-0006KI-K8 for 52349@debbugs.gnu.org; Sun, 21 Aug 2022 12:49:55 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 0316460009; Sun, 21 Aug 2022 16:49:43 +0000 (UTC) From: Juri Linkov In-Reply-To: <0415499a-d5c9-fabc-c8e5-34d2b3b3ffad@yandex.ru> (Dmitry Gutov's message of "Mon, 14 Feb 2022 00:41:04 +0200") Organization: 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> <86y22esesn.fsf@mail.linkov.net> <0415499a-d5c9-fabc-c8e5-34d2b3b3ffad@yandex.ru> Date: Sun, 21 Aug 2022 19:07:20 +0300 Message-ID: <86fshpimib.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hi Dmitry, > We could postpone solving this problem until later anyway, perhaps when > someone complains. Or either of us gets bitten by it in practice. Sorry for the delay, I still can't find a solution, so let's postpone this problem until later. I'll prepare a new patch. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 21 Aug 2022 19:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166110888630515 (code B ref 52349); Sun, 21 Aug 2022 19:09:02 +0000 Received: (at 52349) by debbugs.gnu.org; 21 Aug 2022 19:08:06 +0000 Received: from localhost ([127.0.0.1]:36810 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oPqIn-0007w6-Jq for submit@debbugs.gnu.org; Sun, 21 Aug 2022 15:08:06 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:57623) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oPqIk-0007vY-C0 for 52349@debbugs.gnu.org; Sun, 21 Aug 2022 15:08:04 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id C1014E0004; Sun, 21 Aug 2022 19:07:54 +0000 (UTC) From: Juri Linkov In-Reply-To: (Dmitry Gutov's message of "Mon, 14 Feb 2022 00:37:03 +0200") Organization: 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> Date: Sun, 21 Aug 2022 21:53:46 +0300 Message-ID: <861qt9h1hh.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain > Another solution for making sure the current backend supports the new > feature is to add a new backend function. Call it 'checkin-patch' or > `checkin-diff`. > > vc-git-checkin and vc-git-checking patch can share some implementation, so > most of code duplication can be avoided. > > But when a backend does not support this, the user will see a more-or-less > understandable error like "not supported". So a new patch adds a new backend function 'checkin-patch': --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=diff-vc-deduce-fileset.patch diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index e4a1996c1b..5147f37e95 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2928,6 +2928,15 @@ diff-syntax-fontify-props (forward-line 1))) (nreverse props))) +;;;###autoload +(defun diff-vc-deduce-fileset () + (let ((backend (vc-responsible-backend default-directory)) + files) + (save-excursion + (goto-char (point-min)) + (while (progn (diff-file-next) (not (eobp))) + (push (diff-find-file-name nil t) files))) + (list backend (nreverse files) nil nil 'patch))) (defun diff--filter-substring (str) (when diff-font-lock-prettify diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index e2a490092b..93bcf4e976 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -624,6 +624,8 @@ vc-buffer-sync (declare-function log-edit-empty-buffer-p "log-edit" ()) +(defvar vc-patch-string) + (defun vc-log-edit (fileset mode backend) "Set up `log-edit' for use on FILE." (setq default-directory @@ -653,15 +655,17 @@ vc-log-edit (mapcar (lambda (file) (file-relative-name file root)) fileset)))) - (log-edit-diff-function . vc-diff) + (log-edit-diff-function + . ,(if vc-patch-string 'vc-diff-patch 'vc-diff)) (log-edit-vc-backend . ,backend) - (vc-log-fileset . ,fileset)) + (vc-log-fileset . ,fileset) + (vc-patch-string . ,vc-patch-string)) nil mode) (set-buffer-modified-p nil) (setq buffer-file-name nil)) -(defun vc-start-logentry (files comment initial-contents msg logbuf mode action &optional after-hook backend) +(defun vc-start-logentry (files comment initial-contents msg logbuf mode action &optional after-hook backend patch-string) "Accept a comment for an operation on FILES. If COMMENT is nil, pop up a LOGBUF buffer, emit MSG, and set the action on close to ACTION. If COMMENT is a string and @@ -688,6 +692,7 @@ vc-start-logentry (setq-local vc-parent-buffer parent) (setq-local vc-parent-buffer-name (concat " from " (buffer-name vc-parent-buffer))) + (setq-local vc-patch-string patch-string) (vc-log-edit files mode backend) (make-local-variable 'vc-log-after-operation-hook) (when after-hook @@ -753,7 +758,8 @@ vc-finish-logentry (defun vc-dispatcher-browsing () "Are we in a directory browser buffer?" (or (derived-mode-p 'vc-dir-mode) - (derived-mode-p 'dired-mode))) + (derived-mode-p 'dired-mode) + (derived-mode-p 'diff-mode))) ;; These are unused. ;; (defun vc-dispatcher-in-fileset-p (fileset) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 46a486a46c..8458b40714 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -53,7 +53,8 @@ ;; - responsible-p (file) OK ;; - receive-file (file rev) NOT NEEDED ;; - unregister (file) OK -;; * checkin (files rev comment) OK +;; * checkin (files comment rev) OK +;; - checkin-patch (patch-string comment) OK ;; * find-revision (file rev buffer) OK ;; * checkout (file &optional rev) OK ;; * revert (file &optional contents-done) OK @@ -914,6 +915,12 @@ vc-git-log-edit-mode "Major mode for editing Git log messages. It is based on `log-edit-mode', and has Git-specific extensions.") +(defvar vc-git-patch-string nil) + +(defun vc-git-checkin-patch (patch-string comment) + (let ((vc-git-patch-string patch-string)) + (vc-git-checkin nil comment nil))) + (defun vc-git-checkin (files comment &optional _rev) (let* ((file1 (or (car files) default-directory)) (root (vc-git-root file1)) @@ -936,12 +943,20 @@ vc-git-checkin (if (eq system-type 'windows-nt) (let ((default-directory (file-name-directory file1))) (make-nearby-temp-file "git-msg"))))) + (when vc-git-patch-string + (let ((patch-file (make-temp-file "git-patch"))) + (with-temp-file patch-file + (insert vc-git-patch-string)) + (unwind-protect + (apply #'vc-git-command nil 0 patch-file + (list "apply" "--cached")) + (delete-file patch-file)))) (cl-flet ((boolean-arg-fn (argument) (lambda (value) (when (equal value "yes") (list argument))))) ;; When operating on the whole tree, better pass "-a" than ".", since "." ;; fails when we're committing a merge. - (apply #'vc-git-command nil 0 (if only files) + (apply #'vc-git-command nil 0 (if (and only (not vc-git-patch-string)) files) (nconc (if msg-file (list "commit" "-F" (file-local-name msg-file)) (list "commit" "-m")) @@ -959,7 +974,8 @@ vc-git-checkin (write-region (car args) nil msg-file)) (setq args (cdr args))) args) - (if only (list "--only" "--") '("-a"))))) + (unless vc-git-patch-string + (if only (list "--only" "--") '("-a")))))) (if (and msg-file (file-exists-p msg-file)) (delete-file msg-file)))) (defun vc-git-find-revision (file rev buffer) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index b05adfb2d5..c5c9835de9 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -247,6 +247,11 @@ ;; revision argument is only supported with some older VCSes, like ;; RCS and CVS, and is otherwise silently ignored. ;; +;; - checkin-patch (patch-string comment) +;; +;; Commit a single patch PATCH-STRING to this backend, bypassing +;; the changes in filesets. COMMENT is used as a check-in comment. +;; ;; * find-revision (file rev buffer) ;; ;; Fetch revision REV of file FILE and put it into BUFFER. @@ -1102,6 +1107,8 @@ vc-deduce-fileset-1 (vc-dir-deduce-fileset state-model-only-files)) ((derived-mode-p 'dired-mode) (dired-vc-deduce-fileset state-model-only-files not-state-changing)) + ((derived-mode-p 'diff-mode) + (diff-vc-deduce-fileset)) ((setq backend (vc-backend buffer-file-name)) (if state-model-only-files (list backend (list buffer-file-name) @@ -1114,7 +1121,8 @@ vc-deduce-fileset-1 (or (buffer-file-name vc-parent-buffer) (with-current-buffer vc-parent-buffer (or (derived-mode-p 'vc-dir-mode) - (derived-mode-p 'dired-mode))))) + (derived-mode-p 'dired-mode) + (derived-mode-p 'diff-mode))))) (progn ;FIXME: Why not `with-current-buffer'? --Stef. (set-buffer vc-parent-buffer) (vc-deduce-fileset-1 not-state-changing allow-unregistered state-model-only-files))) @@ -1230,6 +1238,8 @@ vc-next-action (error "Fileset files are missing, so cannot be operated on")) ((eq state 'ignored) (error "Fileset files are ignored by the version-control system")) + ((eq model 'patch) + (vc-checkin files backend nil nil nil (buffer-string))) ((or (null state) (eq state 'unregistered)) (cond (verbose (let ((backend (vc-read-backend "Backend to register to: "))) @@ -1615,7 +1625,9 @@ vc-steal-lock ".\n") (message "Please explain why you stole the lock. Type C-c C-c when done."))) -(defun vc-checkin (files backend &optional comment initial-contents rev) +(defvar vc-patch-string nil) + +(defun vc-checkin (files backend &optional comment initial-contents rev patch-string) "Check in FILES. COMMENT is a comment string; if omitted, a buffer is popped up to accept a comment. If INITIAL-CONTENTS is non-nil, then COMMENT is used as the initial contents of the log @@ -1643,7 +1655,9 @@ vc-checkin ;; vc-checkin-switches, but 'the' local buffer is ;; not a well-defined concept for filesets. (progn - (vc-call-backend backend 'checkin files comment rev) + (if patch-string + (vc-call-backend backend 'checkin-patch patch-string comment) + (vc-call-backend backend 'checkin files comment rev)) (mapc #'vc-delete-automatic-version-backups files)) `((vc-state . up-to-date) (vc-checkout-time . ,(file-attribute-modification-time @@ -1651,7 +1665,8 @@ vc-checkin (vc-working-revision . nil))) (message "Checking in %s...done" (vc-delistify files))) 'vc-checkin-hook - backend)) + backend + patch-string)) ;;; Additional entry points for examining version histories @@ -1779,6 +1794,23 @@ vc-diff-finish (defvar vc-diff-added-files nil "If non-nil, diff added files by comparing them to /dev/null.") +(defvar vc-patch-buffer nil) + +(defun vc-diff-patch () + (let ((buffer "*vc-diff*") + (patch-string vc-patch-string)) + (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))) + (pop-to-buffer (current-buffer)) + (vc-run-delayed (vc-diff-finish (current-buffer) nil)))) + (defun vc-diff-internal (async vc-fileset rev1 rev2 &optional verbose buffer) "Report diffs between two revisions of a fileset. Output goes to the buffer BUFFER, which defaults to *vc-diff*. --=-=-= Content-Type: text/plain > Perhaps we should also check that there are no existing staged changes for > those files, and if so, abort? This way we won't commit anything else by > accident. Will do later. --=-=-=-- From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Aug 2022 02:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.16613068055424 (code B ref 52349); Wed, 24 Aug 2022 02:07:02 +0000 Received: (at 52349) by debbugs.gnu.org; 24 Aug 2022 02:06:45 +0000 Received: from localhost ([127.0.0.1]:45322 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQfn3-0001PQ-2j for submit@debbugs.gnu.org; Tue, 23 Aug 2022 22:06:45 -0400 Received: from mail-wm1-f52.google.com ([209.85.128.52]:52005) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQfn1-0001PD-HT for 52349@debbugs.gnu.org; Tue, 23 Aug 2022 22:06:43 -0400 Received: by mail-wm1-f52.google.com with SMTP id ay12so8054069wmb.1 for <52349@debbugs.gnu.org>; Tue, 23 Aug 2022 19:06:43 -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=xy7xhlSFnz/GY/C35UCYtMLdB3l6yaMSmVAdYD0/BfU=; b=hmknDGhUtebOnjSyeRfY3BXgEy7gdhVlcuWSBFbBIuILSa5eiIwepUcEkUHfz07RTh y4Vt3RbPZxaHynU4SY92n2gpLVEmWUdbBRo/O2U+63+lIV5GsQ9mFUQOUj44L1GbcKbi EIhwv7sJxx+923ajIDbxDfeSKemfA6UkRe5etuofepP0C3IhyCmclsEKA8xUV8BqqCuo R6qAl58pT7HFYw8I3pAnP3FIkhZioMGNmnVMFfyUqtj92AvdYeSPoFxxkHHQz0dfH8a1 mdiBVSXnlx7TBOdeh72W9724X6/KjQHvuB7FIRfLnFcId57QzDBoxe72y0aX7IPKyJCP ucbA== 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=xy7xhlSFnz/GY/C35UCYtMLdB3l6yaMSmVAdYD0/BfU=; b=SZNPwIpD7pVVgfyfmXtcqhlNeZeO9UTzpuih+MYKFaEI+kqXO0JMfzd/tGDD+zSSJK F2rWSWr5RD+9lXklY/hdSE90Ym6arPF8uUy8txiX1BmkCMFyBkjl6BflE8PJSEseATOv zH+kUfFoVByZc7teUPfwYeF7vhfaCoQXAU1MQfFm5crHvYI+o5/Rt72j9WldzNRznqXe Ja9guPAiVyt4quREgof9gQcT8+CDvOfN0eVP02ufFj26X+hactSB/YU3WlJatmQom1EC m5ZmTi31TrV5qMfRMTRjDDqqX/XhFB8dSBSgCSvg9NNQTdzAFKRU8onuHm5gEbdBtTaC 0Plw== X-Gm-Message-State: ACgBeo2KHORSK+QxGgKbAGQ+lv13p9vFVu3vj4jZon9oGnwzZqq/Zcxs 7VQhg+begUO6p1B9VUx3M/0= X-Google-Smtp-Source: AA6agR5toomYQN650xw1It4yf4sV9N0iqszgUrsQj3/JSoocXzSo14iZhRuh2+FfBHidQOLtVGmQyQ== X-Received: by 2002:a05:600c:22cd:b0:3a6:7b62:3778 with SMTP id 13-20020a05600c22cd00b003a67b623778mr3690316wmg.45.1661306797643; Tue, 23 Aug 2022 19:06:37 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id t63-20020a1c4642000000b003a673055e68sm202531wma.0.2022.08.23.19.06.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Aug 2022 19:06:36 -0700 (PDT) Message-ID: Date: Wed, 24 Aug 2022 05:06:34 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Content-Language: en-US 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> From: Dmitry Gutov In-Reply-To: <861qt9h1hh.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On 21.08.2022 21:53, Juri Linkov wrote: >> Another solution for making sure the current backend supports the new >> feature is to add a new backend function. Call it 'checkin-patch' or >> `checkin-diff`. >> >> vc-git-checkin and vc-git-checking patch can share some implementation, so >> most of code duplication can be avoided. >> >> But when a backend does not support this, the user will see a more-or-less >> understandable error like "not supported". > > So a new patch adds a new backend function 'checkin-patch': Looks pretty good. Thank you. >> Perhaps we should also check that there are no existing staged changes for >> those files, and if so, abort? This way we won't commit anything else by >> accident. > > Will do later. Shouldn't be too hard, if we don't try to do it eagerly. Just add a check inside (when vc-git-patch-string ...) in vc-git-checkin. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Aug 2022 18:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166136549719890 (code B ref 52349); Wed, 24 Aug 2022 18:25:01 +0000 Received: (at 52349) by debbugs.gnu.org; 24 Aug 2022 18:24:57 +0000 Received: from localhost ([127.0.0.1]:48197 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQv3g-0005Ak-SP for submit@debbugs.gnu.org; Wed, 24 Aug 2022 14:24:57 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:57797) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQv3f-0005AW-CY for 52349@debbugs.gnu.org; Wed, 24 Aug 2022 14:24:56 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id F0D4AC0006; Wed, 24 Aug 2022 18:24:47 +0000 (UTC) From: Juri Linkov In-Reply-To: (Dmitry Gutov's message of "Wed, 24 Aug 2022 05:06:34 +0300") Organization: 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> Date: Wed, 24 Aug 2022 21:20:39 +0300 Message-ID: <864jy1mrk8.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >>> Perhaps we should also check that there are no existing staged changes for >>> those files, and if so, abort? This way we won't commit anything else by >>> accident. >> Will do later. > > Shouldn't be too hard, if we don't try to do it eagerly. Just add a check > inside (when vc-git-patch-string ...) in vc-git-checkin. This uses the same command `git diff --cached --quiet` as in commit-patch that you mentioned earlier https://github.com/caldwell/commit-patch/blob/master/commit-patch#L215-L217 (but with an error message shorter than "Cowardly refusing to do anything potentially harmful":) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 8458b40714..fa09ecf472 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -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")) (let ((patch-file (make-temp-file "git-patch"))) (with-temp-file patch-file (insert vc-git-patch-string)) From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Aug 2022 20:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166137247131245 (code B ref 52349); Wed, 24 Aug 2022 20:22:01 +0000 Received: (at 52349) by debbugs.gnu.org; 24 Aug 2022 20:21:11 +0000 Received: from localhost ([127.0.0.1]:48317 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQwsB-00087t-5v for submit@debbugs.gnu.org; Wed, 24 Aug 2022 16:21:11 -0400 Received: from mail-wr1-f43.google.com ([209.85.221.43]:44640) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQws9-00087f-2o for 52349@debbugs.gnu.org; Wed, 24 Aug 2022 16:21:10 -0400 Received: by mail-wr1-f43.google.com with SMTP id u5so14311372wrt.11 for <52349@debbugs.gnu.org>; Wed, 24 Aug 2022 13:21:09 -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=dkyGSSpdDz8VuXfB6YbD0v0u+qmXLXdulWWqDmrdA9s=; b=oy/4IUWw1iPRf1XhAflP/BFyd523gVACAUie9q9y4jl+KnKNz/iif7x5vG4KEG6Vrp HAzDYVyXVsGV71pLkMsDlTsPKFSC8J1dUUu8mwxp9KZWvY9KLTPgmVDf3wkOmrgHjKKl WoTwmFTfuCzcjrrGCR1E7ZlXaQ0mTAgavPeS7/JKm3fOav0pFaYFqy8YOfJ7r1bc0bFH loo4fe/ZHvQUK8/Ms6rj4+hTbPnSRfPArtBqsF0Wi0pjOzjnBEBAkZeeE1s8aT2eZhrO y+fDpgPqqth0wukMvLRioPcjtxZ2WLoVVsRlMNYeFK4sRDwx08x5iqUynmwYaiXfi7B1 Z/bA== 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=dkyGSSpdDz8VuXfB6YbD0v0u+qmXLXdulWWqDmrdA9s=; b=VdA0GnKJTepjYJm8ri8wN8QNWARP4aeT9sZkGY5MkeOrFyq+ZCmZZiNO9Ytg9imTJu /bJTagoKuGJgURYunFVVqIYitcYbnd+uyOq4nQ6YAoM9azzOc/1t3QAIt3WqNlgTnPkg dzdHMg9hCWtrxcN5MvZZsaWDUk6r59mwWf/IheLh3itORZ6QL5iwjPtDGhJgeRrgjJ7y HoU8MjxXGl3NouTh/3+51v9+KFpOk95UBb+5wgjZxT2DgLmE+8gVgrd0bKvEdmdVg+D+ 7mNyhWsa3wsBAFTu4pF50blP0XDdbYGGAC/uqWC2mLMWKT2qbC6i+cjF02thVC7XyRVk squw== X-Gm-Message-State: ACgBeo13wkRkm6xZJwCJ4BzI5XBDYAuFmvfRkm25S4XgTjhEo/eFd6eE dXvQ1o2Z4E3B4YsPjS5Xj0w= X-Google-Smtp-Source: AA6agR7npfLfRv+FYx0TSkGyt1vp8VG47lr2kr2C2uPm56RYFxzVsXsWfbVNRIgms/raB45cMW2umA== X-Received: by 2002:a05:6000:221:b0:225:464d:b096 with SMTP id l1-20020a056000022100b00225464db096mr484326wrz.32.1661372462279; Wed, 24 Aug 2022 13:21:02 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id g13-20020adfe40d000000b0021f15514e7fsm21937991wrm.0.2022.08.24.13.21.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Aug 2022 13:21:01 -0700 (PDT) Message-ID: Date: Wed, 24 Aug 2022 23:20:59 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Content-Language: en-US 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> From: Dmitry Gutov In-Reply-To: <864jy1mrk8.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On 24.08.2022 21:20, Juri Linkov wrote: >>>> Perhaps we should also check that there are no existing staged changes for >>>> those files, and if so, abort? This way we won't commit anything else by >>>> accident. >>> Will do later. >> Shouldn't be too hard, if we don't try to do it eagerly. Just add a check >> inside (when vc-git-patch-string ...) in vc-git-checkin. > This uses the same command `git diff --cached --quiet` as in commit-patch > that you mentioned earlier > https://github.com/caldwell/commit-patch/blob/master/commit-patch#L215-L217 > (but with an error message shorter than "Cowardly refusing to do anything > potentially harmful":) > > diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el > index 8458b40714..fa09ecf472 100644 > --- a/lisp/vc/vc-git.el > +++ b/lisp/vc/vc-git.el > @@ -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? > (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. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Filipp Gunbin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 26 Aug 2022 17:12:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 52349@debbugs.gnu.org, Dmitry Gutov Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166153390814760 (code B ref 52349); Fri, 26 Aug 2022 17:12:03 +0000 Received: (at 52349) by debbugs.gnu.org; 26 Aug 2022 17:11:48 +0000 Received: from localhost ([127.0.0.1]:54469 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oRcs0-0003pz-Gf for submit@debbugs.gnu.org; Fri, 26 Aug 2022 13:11:48 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:35071) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oRcry-0003pk-GU for 52349@debbugs.gnu.org; Fri, 26 Aug 2022 13:11:47 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 5F36B320014C; Fri, 26 Aug 2022 13:11:40 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 26 Aug 2022 13:11:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1661533899; x=1661620299; bh=J+T/GeqF4k 5nPWVyrqsbEO9Z8eZ5/lp+Eqq0rAlG9r8=; b=iftCejQtuvA2Jao5lAuaFKhI4O 6v95n1P9s6pcma1Dt/8RXw4jOgEXLjUbDh+mYvOy7Dnjb44ouyLpmW1W2BwhH9Z7 sOk29fUfKGULFAgveridhTWk9kVbwArwGA4L+aUTJRRihIuAfZeF7GvdFZygNBQX 0x5d0X95FA0Nm/EbY8NxvqmA0cx3hs5B2WQaR5Nb1eQn0M/vwU1uG9n0PTfXKYzI Iq2Fzso+YcJJ6Wbfm8yYQYSN5bYSB/qGDAtI7eDSNwTrb4vamo1U2++pJE23JIem LVFf6YMHC/WwZGaTLawOZ2ChmYLOc0nPo814GB6QXHwBslC7E41OI7u26z+w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1661533899; x=1661620299; bh=J+T/GeqF4k5nPWVyrqsbEO9Z8eZ5 /lp+Eqq0rAlG9r8=; b=seetC2bQ0LpWirAufwHLrvwhmlVie9hMdxuCLRMt+MmF BxZPJCR7g5Ez5EuwX4NfTSfQJynUXseq2PIXxy5WTvbFkVEozn9M4wJubZsODgpT PhuzpFLy5LpOYVKpHWvUfup1aCQdJojQ9CjqbyPQJePAtPwpcvLx4YgfXV1Q8BpB 2FJVYal/LpOozWy47zQHUgzdj6VPlea9AB9bpZqx0hHYNhmk4Gf2RvbCfd4g134m TZerWUsSSCUVzPQcbCWYmXiL9a3CeT9Jk+IiPqIYMtpQKwm0PY5XqrRdh9rxTMq/ 52DUNUSQj3vnI+W35HU59zUITx3oUxmUwsOJYtQong== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdejhedguddtkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufgjfhgffffkgggtsehttdertddtredtnecuhfhrohhmpefhihhl ihhpphcuifhunhgsihhnuceofhhguhhnsghinhesfhgrshhtmhgrihhlrdhfmheqnecugg ftrfgrthhtvghrnhepfffhjeevieeiiedutefgheffleeiveeffeeftdekleehledufeeu ueduheevieffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepfhhguhhnsghinhesfhgrshhtmhgrihhlrdhfmh X-ME-Proxy: Feedback-ID: id48c41f1:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 26 Aug 2022 13:11:38 -0400 (EDT) From: Filipp Gunbin In-Reply-To: <861qt9h1hh.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 21 Aug 2022 21:53:46 +0300") 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> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin) Date: Fri, 26 Aug 2022 20:11:36 +0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On 21/08/2022 21:53 +0300, Juri Linkov wrote: A minor comment: > +(defun vc-diff-patch () > + (let ((buffer "*vc-diff*") > + (patch-string vc-patch-string)) > + (vc-setup-buffer buffer) > + (set-buffer buffer) vc-setup-buffer already did set-buffer? From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Aug 2022 20:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Filipp Gunbin Cc: 52349@debbugs.gnu.org, Dmitry Gutov Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166163117015181 (code B ref 52349); Sat, 27 Aug 2022 20:13:01 +0000 Received: (at 52349) by debbugs.gnu.org; 27 Aug 2022 20:12:50 +0000 Received: from localhost ([127.0.0.1]:57160 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oS2Ak-0003wn-22 for submit@debbugs.gnu.org; Sat, 27 Aug 2022 16:12:50 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:47201) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oS2Ag-0003wW-Kw for 52349@debbugs.gnu.org; Sat, 27 Aug 2022 16:12:49 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 4924A200005; Sat, 27 Aug 2022 20:12:38 +0000 (UTC) From: Juri Linkov In-Reply-To: (Filipp Gunbin's message of "Fri, 26 Aug 2022 20:11:36 +0300") Organization: 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> Date: Sat, 27 Aug 2022 22:56:30 +0300 Message-ID: <86fshhmpe9.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > A minor comment: > >> +(defun vc-diff-patch () >> + (let ((buffer "*vc-diff*") >> + (patch-string vc-patch-string)) >> + (vc-setup-buffer buffer) >> + (set-buffer buffer) > > vc-setup-buffer already did set-buffer? Thanks for noticing, will be fixed in the next version. This is because vc-diff-patch tries to duplicate code from vc-diff-internal since the same function can't be reused for vc-diff-patch. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks 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 X-GNU-PR-Keywords: To: Dmitry Gutov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166163117715200 (code B ref 52349); Sat, 27 Aug 2022 20:13:02 +0000 Received: (at 52349) by debbugs.gnu.org; 27 Aug 2022 20:12:57 +0000 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 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 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id E8AA1FF802; Sat, 27 Aug 2022 20:12:42 +0000 (UTC) From: Juri Linkov In-Reply-To: (Dmitry Gutov's message of "Wed, 24 Aug 2022 23:20:59 +0300") Organization: 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> Date: Sat, 27 Aug 2022 23:07:12 +0300 Message-ID: <86ler9labz.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= 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))))) --=-=-=-- From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 28 Aug 2022 00:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.16616472268592 (code B ref 52349); Sun, 28 Aug 2022 00:41:02 +0000 Received: (at 52349) by debbugs.gnu.org; 28 Aug 2022 00:40:26 +0000 Received: from localhost ([127.0.0.1]:57309 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oS6Lh-0002EV-RV for submit@debbugs.gnu.org; Sat, 27 Aug 2022 20:40:26 -0400 Received: from mail-wm1-f48.google.com ([209.85.128.48]:53177) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oS6Lf-0002E7-3a for 52349@debbugs.gnu.org; Sat, 27 Aug 2022 20:40:25 -0400 Received: by mail-wm1-f48.google.com with SMTP id k17so2606213wmr.2 for <52349@debbugs.gnu.org>; Sat, 27 Aug 2022 17:40:23 -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=ps5B2QUZPUo9p4tr43U49YrW5fVcK5ikiNVhFraJypI=; b=gt9hHffcGK6zMNG/97Umy/qSFc1miB+nHFaokuAqpCgjNZ8aD9mCCPdLVvWdrirR4l iewsYemifoD/+ZJ58PliiHQC7xdnJXBRn4WsksGk6FIjBQ+lCHd0QWcXE9W8ccXQaxH/ jKsdgEc7Zl9y6HhUdHIN4hsorbAN6K4UKu/GxBU+LYyWUfhMEZV0kFU2gltm8mDlMGyD RiXTf96n+UdPt1ReZKUCQSdV1bbJ/iUb1VDOgcW4OWva7h/AvJqyCKA3whw3qNV8L2Yh CY9eEoo1PWd6/Q+uqB6m9KWJnkY7RueVkpKPNAkHGjmY/yHUt+nWXHBQ/bEqBuDZb64R aolg== 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=ps5B2QUZPUo9p4tr43U49YrW5fVcK5ikiNVhFraJypI=; b=rOjPBHpBDCM2ayNH8qeIfbYikG59UmmxCtXYn5zinhzhnPhraHEQVsnmOxd/t7gVXx vFEZKrFM9yygVzgAnnaElPSTQB0CATSGIf4PPcF3lHqeMfErCKfwwTuMtYGDWDZGvUM4 hA0GpheEUPD4GdXlFMmVvnLzAmUTn2yfPe/n0j9Oo21O6SiDhTX/ADh7f0otMsmnKMeE 1Kk2JmwnlVKTjRQEE0zg9M61J85dw05u5jK8Q5t9AUFyWPpZstSr3RbifSMwVdrichzt xcb+Bj7jBXfXAlo4/4LKAyX9XiQewLuPgqjBmMAdpqj4h9uOvvjme7Bd3vr8W1VjyWzS BeiQ== X-Gm-Message-State: ACgBeo3jRjvz832Tsw82t+h6tYnH+QE6Oo2R7tfqyjD6bl4Wkai/NM0j iA7AsuBw7S0k+PKGsBzJlH4= X-Google-Smtp-Source: AA6agR5Jf3dDI+ePjy+bmpanMOzP1fjOkox/u7oK1jmwbnPdlkXldC2dLB7aK065VerdgBlDUDR5kQ== X-Received: by 2002:a05:600c:206:b0:3a5:41f1:aa23 with SMTP id 6-20020a05600c020600b003a541f1aa23mr3371031wmi.31.1661647217130; Sat, 27 Aug 2022 17:40:17 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id j18-20020a05600c191200b003a5c1e916c8sm23844102wmq.1.2022.08.27.17.40.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Aug 2022 17:40:15 -0700 (PDT) Message-ID: Date: Sun, 28 Aug 2022 03:40:13 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Content-Language: en-US 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> <86ler9labz.fsf@mail.linkov.net> From: Dmitry Gutov In-Reply-To: <86ler9labz.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On 27.08.2022 23:07, Juri Linkov wrote: >>> @@ -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: Makes perfect sense, thanks. Honestly, I think it's a long-requested advanced feature which we'd be happy to have even if there were rough edges remaining (as long as it doesn't corrupt users' files or otherwise loses changes, of course). But this seems to be coming along nicely. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 28 Aug 2022 19:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.16617160207909 (code B ref 52349); Sun, 28 Aug 2022 19:47:01 +0000 Received: (at 52349) by debbugs.gnu.org; 28 Aug 2022 19:47:00 +0000 Received: from localhost ([127.0.0.1]:59629 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSOFI-00023U-7O for submit@debbugs.gnu.org; Sun, 28 Aug 2022 15:47:00 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:35555) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSOFC-00022E-3V; Sun, 28 Aug 2022 15:46:57 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 58F4E1C0004; Sun, 28 Aug 2022 19:46:44 +0000 (UTC) From: Juri Linkov In-Reply-To: (Dmitry Gutov's message of "Sun, 28 Aug 2022 03:40:13 +0300") Organization: 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> <86ler9labz.fsf@mail.linkov.net> Date: Sun, 28 Aug 2022 22:45:51 +0300 Message-ID: <8635dgkv80.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) close 52349 29.0.50 thanks >> 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: > > Makes perfect sense, thanks. So now pushed and closed. If more changes are needed, this could be reopened or a new bug report opened. > Honestly, I think it's a long-requested advanced feature which we'd be > happy to have even if there were rough edges remaining (as long as it > doesn't corrupt users' files or otherwise loses changes, of course). But > this seems to be coming along nicely. 'vc-finish-logentry' has such FIXME: (let ((logbuf (current-buffer)) (log-operation vc-log-operation) ;; FIXME: When coming from VC-Dir, we should check that the ;; set of selected files is still equal to vc-log-fileset, ;; to avoid surprises. (log-fileset vc-log-fileset) (pop-to-buffer vc-parent-buffer) I tried to fix this, but it requires duplicating too much code from vc-next-action, including code that prepares 'ready-for-commit' list of files. I'm afraid that such check often will raise a false alarm. OTOH, maybe this check is not needed since I fixed 'C-c C-d' above to show the same diff that will be committed using vc-log-fileset, and 'C-c C-c' uses the same vc-log-fileset as well. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 28 Aug 2022 23:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.16617296986175 (code B ref 52349); Sun, 28 Aug 2022 23:35:02 +0000 Received: (at 52349) by debbugs.gnu.org; 28 Aug 2022 23:34:58 +0000 Received: from localhost ([127.0.0.1]:59736 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSRnu-0001bX-IZ for submit@debbugs.gnu.org; Sun, 28 Aug 2022 19:34:58 -0400 Received: from mail-wm1-f44.google.com ([209.85.128.44]:53804) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSRns-0001bI-7b for 52349@debbugs.gnu.org; Sun, 28 Aug 2022 19:34:56 -0400 Received: by mail-wm1-f44.google.com with SMTP id h1so3483077wmd.3 for <52349@debbugs.gnu.org>; Sun, 28 Aug 2022 16:34:56 -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=kGsNp0/hv6rLx/crt859qOouKGkmGzpUFxCpaVg7S60=; b=ZCDObY+7jBWVb4LWv9uxShPXhuhc12JMTh61ye/3zYH7eZNTUC2+uQhK6IdHCXYsxa iUbaY5JpFACGCXvOU/snbdIj3KoL2C32lhjz5NC7W5HdiGk+DERVtqPiI0WeQ/71vqkk vtWy5GCL1tFCd8bUEyIIwo3m0VaI1Xy50g5z36JbbdPNrYAJ7dUTMDIJPN7dNY5WDt3P 7w0XymFSKgKBqo/L1k3SCYaDAde8hULlXETSBes1BKDBS4sz3TLKXJXP8mHEgdEuMgYd HUMZqEKbpdS9nJEXn6a7Zhy4vIdAuCbeINTFvIwIc/2I1Vxw5uUJFFAfqkdofQpuWhz9 Y++A== 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=kGsNp0/hv6rLx/crt859qOouKGkmGzpUFxCpaVg7S60=; b=oaSilxEtAqRsKSAqH9pzuumFKnilTAUS5NOnO2oXD7aArb1kWUJu0y5s02IwXqobBe Fqm9hg2kktyGpiB4vdTXS/SPbolA83go4A3qnKn+AJxZEXkcblKYhCdmKYt8u1s+N+Ih R2i5YcKwdQqy7CbVYBDkuXBu/Y7B+mQhpzV8/ip5vIUFptaMcJR+OVcavu/jIQgDofN+ 7vh2PBLq4TglPtGsd+i3ZaU8llOXgRKqN6W1Eb3tAd5dpjaFp20DQ4YiLfxGs5Xgl5Id BxYWLVI1Ys7DNuIF03ETNtQeMlwjetNY/GBRMfi5TO1UfkRhldPqlIbwRk5/mug+byDi qaVA== X-Gm-Message-State: ACgBeo2dIHSop48sroE/L9tsvs2pZ3ZgbVfsk/IHOTtZfQc5kX/9GOG4 KC/Ep9IOIFvt7qiMR51CLxs= X-Google-Smtp-Source: AA6agR42uRWnLx35fUIam+gDvVlofKvqx7pBasP7SILtDeKFqYzxluvSFnAVQVYDUEqiFcIjBYGxdQ== X-Received: by 2002:a05:600c:1c8d:b0:3a6:8ef:f6c0 with SMTP id k13-20020a05600c1c8d00b003a608eff6c0mr5230362wms.23.1661729690232; Sun, 28 Aug 2022 16:34:50 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id c191-20020a1c35c8000000b003a608d69a64sm7067646wma.21.2022.08.28.16.34.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Aug 2022 16:34:49 -0700 (PDT) Message-ID: <310d5a9d-fbe4-4fd1-dcd0-34cf08388771@yandex.ru> Date: Mon, 29 Aug 2022 02:34:46 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Content-Language: en-US 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> <86ler9labz.fsf@mail.linkov.net> <8635dgkv80.fsf@mail.linkov.net> From: Dmitry Gutov In-Reply-To: <8635dgkv80.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On 28.08.2022 22:45, Juri Linkov wrote: > close 52349 29.0.50 > thanks > >>> 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: >> >> Makes perfect sense, thanks. > > So now pushed and closed. If more changes are needed, > this could be reopened or a new bug report opened. Seems to be working well. Thank you! >> Honestly, I think it's a long-requested advanced feature which we'd be >> happy to have even if there were rough edges remaining (as long as it >> doesn't corrupt users' files or otherwise loses changes, of course). But >> this seems to be coming along nicely. > > 'vc-finish-logentry' has such FIXME: > > (let ((logbuf (current-buffer)) > (log-operation vc-log-operation) > ;; FIXME: When coming from VC-Dir, we should check that the > ;; set of selected files is still equal to vc-log-fileset, > ;; to avoid surprises. > (log-fileset vc-log-fileset) > (pop-to-buffer vc-parent-buffer) > > I tried to fix this, but it requires duplicating too much code > from vc-next-action, including code that prepares 'ready-for-commit' > list of files. I'm afraid that such check often will raise > a false alarm. > > OTOH, maybe this check is not needed since I fixed 'C-c C-d' above > to show the same diff that will be committed using vc-log-fileset, > and 'C-c C-c' uses the same vc-log-fileset as well. Hopefully, yes. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Sep 2022 19:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166266591116309 (code B ref 52349); Thu, 08 Sep 2022 19:39:02 +0000 Received: (at 52349) by debbugs.gnu.org; 8 Sep 2022 19:38:31 +0000 Received: from localhost ([127.0.0.1]:60127 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oWNM6-0004Ey-S9 for submit@debbugs.gnu.org; Thu, 08 Sep 2022 15:38:31 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:39225) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oWNM4-0004Eh-Cc for 52349@debbugs.gnu.org; Thu, 08 Sep 2022 15:38:29 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id F393D240002; Thu, 8 Sep 2022 19:38:20 +0000 (UTC) From: Juri Linkov In-Reply-To: (Dmitry Gutov's message of "Wed, 24 Aug 2022 23:20:59 +0300") Organization: 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> Date: Thu, 08 Sep 2022 22:29:29 +0300 Message-ID: <86fsh1ll5y.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >>>>> Perhaps we should also check that there are no existing staged changes for >>>>> those files, and if so, abort? This way we won't commit anything else by >>>>> accident. >>>> Will do later. >>> Shouldn't be too hard, if we don't try to do it eagerly. Just add a check >>> inside (when vc-git-patch-string ...) in vc-git-checkin. >> + (unless (eq (vc-git-command nil t nil "diff" "--cached" "--quiet") 0) >> + (error "Index not empty")) > > user-error, maybe? Oh, it has a sad shortcoming: this feature can't be used when a new file is added with 'C-x v v' since new files get added directly to the index, and checking for the empty index raises the error for the whole changeset with modified old files and new files. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Sep 2022 22:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov , Dmitry Gutov , 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.16626773352685 (code B ref 52349); Thu, 08 Sep 2022 22:49:01 +0000 Received: (at 52349) by debbugs.gnu.org; 8 Sep 2022 22:48:55 +0000 Received: from localhost ([127.0.0.1]:60452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oWQKN-0000hE-12 for submit@debbugs.gnu.org; Thu, 08 Sep 2022 18:48:55 -0400 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:56463) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oWQKK-0000gy-Oz for 52349@debbugs.gnu.org; Thu, 08 Sep 2022 18:48:54 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id CBE56320069B; Thu, 8 Sep 2022 18:48:44 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 08 Sep 2022 18:48:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1662677324; x=1662763724; bh=XVBMlt0p1I C7lUMXHIzGO9hxvMkQz4jVXv9QHpRKZug=; b=kuVMRpW5uKvEYjAZxVwfZdm06c NihKev8nWiVs1/L55+srbdCuuo8rTXz5KV5sFP91EFeDNnC8jCVdCjc9J8YEFyf5 YkXq0sHVcuiwpx5Xy4rW5V3JtTXTDeg/7pwRyP3uzOUnexQTIj2WxHwa9cuT8pxt p+Pl3BeBsQlWl6xNduWC38cH9nz2+Q+0cHmhmy4Dolf+c/dHgTw3A5ngv3oDbW3R 9wUlcWscG4XBM7wcjYKaMKzsLezKI+VYmc13HQlcwfxyPAXuKz5XHuAilwmqgtnL gspkAKNopWiTYNUW1KxJGa0MHd3VC710ygNqAXNi1BHYxr/mFrOTaZAuTFWg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1662677324; x=1662763724; bh=XVBMlt0p1IC7lUMXHIzGO9hxvMkQ z4jVXv9QHpRKZug=; b=fxEGVHQfgpQjGvia28UAQlBl8KSFykuXa/rP8SluvUPR tHEmsQnVaAnncrko4pL29GZf7z9sFv1+E63XN3iOEeRN4SQZ5sjFRNdCpw9CUihS jrO65bo+SJm1+D5swjavrpwcMIOJ3MFLF+80dzfd37YDNxSM2mG1rP6XfBJZu/hC rD1ROPHMJh+5d/nG0EeYL7SYUqsXw58rmpmPRP1DJqpkxzyc+tJFj/a34/IbNpyO yvUTuGw8s0xjD18lKK0aQNdId/7rRHjX5uVFipiW3N3v1BweccHTbfKKqrmIfKRK zCMrhz/LgU2X6KVcTlbcYc+qtecr6W6Vm7vjvubMow== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedtgedgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufgjfhffkfgfgggtsehttddttddtredtnecuhfhrohhmpefuvggrnhcu hghhihhtthhonhcuoehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvgeqne cuggftrfgrthhtvghrnhepffeutedtfedvtdetvefgueefjefggedugfefuddtgeefteek heduvdefjeejieefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgv X-ME-Proxy: Feedback-ID: i23c04076:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 8 Sep 2022 18:48:43 -0400 (EDT) Received: by melete.silentflame.com (Postfix, from userid 1000) id 77B587EAF02; Thu, 8 Sep 2022 15:48:42 -0700 (MST) From: Sean Whitton In-Reply-To: <86fsh1ll5y.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 08 Sep 2022 22:29:29 +0300") 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> <86fsh1ll5y.fsf@mail.linkov.net> Date: Thu, 08 Sep 2022 15:48:42 -0700 Message-ID: <87edwlo52t.fsf@melete.silentflame.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hello, On Thu 08 Sep 2022 at 10:29PM +03, Juri Linkov wrote: >>>>>> Perhaps we should also check that there are no existing staged changes for >>>>>> those files, and if so, abort? This way we won't commit anything else by >>>>>> accident. >>>>> Will do later. >>>> Shouldn't be too hard, if we don't try to do it eagerly. Just add a check >>>> inside (when vc-git-patch-string ...) in vc-git-checkin. >>> + (unless (eq (vc-git-command nil t nil "diff" "--cached" "--quiet") 0) >>> + (error "Index not empty")) >> >> user-error, maybe? > > Oh, it has a sad shortcoming: this feature can't be used when a new file > is added with 'C-x v v' since new files get added directly to the index, > and checking for the empty index raises the error for the whole changeset > with modified old files and new files. VC is a bit strange with adding and deleting files with Git -- doing so stages the additions or deletions, whereas in every other case VC doesn't use the staging area at all, except as an implementation detail when actually committing. So when you add or delete files you end up in a sort of transient state that you aren't otherwise in. What I've been doing is immediately committing any additions or deletions and then preparing --amend commits with the changes to existing files, using your new feature. Would it be too disruptive to make "registering" a new file with Git a no-op, and then require the user to commit it by going to VC Dir and marking it? That's the only alternative I can think of, given that it's common to have lots of untracked, unignored files around you don't intend ever to commit. -- Sean Whitton From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Sep 2022 01:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton , Juri Linkov , 52349@debbugs.gnu.org Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166277380912620 (code B ref 52349); Sat, 10 Sep 2022 01:37:01 +0000 Received: (at 52349) by debbugs.gnu.org; 10 Sep 2022 01:36:49 +0000 Received: from localhost ([127.0.0.1]:35997 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oWpQP-0003HU-CL for submit@debbugs.gnu.org; Fri, 09 Sep 2022 21:36:49 -0400 Received: from mail-wr1-f45.google.com ([209.85.221.45]:46817) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oWpQJ-0003HB-Iu for 52349@debbugs.gnu.org; Fri, 09 Sep 2022 21:36:48 -0400 Received: by mail-wr1-f45.google.com with SMTP id e20so5848984wri.13 for <52349@debbugs.gnu.org>; Fri, 09 Sep 2022 18:36:43 -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:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date; bh=a/+dPsSQz8957XUMlYzRaUzS6rhmMO9oy0bJ2nfbOaI=; b=aU4DhRgLZ8gLLX2Fwdf1NycM9PUsiFJ8PLl/58c+MEnSVF/Z6LtVBRoLPimDjTWaSZ oKkTL0JBNSVFRXN1ZcipPTbNPz30Mld+FRmxdpcr/qL/NuZCLNRHpexVm44EJISqwZOn 1aDZtjjO1O3CVoiIujPIimUA9LfebaT9TsiThZs+dZFnzvz+ew2yWezNp6ZvzFrCN+WH uhriGvgh5bL/9SjnhQ8801IBAgGvlIAYIsJFJze4Fd+XNNnW3iYA9yFEmLZPd+Oa8PX4 k1114Bz9pBMc4nfTQD5lqm7fA07F/RgJ9qLF4twnYLGPQXoP0Bj3cExcA/1PXmUR/4HZ C5ug== 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:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date; bh=a/+dPsSQz8957XUMlYzRaUzS6rhmMO9oy0bJ2nfbOaI=; b=beU4669QwBjq0GUHsRZu9+gCmxK+QkAHxWTLWNqE7Sxh60J0u6Xc1QmnibCJfLC20V cEyXgzJ+5g3yGVro1LiC4ftXguh2ZbS7g48EO9l3SjAwpSvh1O1eewOcoIC3Kac3c2Pm mFHF3v2XkfZJf1OVSI1uqB64NWD8CZwe+c68haMXfXWzyEPuO0saqtELO2B9oD8fh3lw uft38kGKX2D8Pd59vj9HtI/qqbmRwCjPQnGROouGFb0e4ucXYGXa26DjicJ3tBp1XkqS pxYpEZWOnSRNLAqCOMaaXdd/0imP09f9NTl9im17af2C8nv7A0GiP7cMY4hNButQFhSl mAWw== X-Gm-Message-State: ACgBeo1wMtsFfOgroGOWsmwJlS4NNC/hgoUH/G3gBlrd3OkXZeMxscEO A/EAjrySdwqr9dLiXjNWJDs= X-Google-Smtp-Source: AA6agR5DQ2M1+sN4vl7uhdQbS8g/891gUozIKO12levUzrOU5Em5EMYgRGDDSEoO/uT7O0MABCBhJg== X-Received: by 2002:a5d:47c3:0:b0:22a:2e9f:b839 with SMTP id o3-20020a5d47c3000000b0022a2e9fb839mr6345969wrc.72.1662773797563; Fri, 09 Sep 2022 18:36:37 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id d7-20020a5d5387000000b00228d52b935asm1643688wrv.71.2022.09.09.18.36.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Sep 2022 18:36:37 -0700 (PDT) Message-ID: Date: Sat, 10 Sep 2022 04:36:35 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US 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> <86fsh1ll5y.fsf@mail.linkov.net> <87edwlo52t.fsf@melete.silentflame.com> From: Dmitry Gutov In-Reply-To: <87edwlo52t.fsf@melete.silentflame.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On 09.09.2022 01:48, Sean Whitton wrote: > Would it be too disruptive to make "registering" a new file with Git a > no-op, and then require the user to commit it by going to VC Dir and > marking it? That's the only alternative I can think of, given that it's > common to have lots of untracked, unignored files around you don't > intend ever to commit. I suppose we could use a more complex check in Git's case: if the diff is non-empty, check that it doesn't intersect with the diff we want to apply, or where it does, the contents are exactly the same. It's more complex than the existing one-liner, though. The commit-and-amend thick is the first that came to my mind too, but the above would be more flexible, I guess. And as for dropping the "registering" step in Git, I suppose that might speed up the overall workflow for some people (myself included, probably), but it still wouldn't allow you to check in new files together with a partial diff in existing one. I think. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 11 Sep 2022 15:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: 52349@debbugs.gnu.org, Sean Whitton Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166290910911113 (code B ref 52349); Sun, 11 Sep 2022 15:12:01 +0000 Received: (at 52349) by debbugs.gnu.org; 11 Sep 2022 15:11:49 +0000 Received: from localhost ([127.0.0.1]:43178 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oXOcf-0002tB-5P for submit@debbugs.gnu.org; Sun, 11 Sep 2022 11:11:49 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:49299) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oXOcd-0002sr-3F for 52349@debbugs.gnu.org; Sun, 11 Sep 2022 11:11:47 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 315BDE0005; Sun, 11 Sep 2022 15:11:36 +0000 (UTC) From: Juri Linkov In-Reply-To: (Dmitry Gutov's message of "Sat, 10 Sep 2022 04:36:35 +0300") Organization: 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> <86fsh1ll5y.fsf@mail.linkov.net> <87edwlo52t.fsf@melete.silentflame.com> Date: Sun, 11 Sep 2022 18:05:20 +0300 Message-ID: <868rmqypjz.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain >> Would it be too disruptive to make "registering" a new file with Git a >> no-op, and then require the user to commit it by going to VC Dir and >> marking it? That's the only alternative I can think of, given that it's >> common to have lots of untracked, unignored files around you don't >> intend ever to commit. > > I suppose we could use a more complex check in Git's case: if the diff is > non-empty, check that it doesn't intersect with the diff we want to apply, > or where it does, the contents are exactly the same. It's more complex than > the existing one-liner, though. Maybe like this? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=vc-git-checkin-diff-cached.patch diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 2941cc75be..792981b142 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1018,7 +1018,20 @@ vc-git-checkin (make-nearby-temp-file "git-msg"))))) (when vc-git-patch-string (unless (zerop (vc-git-command nil t nil "diff" "--cached" "--quiet")) - (user-error "Index not empty")) + (with-temp-buffer + (vc-git-command (current-buffer) t nil "diff" "--cached") + (goto-char (point-min)) + (let ((pos (point)) file-diff) + (forward-line 1) + (while (not (eobp)) + (search-forward "diff --git" nil 'move) + (move-beginning-of-line 1) + (setq file-diff (buffer-substring pos (point))) + (if (string-search file-diff vc-git-patch-string) + (setq vc-git-patch-string + (string-replace file-diff "" vc-git-patch-string)) + (user-error "Index not empty")) + (setq pos (point)))))) (let ((patch-file (make-temp-file "git-patch"))) (with-temp-file patch-file (insert vc-git-patch-string)) --=-=-=-- From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 11 Sep 2022 21:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 52349@debbugs.gnu.org, Sean Whitton Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.16629334785101 (code B ref 52349); Sun, 11 Sep 2022 21:58:01 +0000 Received: (at 52349) by debbugs.gnu.org; 11 Sep 2022 21:57:58 +0000 Received: from localhost ([127.0.0.1]:43712 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oXUxh-0001KC-PX for submit@debbugs.gnu.org; Sun, 11 Sep 2022 17:57:58 -0400 Received: from mail-wm1-f50.google.com ([209.85.128.50]:41934) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oXUxf-0001Jx-1A for 52349@debbugs.gnu.org; Sun, 11 Sep 2022 17:57:56 -0400 Received: by mail-wm1-f50.google.com with SMTP id az24-20020a05600c601800b003a842e4983cso5992081wmb.0 for <52349@debbugs.gnu.org>; Sun, 11 Sep 2022 14:57:54 -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:subject:date; bh=1PqA7OYdKnAHjJ1p8TbZp0bFYaL8JVs0AJEqq6TIB5o=; b=jtvjKQM3iCMjtN7twTvLFfdy8F8sIEzavd0y4MD4E6YvAqEomKX11mJzImj7aRtzYW jy02vtV3Hnkq5tY8jFkehOZXNlwxKAvZG69FESC+qKN2gqhSmcbgm0ovY65DO3FlyhYF LNCxH17+oJWkZhYdw/jUq9urC78l0344ZgnKo4EJY4tIpUvr0TxAAwOvkDIo4arrH81t vDKcLfTGkXr3SspJSF+x0/pdkR21f/7GeRD/hsyUXaPOY0BN8eBstRyL3yUHocoLhkll P4kDs7r4ZiGsdrjs6zry9oV4+PNhKWM9JJdzKo5e8tMJowiV2BosY68yFJ0esgGDfuTF OZkg== 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:subject:date; bh=1PqA7OYdKnAHjJ1p8TbZp0bFYaL8JVs0AJEqq6TIB5o=; b=N0YsD0er2ejLcnQwz/2NwpATvDhMVvjDkg3nn2O/jOhuRI0MyXIi39jFHtNT4MXcqM BWCpAAoBI6zYRBFcxCnncmTuAgyql5o84zpGk5mh2N7GB0RK3XIYnvtN0ovaZ/l4JKwg g8bUQ5IUAud7eize9xd74lFLVysojpC+052RzTu6N4Cg03cUP1xQQrQr8UNJ0LXvATAN 5fZc44h/EXZDPglCy4PbCnUtAP13bt2KYdFMMIQXbWwxJuL1WXjP1vdDRpVign3ORS0A xLlCH3eV4e7JRc7tCOMbLOyghyR1/25bcVALFgFwpQeCoW8wQ3AgHpq9wegPpaDnDpBZ U4ZA== X-Gm-Message-State: ACgBeo2nxs2xHmFHEKBW+VQwV/cQa53cZFyHMtDptB7rblF3evp8O1WE o5TKTnX61T+wL3eRrFB8nuw= X-Google-Smtp-Source: AA6agR75AGBMrZf8O37ha0/oSnopRy0JjhXA3+jd3TQVaegj+2WoHuYUdkemvsQ4g0xfu9vX9AvjKA== X-Received: by 2002:a05:600c:3488:b0:3a8:52f7:b869 with SMTP id a8-20020a05600c348800b003a852f7b869mr11907836wmq.36.1662933469104; Sun, 11 Sep 2022 14:57:49 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id a12-20020a5d570c000000b00228dd80d78asm5541999wrv.86.2022.09.11.14.57.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 11 Sep 2022 14:57:48 -0700 (PDT) Message-ID: <70b6d879-ea34-a473-aa27-7fc7b72fd7d0@yandex.ru> Date: Mon, 12 Sep 2022 00:57:47 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US 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> <86fsh1ll5y.fsf@mail.linkov.net> <87edwlo52t.fsf@melete.silentflame.com> <868rmqypjz.fsf@mail.linkov.net> From: Dmitry Gutov In-Reply-To: <868rmqypjz.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On 11.09.2022 18:05, Juri Linkov wrote: > + (if (string-search file-diff vc-git-patch-string) > + (setq vc-git-patch-string > + (string-replace file-diff "" vc-git-patch-string)) Not sure I understand this part. We're replacing some text (the diff file header) with empty text in the patch string? But not the whole hunk? It might work if we removed the whole hunk as well, but we need to make sure that the staged contents for that file are exactly the same as what is contained for that file in vc-git-patch-string. Perhaps if we called diff-file-next in addition to (move-beginning-of-line 1)? But we need to save both strings: and ensure that if there is a match for that file header, then all hunks are contained in the patch as well (and nothing extra, for that file). It's complex logic, so if you manage to write a test as well, that would be excellent. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 12 Sep 2022 18:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: 52349@debbugs.gnu.org, Sean Whitton Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166300687226785 (code B ref 52349); Mon, 12 Sep 2022 18:22:02 +0000 Received: (at 52349) by debbugs.gnu.org; 12 Sep 2022 18:21:12 +0000 Received: from localhost ([127.0.0.1]:47816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oXo3U-0006xw-8j for submit@debbugs.gnu.org; Mon, 12 Sep 2022 14:21:12 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:35649) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oXo3S-0006xh-No for 52349@debbugs.gnu.org; Mon, 12 Sep 2022 14:21:11 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 3E9B1200008; Mon, 12 Sep 2022 18:21:02 +0000 (UTC) From: Juri Linkov In-Reply-To: <70b6d879-ea34-a473-aa27-7fc7b72fd7d0@yandex.ru> (Dmitry Gutov's message of "Mon, 12 Sep 2022 00:57:47 +0300") Organization: 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> <86fsh1ll5y.fsf@mail.linkov.net> <87edwlo52t.fsf@melete.silentflame.com> <868rmqypjz.fsf@mail.linkov.net> <70b6d879-ea34-a473-aa27-7fc7b72fd7d0@yandex.ru> Date: Mon, 12 Sep 2022 21:19:41 +0300 Message-ID: <86mtb4tpz6.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >> + (if (string-search file-diff vc-git-patch-string) >> + (setq vc-git-patch-string >> + (string-replace file-diff "" vc-git-patch-string)) > > Not sure I understand this part. We're replacing some text (the diff file > header) with empty text in the patch string? But not the whole hunk? Actually it replaces the whole new/deleted file differences. > It might work if we removed the whole hunk as well, but we need to make > sure that the staged contents for that file are exactly the same as what is > contained for that file in vc-git-patch-string. This is exactly what this patch does. > Perhaps if we called diff-file-next in addition to (move-beginning-of-line > 1)? diff-file-next doesn't work: it stops in the middle of the diff file header. Therefore the patch navigates git diff file headers explicitly. > But we need to save both strings: and ensure that if there is a match > for that file header, then all hunks are contained in the patch as well > (and nothing extra, for that file). This is implemented by the patch. Maybe it could help you to see how it works by running it under debugger and stepping through it. > It's complex logic, so if you manage to write a test as well, that would be > excellent. A test could written when someone will create infrastructure for testing git commands with helpers to create a git repository and checking its content. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Sep 2022 02:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 52349@debbugs.gnu.org, Sean Whitton Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166355337016942 (code B ref 52349); Mon, 19 Sep 2022 02:10:02 +0000 Received: (at 52349) by debbugs.gnu.org; 19 Sep 2022 02:09:30 +0000 Received: from localhost ([127.0.0.1]:51632 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oa6Dy-0004PC-0U for submit@debbugs.gnu.org; Sun, 18 Sep 2022 22:09:30 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:44725) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oa6Dv-0004Ow-Ne for 52349@debbugs.gnu.org; Sun, 18 Sep 2022 22:09:28 -0400 Received: by mail-wr1-f53.google.com with SMTP id c11so45246526wrp.11 for <52349@debbugs.gnu.org>; Sun, 18 Sep 2022 19:09:27 -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:subject:date; bh=Cee0RL3te3uTvvaQP4Oj5TwGZKRZ0BOzp8Q8cSurzfk=; b=Sjf4fAUOc9yE5G6QnKPPzeFTCDd8/SRwiWOmQJPBflVDtiLvR1NVu3GT9ymE82ZGMp yk+g5pM8NQt3HBS+c8SoIwoZ8DOQn3Ql4UzraKl/U1u/iGQxCoTQGmFEjT4fedXdhtbK IJTXwAtzqu/06dcNcaj9agPBHNGA9GB0sBgMJvwwNZhEwseuKTNzjPaDr/bC2js+ncYw YH9B1Zriv8pHVM7UMkmolpqr78C655um89m7d0CqEoxHz0SLU2T/REbn/6xrf+Uu9HaE gU3TDe3XpVBuCUQpQ8p5dW5DWSriCOEysEn9yjWrJz0pjBu9he8a2fKzUxqtkBO8Tj6M OEig== 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:subject:date; bh=Cee0RL3te3uTvvaQP4Oj5TwGZKRZ0BOzp8Q8cSurzfk=; b=ciAsfQz1o6zBgUrwVBh0ImgCqGl7i8RBwMtI19Ie5D+3zDJMZ29RE33fjIsTDC7ASo VhrNdQFjZnoEfE/nrboKXKY4lvwJ74Coc+DKK2IwvthAfFEhSvXIPg9MH6m7D5z9z7/v 18PFB3kJK+bisf3CDkwTLusarJ/3JiSIOcvzRlUnCE54CvWlyqlwkh+Ird/4wZS5AV+h laolj/uPnlbI0Fg/EObE5VJDpbX900mdxKCH462hIo4lACH46tIZllfHmIrr1JXUqH7v 5DDlFgdK6koOKKCQfvPJN2Rrx5x2ydt718bQkU/8jOndTmZFGxyy3aNinJgsc7l0PP+w 48ng== X-Gm-Message-State: ACrzQf3EyiI528YJZo5dEf1IPf+8UYZIvSx37gt0yuTXxXe1vJoHoXbA 7lKemxZBC+qKxOf0W5fqlOs= X-Google-Smtp-Source: AMsMyM7uadY/ZCtBKET6gxBTZ2ygWZBCTdgyIMofzwWSk+8GjyNUn2xoeIc/8gxvvNrP5wR4KNcr4A== X-Received: by 2002:a5d:4ecd:0:b0:22a:42ec:8d74 with SMTP id s13-20020a5d4ecd000000b0022a42ec8d74mr9722827wrv.359.1663553361625; Sun, 18 Sep 2022 19:09:21 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id j13-20020adfff8d000000b0022ae59d472esm7107887wrr.112.2022.09.18.19.09.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 18 Sep 2022 19:09:21 -0700 (PDT) Message-ID: <78b1100c-89a6-5daf-548f-778807105307@yandex.ru> Date: Mon, 19 Sep 2022 05:09:19 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US 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> <86fsh1ll5y.fsf@mail.linkov.net> <87edwlo52t.fsf@melete.silentflame.com> <868rmqypjz.fsf@mail.linkov.net> <70b6d879-ea34-a473-aa27-7fc7b72fd7d0@yandex.ru> <86mtb4tpz6.fsf@mail.linkov.net> From: Dmitry Gutov In-Reply-To: <86mtb4tpz6.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) On 12.09.2022 21:19, Juri Linkov wrote: >>> + (if (string-search file-diff vc-git-patch-string) >>> + (setq vc-git-patch-string >>> + (string-replace file-diff "" vc-git-patch-string)) >> >> Not sure I understand this part. We're replacing some text (the diff file >> header) with empty text in the patch string? But not the whole hunk? > > Actually it replaces the whole new/deleted file differences. > >> It might work if we removed the whole hunk as well, but we need to make >> sure that the staged contents for that file are exactly the same as what is >> contained for that file in vc-git-patch-string. > > This is exactly what this patch does. Right, sorry, I see it now. Do you know if Git use a stable ordering for files? If not, here's where the proposed implementation might fail: Suppose we have the staging area with contents a/bar b/bar +bbb a/foo b/foo +aaa +ccc and the diff to check in with contents a/foo b/foo +aaa a/bar b/bar +bbb +ccc ...then the check will succeed, I think. Even if Git always sorts them the same, I suppose an externally-produced diff could trigger this scenario. It should be a pretty rare case, though, so it's probably fine. A tweak like the following could fix it, though: instead of replacing the chunks with "", maybe keep the file headers. Then the remaining contents for the same file in vc-git-patch-string wouldn't be able to stick to the previous file's chunks. >> Perhaps if we called diff-file-next in addition to (move-beginning-of-line >> 1)? > > diff-file-next doesn't work: it stops in the middle of the diff file header. > Therefore the patch navigates git diff file headers explicitly. > >> But we need to save both strings: and ensure that if there is a match >> for that file header, then all hunks are contained in the patch as well >> (and nothing extra, for that file). > > This is implemented by the patch. Maybe it could help you to see how it works > by running it under debugger and stepping through it. > >> It's complex logic, so if you manage to write a test as well, that would be >> excellent. > > A test could written when someone will create infrastructure for testing > git commands with helpers to create a git repository and checking its content. test/lisp/vc/vc-tests.el actually contains a helper like this. Every scenario starts with calling vc-test--create-repo-function, and there are tests for 'version-diff' at the very end of the file. It's somewhat convoluted, so I don't blame you for missing it. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Sep 2022 07:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: 52349@debbugs.gnu.org, Sean Whitton Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166357402828963 (code B ref 52349); Mon, 19 Sep 2022 07:54:01 +0000 Received: (at 52349) by debbugs.gnu.org; 19 Sep 2022 07:53:48 +0000 Received: from localhost ([127.0.0.1]:52197 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oaBb9-0007X4-Lu for submit@debbugs.gnu.org; Mon, 19 Sep 2022 03:53:47 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:59099) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oaBb5-0007Wc-Uq for 52349@debbugs.gnu.org; Mon, 19 Sep 2022 03:53:45 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id A2664C0002; Mon, 19 Sep 2022 07:53:35 +0000 (UTC) From: Juri Linkov In-Reply-To: <78b1100c-89a6-5daf-548f-778807105307@yandex.ru> (Dmitry Gutov's message of "Mon, 19 Sep 2022 05:09:19 +0300") Organization: LINKOV.NET References: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> <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> <86fsh1ll5y.fsf@mail.linkov.net> <87edwlo52t.fsf@melete.silentflame.com> <868rmqypjz.fsf@mail.linkov.net> <70b6d879-ea34-a473-aa27-7fc7b72fd7d0@yandex.ru> <86mtb4tpz6.fsf@mail.linkov.net> <78b1100c-89a6-5daf-548f-778807105307@yandex.ru> Date: Mon, 19 Sep 2022 09:50:18 +0300 Message-ID: <86leqf6bwl.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > Do you know if Git use a stable ordering for files? It seems the ordering is stable unless it's changed explicitly by command line options. > If not, here's where the proposed implementation might fail: > > Suppose we have the staging area with contents > > a/bar b/bar > +bbb > a/foo b/foo > +aaa > +ccc > > and the diff to check in with contents > > a/foo b/foo > +aaa > a/bar b/bar > +bbb > +ccc > > ...then the check will succeed, I think. This check is intended to detect only added/deleted files that get into the staging area. > Even if Git always sorts them the same, I suppose an externally-produced > diff could trigger this scenario. It should be a pretty rare case, though, > so it's probably fine. > > A tweak like the following could fix it, though: instead of replacing the > chunks with "", maybe keep the file headers. Then the remaining contents > for the same file in vc-git-patch-string wouldn't be able to stick to the > previous file's chunks. This looks too complicated. And indeed, this is a rare case, so maybe something like this could be added when this will became a real problem. >>> Perhaps if we called diff-file-next in addition to (move-beginning-of-line >>> 1)? >> diff-file-next doesn't work: it stops in the middle of the diff file >> header. >> Therefore the patch navigates git diff file headers explicitly. >> >>> But we need to save both strings: and ensure that if there is a match >>> for that file header, then all hunks are contained in the patch as well >>> (and nothing extra, for that file). >> This is implemented by the patch. Maybe it could help you to see how it >> works >> by running it under debugger and stepping through it. >> >>> It's complex logic, so if you manage to write a test as well, that would be >>> excellent. >> A test could written when someone will create infrastructure for testing >> git commands with helpers to create a git repository and checking its content. > > test/lisp/vc/vc-tests.el actually contains a helper like this. > > Every scenario starts with calling vc-test--create-repo-function, and there > are tests for 'version-diff' at the very end of the file. It's somewhat > convoluted, so I don't blame you for missing it. Actually, I looked into test/lisp/vc/vc-git-tests.el that is almost empty. I expected that since this check is git-specific, it should be in vc-git-tests.el. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Sep 2022 12:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 52349@debbugs.gnu.org, Sean Whitton Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166359224821579 (code B ref 52349); Mon, 19 Sep 2022 12:58:01 +0000 Received: (at 52349) by debbugs.gnu.org; 19 Sep 2022 12:57:28 +0000 Received: from localhost ([127.0.0.1]:52668 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oaGL1-0005by-KP for submit@debbugs.gnu.org; Mon, 19 Sep 2022 08:57:27 -0400 Received: from mail-wm1-f49.google.com ([209.85.128.49]:51859) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oaGKz-0005bl-UA for 52349@debbugs.gnu.org; Mon, 19 Sep 2022 08:57:26 -0400 Received: by mail-wm1-f49.google.com with SMTP id o5so16749258wms.1 for <52349@debbugs.gnu.org>; Mon, 19 Sep 2022 05:57:25 -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:subject:date; bh=f8unWC60/6viF+jns9XtG45Ug2MVresKBy5dMELbg/U=; b=R6y9Ql7X5eFFsJYOva+OOWxF4D/lznMYr9qPnCBjhXsxicTuPpsP7VElfIR9/UsHzz j5iiNTIJu+dxUjqI0lqeksbTGNL95eA35dKCWu9W6FZNfbQjA1NKVVHWVCP9+vMkvKlY pVkhFlLQMtExcYJw4EiB+EmrpMOi/FvWbh6CuiyVgJAtBnTmvRjUbNMUFZdyRAd5BaHs n6U9SRPVrzxKeRWF0OMQrv+GcyE7xmi0j5sT1JSvxR4aUVEAOJl1UTVqS/avifKgD3DR P7xs+kePIuzAz9cdtla5PNMOAHNBpiaxR/L41evCusv2mgAxNRmjFkqeKQbuJSv3khfr uaMw== 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:subject:date; bh=f8unWC60/6viF+jns9XtG45Ug2MVresKBy5dMELbg/U=; b=sKGgTuHHQyZSLkwteq/td71hK0W2K3gzxUuFVXK1lsoV3v81ygH7hSDg7cbdL9s/9H /R6qptJ2noVqjlmYCppzd9FxQDHJLOaSs108ZvKHSxbxMmCjjOGiGN+EYVihDsi85tQ/ lWAH5Bm5ureG9Rl32/h3/j4/+I9A3OQZf5iMR5TI0+nvMqdojm6GVDHsAHfknbTZjj6q 6MRWEA7ZPirg3GzGdORnyEKJglOtxGFdmVYFxis1qRuHrIBR2CBxYAPfRMaxsahQbL3w 4eiyuR2Skl1YKF5S686DwHOehbSq6+CU6s4Ylq9hm7bSHUR1mitOMq41+DnW8A/27RiF miTQ== X-Gm-Message-State: ACrzQf0AU9klnFuPC1H0CRAOfZrYlfmh00cmHz3RCEOv6pZZHLAIWRI2 SDvJe2w8Ws6/MDMw2Ea2j+g= X-Google-Smtp-Source: AMsMyM6d7tMZan6UaSy+ztnLuZCqsqaKj8FjgL8PwUjz36LHqFLoHaiSWohQdYDsxwdedQaUOJCI5w== X-Received: by 2002:a05:600c:524f:b0:3b4:7cfa:3ca3 with SMTP id fc15-20020a05600c524f00b003b47cfa3ca3mr12580741wmb.172.1663592239778; Mon, 19 Sep 2022 05:57:19 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id m5-20020a1ca305000000b003b27f644488sm13729695wme.29.2022.09.19.05.57.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Sep 2022 05:57:19 -0700 (PDT) Message-ID: <7af82b9a-212f-9456-dd28-7279f87e92c8@yandex.ru> Date: Mon, 19 Sep 2022 15:57:17 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US References: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> <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> <86fsh1ll5y.fsf@mail.linkov.net> <87edwlo52t.fsf@melete.silentflame.com> <868rmqypjz.fsf@mail.linkov.net> <70b6d879-ea34-a473-aa27-7fc7b72fd7d0@yandex.ru> <86mtb4tpz6.fsf@mail.linkov.net> <78b1100c-89a6-5daf-548f-778807105307@yandex.ru> <86leqf6bwl.fsf@mail.linkov.net> From: Dmitry Gutov In-Reply-To: <86leqf6bwl.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) On 19.09.2022 09:50, Juri Linkov wrote: >> Do you know if Git use a stable ordering for files? > > It seems the ordering is stable unless it's changed explicitly > by command line options. > >> If not, here's where the proposed implementation might fail: >> >> Suppose we have the staging area with contents >> >> a/bar b/bar >> +bbb >> a/foo b/foo >> +aaa >> +ccc >> >> and the diff to check in with contents >> >> a/foo b/foo >> +aaa >> a/bar b/bar >> +bbb >> +ccc >> >> ...then the check will succeed, I think. > > This check is intended to detect only added/deleted files > that get into the staging area. It doesn't seem like it's going to differentiate between "add whole file" chunks and any other kinds of chunks. Which is not a bad thing by itself, probably. But can increase the odds of something like the above happening. >> Even if Git always sorts them the same, I suppose an externally-produced >> diff could trigger this scenario. It should be a pretty rare case, though, >> so it's probably fine. >> >> A tweak like the following could fix it, though: instead of replacing the >> chunks with "", maybe keep the file headers. Then the remaining contents >> for the same file in vc-git-patch-string wouldn't be able to stick to the >> previous file's chunks. > > This looks too complicated. And indeed, this is a rare case, so maybe > something like this could be added when this will became a real problem. Sure, sounds good to me. >>>> It's complex logic, so if you manage to write a test as well, that would be >>>> excellent. >>> A test could written when someone will create infrastructure for testing >>> git commands with helpers to create a git repository and checking its content. >> >> test/lisp/vc/vc-tests.el actually contains a helper like this. >> >> Every scenario starts with calling vc-test--create-repo-function, and there >> are tests for 'version-diff' at the very end of the file. It's somewhat >> convoluted, so I don't blame you for missing it. > > Actually, I looked into test/lisp/vc/vc-git-tests.el that is almost empty. > I expected that since this check is git-specific, it should be in > vc-git-tests.el. Not sure how to best share the setup/teardown logic between vc-tests.el and vc-git-test.el. From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 02 Oct 2022 18:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: 52349@debbugs.gnu.org, Sean Whitton Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.16647367002295 (code B ref 52349); Sun, 02 Oct 2022 18:52:01 +0000 Received: (at 52349) by debbugs.gnu.org; 2 Oct 2022 18:51:40 +0000 Received: from localhost ([127.0.0.1]:48055 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1of43w-0000aw-5a for submit@debbugs.gnu.org; Sun, 02 Oct 2022 14:51:40 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:43361) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1of43u-0000ad-8v for 52349@debbugs.gnu.org; Sun, 02 Oct 2022 14:51:38 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id A5C0220002; Sun, 2 Oct 2022 18:51:28 +0000 (UTC) From: Juri Linkov In-Reply-To: <7af82b9a-212f-9456-dd28-7279f87e92c8@yandex.ru> (Dmitry Gutov's message of "Mon, 19 Sep 2022 15:57:17 +0300") Organization: LINKOV.NET References: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> <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> <86fsh1ll5y.fsf@mail.linkov.net> <87edwlo52t.fsf@melete.silentflame.com> <868rmqypjz.fsf@mail.linkov.net> <70b6d879-ea34-a473-aa27-7fc7b72fd7d0@yandex.ru> <86mtb4tpz6.fsf@mail.linkov.net> <78b1100c-89a6-5daf-548f-778807105307@yandex.ru> <86leqf6bwl.fsf@mail.linkov.net> <7af82b9a-212f-9456-dd28-7279f87e92c8@yandex.ru> Date: Sun, 02 Oct 2022 21:51:19 +0300 Message-ID: <86zgeeysg4.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > It doesn't seem like it's going to differentiate between "add whole file" > chunks and any other kinds of chunks. > > Which is not a bad thing by itself, probably. But can increase the odds of > something like the above happening. I added more checks to detect the whole files boundaries, and pushed. >>>>> It's complex logic, so if you manage to write a test as well, that would be >>>>> excellent. >>>> A test could written when someone will create infrastructure for testing >>>> git commands with helpers to create a git repository and checking its content. >>> >>> test/lisp/vc/vc-tests.el actually contains a helper like this. >>> >>> Every scenario starts with calling vc-test--create-repo-function, and there >>> are tests for 'version-diff' at the very end of the file. It's somewhat >>> convoluted, so I don't blame you for missing it. >> Actually, I looked into test/lisp/vc/vc-git-tests.el that is almost >> empty. >> I expected that since this check is git-specific, it should be in >> vc-git-tests.el. > > Not sure how to best share the setup/teardown logic between vc-tests.el and > vc-git-test.el. I looked into this, but this is a too big task. It would be nice if Someone (TM) created the git-specific setup/teardown logic, and other helper functions in test/lisp/vc/vc-git-tests.el. From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 03 21:31:09 2022 Received: (at control) by debbugs.gnu.org; 4 Nov 2022 01:31:09 +0000 Received: from localhost ([127.0.0.1]:51086 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqlY5-0005vU-1M for submit@debbugs.gnu.org; Thu, 03 Nov 2022 21:31:09 -0400 Received: from mail-wm1-f42.google.com ([209.85.128.42]:41692) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqlY4-0005vG-0w for control@debbugs.gnu.org; Thu, 03 Nov 2022 21:31:08 -0400 Received: by mail-wm1-f42.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so2333390wmb.0 for ; Thu, 03 Nov 2022 18:31:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:from:to:content-language:user-agent :mime-version:date:message-id:sender:from:to:cc:subject:date :message-id:reply-to; bh=KB7AU+auNtNbqQobI/ktS8QvvZzoGbsds4BzmUwgVig=; b=fLU9NdUkzYYjcc0AXrtfV6Z5vlCGve8MMzfedY2araDqLFBg3tj+NcSf8/2mJUYCom eU2cA9d0PzQXK9+BAgltz9jKJHOqf7B7e8Sn6WQ34GjytURIlmOil5L8PVGIiLY6xz4g yrEg78/Z2lfekzwWQykTh8LT12ajcMJV9pzjB26o3bz7SkdOfZzEUD1UxjXewQfv1KHs ofUFmrYUzl/+ATy6YTX5VaHJnfVlRQrUDpJELN2PzQV2xKs0Py5OsSpxRJvrL0bhgi5a osRunZ0wNMcpU8nDeY6FCswguTEe21ICy7FE1fbuXaQP5d8wi2+jIILtdPoffyQjVZ4t IrEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:from:to:content-language:user-agent :mime-version:date:message-id:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KB7AU+auNtNbqQobI/ktS8QvvZzoGbsds4BzmUwgVig=; b=vZ70M5VPJb37D28pz3iKHdNLRk7gBd7TCSqxjWdWlJF1dXmQ22ynbQKLKXHE4g4wwV ivLX3P4sU7SGZWyJzz6j/zIIUx9dNMZqBQu0M9vPm/ucph4CwSk6jnvvRDvWXVzwROge RU83jkEMyUf1MaR1qbmLk1e9zIbaaQWaC+qTuppzsIqNln9is6RNwscuNSTd6ftb1Hwn vEq0Xv4DsufIw97R0yQz7cjI7dCX7GE+OrP4GXuCz30XWVbr81r1nYZImiHwKdLjydIP WryEju/JIWZh4B+fW0NGPI3QX8q9UG292gYNeIoh1vYEX29W0iAAeO4pzyyC3EjVPEED rpYw== X-Gm-Message-State: ACrzQf17YhQG7l5H4xTuYt7Xqdj/vLh7HAXkV4yJKwYU68qKvcZ6+ZdN lasaTFT8u8CDWmJDTht8qR6js7UQ3Io= X-Google-Smtp-Source: AMsMyM7zYk8v8cI4OuPnLY8BscG3oemN9vSA8GW7LZaxMxALpvcnJecBiF3I2snUN53pTR3q+0YVIg== X-Received: by 2002:a05:600c:4e47:b0:3c6:fc59:5eff with SMTP id e7-20020a05600c4e4700b003c6fc595effmr31667017wmq.18.1667525462133; Thu, 03 Nov 2022 18:31:02 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id g14-20020a05600c310e00b003a84375d0d1sm1299597wmo.44.2022.11.03.18.31.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Nov 2022 18:31:02 -0700 (PDT) Message-ID: Date: Fri, 4 Nov 2022 03:31:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Content-Language: en-US To: control@debbugs.gnu.org From: Dmitry Gutov Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: unarchive 52349 Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (raaahh[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.128.42 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.42 listed in wl.mailspike.net] 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.5 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: unarchive 52349 Content analysis details: (1.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.42 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.128.42 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dgutov[at]yandex.ru) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject 0.0 TVD_SPACE_RATIO No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager unarchive 52349 From unknown Sat Jun 14 05:28:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Nov 2022 01:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 52349@debbugs.gnu.org, Sean Whitton Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166752558423145 (code B ref 52349); Fri, 04 Nov 2022 01:34:02 +0000 Received: (at 52349) by debbugs.gnu.org; 4 Nov 2022 01:33:04 +0000 Received: from localhost ([127.0.0.1]:51091 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqlZw-00061E-FO for submit@debbugs.gnu.org; Thu, 03 Nov 2022 21:33:04 -0400 Received: from mail-wr1-f52.google.com ([209.85.221.52]:33529) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqlZs-00060L-Sx for 52349@debbugs.gnu.org; Thu, 03 Nov 2022 21:33:03 -0400 Received: by mail-wr1-f52.google.com with SMTP id h9so5189037wrt.0 for <52349@debbugs.gnu.org>; Thu, 03 Nov 2022 18:33:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:sender :from:to:cc:subject:date:message-id:reply-to; bh=PQafsFHvuEkH2XluGW3VoQt07Vdlcn9NeEcRXoWKmUY=; b=IK8OfP8XRp37TJ5wwYl1GXEX7jN5Sf77AbqdgoqKo1HlPeASE2CBE6/udLWx3WLKCZ TXROViirBRGZtuGxh/aW1fZNR65qIDwBY63Mqj1c0Wu707ujCqh1txCtEI7h+t4sjz3w /ZRsyl8ADlulIrJlKF9Da3pGXbhnzLg/AmfZV7Up4pbnq9HY1BXsVZrkDghysrA8gCF6 xgFLzrMOtDoozGicDJ0lp+0zYQ+4B1J+753G8XLlD4K1mfNBQe/SEmEXvR9bmptjp8FV ZW3JsNjgIeGw2AR5rTMAM+i0XgGuoh4BBJz14OkypRg+BbjCLSRwFIetPWhZJY5mCvV0 eUAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PQafsFHvuEkH2XluGW3VoQt07Vdlcn9NeEcRXoWKmUY=; b=Mmjx8z8WAY+UJmAsADYfGKB3HJ26QrGo/iobUycYaAuhecWw+UAMwTJSwEaZOZyn9T v/8KGzJJ8Uk4LhIbrMo0zq4Uv4eqQWiZkYbujR2Huc11Sgqtu6ftIuJ96vEDvpSuj4+L sQYT95KqDdZhAa4U9wCYjfjzAeHNItxAj5mhIVlM3JIjyB0AnVfg4IUGV/CXlJR7MGot 9RwViHSX5iZHaIt39WMwhkU/7u6r1XsXYTaTzkbDLdDGKSLQm+YYe4ba+Jf694Jal6Yd Z9f0Jbvz9y1PfbW1SM3E58YsSkJZam44uBUrY8EG9HeH6YDG7JXF/Bb0qEE99RMcUOlK sokg== X-Gm-Message-State: ACrzQf0uJunl1xEyuaKzq5f3BLpZ7MueWQ0aLH05PFRpbDqaWsDMNWsf JEZlWtTY/MJgJdYP+rJBX4U= X-Google-Smtp-Source: AMsMyM45uOkkViiDGfuhgSz0ssFhIVhPIUdFFnOoAr31T8l8tVTnwCpiNCppVvGQK28A1OI+Gp2TTQ== X-Received: by 2002:a5d:58f1:0:b0:236:b588:1e07 with SMTP id f17-20020a5d58f1000000b00236b5881e07mr19673007wrd.612.1667525575274; Thu, 03 Nov 2022 18:32:55 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id f63-20020a1c3842000000b003cf4d99fd2asm1389364wma.6.2022.11.03.18.32.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Nov 2022 18:32:55 -0700 (PDT) Message-ID: <713b060a-e32c-1a0a-fdb5-fa6a5a5d9af8@yandex.ru> Date: Fri, 4 Nov 2022 03:32:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 From: Dmitry Gutov References: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> <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> <86fsh1ll5y.fsf@mail.linkov.net> <87edwlo52t.fsf@melete.silentflame.com> <868rmqypjz.fsf@mail.linkov.net> <70b6d879-ea34-a473-aa27-7fc7b72fd7d0@yandex.ru> <86mtb4tpz6.fsf@mail.linkov.net> <78b1100c-89a6-5daf-548f-778807105307@yandex.ru> <86leqf6bwl.fsf@mail.linkov.net> <7af82b9a-212f-9456-dd28-7279f87e92c8@yandex.ru> <86zgeeysg4.fsf@mail.linkov.net> Content-Language: en-US In-Reply-To: <86zgeeysg4.fsf@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) (Sorry, resending after unarchiving). On 02.10.2022 21:51, Juri Linkov wrote: >> It doesn't seem like it's going to differentiate between "add whole file" >> chunks and any other kinds of chunks. >> >> Which is not a bad thing by itself, probably. But can increase the odds of >> something like the above happening. > I added more checks to detect the whole files boundaries, and pushed. Thanks. >>>>>> It's complex logic, so if you manage to write a test as well, that would be >>>>>> excellent. >>>>> A test could written when someone will create infrastructure for testing >>>>> git commands with helpers to create a git repository and checking its content. >>>> test/lisp/vc/vc-tests.el actually contains a helper like this. >>>> >>>> Every scenario starts with calling vc-test--create-repo-function, and there >>>> are tests for 'version-diff' at the very end of the file. It's somewhat >>>> convoluted, so I don't blame you for missing it. >>> Actually, I looked into test/lisp/vc/vc-git-tests.el that is almost >>> empty. >>> I expected that since this check is git-specific, it should be in >>> vc-git-tests.el. >> Not sure how to best share the setup/teardown logic between vc-tests.el and >> vc-git-test.el. > I looked into this, but this is a too big task. It would be nice if > Someone (TM) created the git-specific setup/teardown logic, and other > helper functions in test/lisp/vc/vc-git-tests.el. FWIW, now that the feature is supported across backends, we can add a corresponding test in vc-tests.el. ;-) Some backends will probably need to be skipped anyway, but the most popular ones will hopefully work.