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#65049: Minor update to the repro steps Date: Sat, 26 Aug 2023 03:45:41 +0300 Message-ID: <49d5e741-f97d-ae4d-f79c-ec418051d868@gutov.dev> References: <83y1iruky1.fsf@gnu.org> <83il9qom6k.fsf@gnu.org> <86v8dandhq.fsf@mail.linkov.net> <83bkf1woy3.fsf@gnu.org> <835y57tf23.fsf@gnu.org> <87edjvp6ev.fsf@gmail.com> <83350btdw8.fsf@gnu.org> <831qftspal.fsf@gnu.org> <35b50832-e9ca-9f57-fad6-68621d9b42e7@gutov.dev> <83pm3dqbtp.fsf@gnu.org> <789dacd3-8e62-74ad-f691-5b48cb1d678b@gutov.dev> <2f6986e7-f96b-98bd-4581-7503bb01b111@gutov.dev> <83ttsnoda5.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4448"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: 65049@debbugs.gnu.org, habamax@gmail.com, juri@linkov.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 26 02:47:13 2023 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 1qZhSJ-0000s1-1v for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 26 Aug 2023 02:47:12 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZhS8-00011g-Nh; Fri, 25 Aug 2023 20:47:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZhS7-00011J-0m for bug-gnu-emacs@gnu.org; Fri, 25 Aug 2023 20:46:59 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qZhS5-0006Y7-PC for bug-gnu-emacs@gnu.org; Fri, 25 Aug 2023 20:46:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qZhSA-0008Gt-9z for bug-gnu-emacs@gnu.org; Fri, 25 Aug 2023 20:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Aug 2023 00:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65049 X-GNU-PR-Package: emacs Original-Received: via spool by 65049-submit@debbugs.gnu.org id=B65049.169301076231717 (code B ref 65049); Sat, 26 Aug 2023 00:47:02 +0000 Original-Received: (at 65049) by debbugs.gnu.org; 26 Aug 2023 00:46:02 +0000 Original-Received: from localhost ([127.0.0.1]:41256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZhRB-0008FJ-Ns for submit@debbugs.gnu.org; Fri, 25 Aug 2023 20:46:02 -0400 Original-Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:44955) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZhR7-0008Ew-8i for 65049@debbugs.gnu.org; Fri, 25 Aug 2023 20:46:00 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 8F93D32002E2; Fri, 25 Aug 2023 20:45:45 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 25 Aug 2023 20:45:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type: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=fm3; t= 1693010745; x=1693097145; bh=S8Fof8vLCs5YRuCkGaEaj0C33ZZZXm9nb3b eKcmd030=; b=EW5CIRicxyCbePxxUd70lOMSyf52yRkxCQKoQ84YhyswAdslITB j5dHm5F3Fcl8zwi8u2Z5hv0L1x+6dKeYM4kdH4GSKhsKlkiLYjqIY44HgH2RE8Kc gEHTJt9qg/VoLU0NqBntz4A+4iZC2O3qUa5BVTzMwion6RNa9B011CPkdlyTLR2h e9xlnDB7F+nVVwI0t+FExu8LpS8gHqUY7zPkIMsqX2zKXtwp52mlfDx3GEDjshYN Mu9LGJvF7vePK13bZ735VIo3JvV/CV8pJeC2ncgff9LOhEhOE6s3QxoFTgurOzTy WXvpN+d7nk5XGLI8g5IfLA+0JZ46T16pB6Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type: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= 1693010745; x=1693097145; bh=S8Fof8vLCs5YRuCkGaEaj0C33ZZZXm9nb3b eKcmd030=; b=LC59B0mOGivvT3VIXHNUM0gWTKPaitghiVsEq2rqbQBViJ5TTRf 96LnvJEEaB4tHQByMfkyLSQjvp1Hyerta3XM0D8jH1ul/TeS6nXYy0x2NdgMPzke +2xaeoY7CcBdKSE4NtVGM2DoSXyMS+8P2ddsXI0tn0gFUjSGgBg8ZJqzo2lKSJcl 3EthvcCW5IA03D84W07rTpD9563M4dAWd3X6sjSIx8q48LC4sq9g7v4Z7b+jYWo6 Ny52lNFy2jQMZQeSrN89o+akpecJBbrXTagMv3oku6cIruZnQXwA27lSyOQDy+wl oqjAYn9UaQprQPFx9q6L9gV26bqIdKjiG+Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedruddvledgfeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhephfffheeljeffgeffueeghfekkedtfffgheejvdegjeettdduheeufffggfef jeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 25 Aug 2023 20:45:43 -0400 (EDT) Content-Language: en-US In-Reply-To: <83ttsnoda5.fsf@gnu.org> 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:268453 Archived-At: On 25/08/2023 09:18, Eli Zaretskii wrote: >>> But here's a modification of the scenario that fails (again: both with >>> and without the patch): replace step 9 with >>> >>>   9. C-x v = >>> >>> The non-root diff looks a little different to begin with: it doesn't >>> show those ^M chars at the end of lines (whereas the result of >>> vc-root-diff shows them). That is likely the reason: buffer set up in a >>> different way. >> >> Looks like it's this line: >> >> (coding-system-for-read >> (if files (vc-coding-system-for-diff (car files)) 'undecided)) >> >> near the beginning of vc-diff-internal that creates the difference. >> Commenting it out makes the scenario work with both 'C-x v =' and 'C-x v D'. > > That code fragment is very old, so just removing it is scary, even if > only in master. Yeah, I noticed: it's from 2007 :-) > What if you change that fragment to say > > (coding-system-for-read > (if files (vc-coding-system-for-diff (car files)) 'undecided-unix)) > > instead? No change at all. The reasons are twofold: - You changed the value that was seemingly used for the "root" case, because in the individual diff's case files must not be nil: it would contain the files to be diff'd. That's why that change doesn't affect 'C-x v ='. - But it also doesn't affect 'C-x v D'. Because even in that case FILES is non-nil ;-(. In that scenario FILES is a list with one item: the repository's root directory. So we can conclude that this code is at least a little buggy. But... (*) > If that doesn't work, please tell to what value does > vc-diff-internal set coding-system-for-read in your case there, and I > will try to figure out what would needs to be done there. (vc-coding-system-for-diff (car files)) either returns 'undecided when FILES contains the directory (vc-root-diff), or 'undecided-dos when FILES contains hello.txt as the sole element (because our scenario made sure the file has that encoding), that's the vc-diff case. These are the values coding-system-for-read is set to. > (In general, I believe that using Git on Posix hosts with files that > have DOS EOLs could have such problems in other use cases, where diffs > are generated and then applied as patches. We just don't know about > those cases because they are extremely rare in Real Life.) I'm definitely curious which scenarios made Eric add that line. (*) ... upon some reflection, though, it seems like our success here is kind of relying on vc-root-diff's bug. Remember I mentioned the ^M chars appearing at the ends of lines? That is because the encoding of the diff buffer (utf-8-unix) doesn't match the encoding of the file (utf-8-dos). That only happens with the root diff, but not with vc-diff, which follows the old design and uses the return value of vc-coding-system-for-diff (undecided-dos). As luck would have it, though, our patch generation and application works well with the former behavior but not the latter. Still, Eric's old design did not make allowance for root diffs. Not sure what to do with that; though I suppose we could post-process the diff outputs instead: read the name of the first file in there, then detect its encoding on disk, and then re-decode the diff contents if the current value of buffer-file-coding-system doesn't match. And *then* we would need to fix vc-git-checkin-patch in that scenario (and maybe other backends as well). Or we decide that seeing ^M in diff buffers is a good thing under those conditions, and delete the line in question. WDYT?