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: Mon, 19 Sep 2022 15:57:17 +0300 Message-ID: <7af82b9a-212f-9456-dd28-7279f87e92c8@yandex.ru> 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> 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="3787"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Cc: 52349@debbugs.gnu.org, Sean Whitton To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 19 15:06:38 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 1oaGTt-0000pT-Fs for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 19 Sep 2022 15:06:37 +0200 Original-Received: from localhost ([::1]:37252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oaGTs-000347-F3 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 19 Sep 2022 09:06:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaGLa-0004hH-KE for bug-gnu-emacs@gnu.org; Mon, 19 Sep 2022 08:58:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53590) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaGLa-00023z-C3 for bug-gnu-emacs@gnu.org; Mon, 19 Sep 2022 08:58:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oaGLZ-0005ck-Sn for bug-gnu-emacs@gnu.org; Mon, 19 Sep 2022 08:58: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: 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 Original-Received: via spool by 52349-submit@debbugs.gnu.org id=B52349.166359224821579 (code B ref 52349); Mon, 19 Sep 2022 12:58:01 +0000 Original-Received: (at 52349) by debbugs.gnu.org; 19 Sep 2022 12:57:28 +0000 Original-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 Original-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 Original-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) Original-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) Content-Language: en-US In-Reply-To: <86leqf6bwl.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:243079 Archived-At: 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.