From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#65049: Minor update to the repro steps Date: Wed, 23 Aug 2023 19:21:06 +0300 Message-ID: <831qftspal.fsf@gnu.org> 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> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5737"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65049@debbugs.gnu.org, juri@linkov.net To: Maxim Kim , Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 23 18:21:39 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 1qYqby-0001I8-52 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 23 Aug 2023 18:21:38 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qYqba-000437-Rf; Wed, 23 Aug 2023 12:21:14 -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 1qYqbK-00042S-Tj for bug-gnu-emacs@gnu.org; Wed, 23 Aug 2023 12:20:58 -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 1qYqbK-0000Sm-Ku for bug-gnu-emacs@gnu.org; Wed, 23 Aug 2023 12:20:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qYqbO-0000MR-0c for bug-gnu-emacs@gnu.org; Wed, 23 Aug 2023 12:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 23 Aug 2023 16:21:01 +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.16928076591371 (code B ref 65049); Wed, 23 Aug 2023 16:21:01 +0000 Original-Received: (at 65049) by debbugs.gnu.org; 23 Aug 2023 16:20:59 +0000 Original-Received: from localhost ([127.0.0.1]:34974 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYqbK-0000M3-RX for submit@debbugs.gnu.org; Wed, 23 Aug 2023 12:20:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47360) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYqbG-0000Lk-Dy for 65049@debbugs.gnu.org; Wed, 23 Aug 2023 12:20:57 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qYqb6-0000OU-V4; Wed, 23 Aug 2023 12:20:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=GsP9hZ7p6e5r5nBM2UxmGIbQKerkliZ0ev59wZOEhLQ=; b=SXhAVzpE6aQq ZXIkxN+UC4qyT3fbIdRgFw3MSHCN5r8iPG/0ZyyVoHLnFjZ5P0hJGowM81i6qLxq77AG3EPoI0/Qa pESlIt+9eYyE1NChMQIvyJGa89DuOjtqglvPGNzbjrM1NCvp6qCqyVIvF7IDqfitw6pUT81REBME9 v2lvGX17/cil09Vez6MdNgl1lF+R7uq0ExkZQD20bmihzYHe727RPNaNL0qUlojiAlrc51n1hFou5 Bl3XpMJo99CX6kKCLNzUaEoYE9RUKbeVsNRKb194vAomrI11jhtfGc81zxAOOfkGwpBdJsjLxhjF4 Fqv4aEWscF7o3mqWHmftrQ==; In-Reply-To: (message from Maxim Kim on Wed, 23 Aug 2023 14:28:10 +1000) 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:268256 Archived-At: > From: Maxim Kim > Cc: juri@linkov.net, 65049@debbugs.gnu.org > Date: Wed, 23 Aug 2023 14:28:10 +1000 > > Eli Zaretskii writes: > > So, it works for the repo with files having windows CRLF. > And doesn't work if the file has EOL type: LF. Thanks, this finally allowed me to nail the sucker. The fix is a bit more complex than I thought, because this bug has two parts: one of them in "C-x v D", the other in vc-git-checkin. The patch is below; please give it a try with all your real-life use cases. Dmitry, do you see any problems with installing this on the release branch? Or do you prefer to keep it on master for a while, and then backport if no one complains? diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 7ae763d..218696c 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1051,7 +1051,15 @@ vc-git-checkin (user-error "Index not empty")) (setq pos (point)))))) (unless (string-empty-p vc-git-patch-string) - (let ((patch-file (make-nearby-temp-file "git-patch"))) + (let ((patch-file (make-nearby-temp-file "git-patch")) + ;; Temporarily countermand the let-binding at the + ;; beginning of this function. + (coding-system-for-write + (coding-system-change-eol-conversion + ;; On DOS/Windows, it is important for the patch file + ;; to have the Unix EOL format, because Git expects + ;; that, even on Windows. + (or pcsw vc-git-commits-coding-system) 'unix))) (with-temp-file patch-file (insert vc-git-patch-string)) (unwind-protect diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 410fe5c..4e008de 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1917,8 +1917,12 @@ vc-diff-internal (generate-new-buffer-name " *vc-diff-clone*") nil)))) ;; 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. - (if (memq system-type '(windows-nt ms-dos)) + ;; EOLs. But for Git, we must force Unix EOLs in the diffs, since + ;; Git always produces Unix EOLs in the parts that didn't come + ;; from the file, and wants to see any CR characters when applying + ;; patches. + (if (and (memq system-type '(windows-nt ms-dos)) + (not (eq (vc-deduce-backend) 'Git))) (setq coding-system-for-read (coding-system-change-eol-conversion coding-system-for-read 'dos)))