From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#52349: 29.0.50; vc-git and diff-mode: stage hunks Date: Wed, 24 Aug 2022 23:20:59 +0300 Message-ID: References: <268cee0d-465d-b862-d1d6-f5da4d69e737@inventati.org> <9106387a-98cf-396f-bf45-ccb04581787b@yandex.ru> <864k7kfd56.fsf@mail.linkov.net> <86fsr3uen2.fsf@mail.linkov.net> <95d2d999-49ad-13c4-9f25-0935650a1e42@yandex.ru> <8635ktjfll.fsf@mail.linkov.net> <36b963e4-5af7-dd9e-af92-4404541b9f4d@yandex.ru> <86v8xjx45h.fsf@mail.linkov.net> <861qt9h1hh.fsf@mail.linkov.net> <864jy1mrk8.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18024"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Cc: 52349@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 24 22:22:10 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oQwt8-0004XP-7D for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Aug 2022 22:22:10 +0200 Original-Received: from localhost ([::1]:43000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQwt6-0001MJ-L0 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Aug 2022 16:22:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQwt0-0001MA-01 for bug-gnu-emacs@gnu.org; Wed, 24 Aug 2022 16:22:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58570) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQwsz-0005Xr-OP for bug-gnu-emacs@gnu.org; Wed, 24 Aug 2022 16:22:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oQwsz-000893-Jl for bug-gnu-emacs@gnu.org; Wed, 24 Aug 2022 16:22:01 -0400 X-Loop: help-debbugs@gnu.org 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 Original-Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166137247131245 (code B ref 52349); Wed, 24 Aug 2022 20:22:01 +0000 Original-Received: (at 52349) by debbugs.gnu.org; 24 Aug 2022 20:21:11 +0000 Original-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 Original-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 Original-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) Original-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) Content-Language: en-US In-Reply-To: <864jy1mrk8.fsf@mail.linkov.net> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:240661 Archived-At: 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.