From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joaotavora@gmail.com (=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?=) Newsgroups: gmane.emacs.bugs Subject: bug#20892: 25.0.50; Applying vc-diff hunks on CRLF tracked files Date: Wed, 24 Jun 2015 12:29:05 +0100 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1435145451 2842 80.91.229.3 (24 Jun 2015 11:30:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 24 Jun 2015 11:30:51 +0000 (UTC) To: 20892@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jun 24 13:30:38 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z7it4-0002AR-77 for geb-bug-gnu-emacs@m.gmane.org; Wed, 24 Jun 2015 13:30:38 +0200 Original-Received: from localhost ([::1]:49980 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7it3-0002xV-By for geb-bug-gnu-emacs@m.gmane.org; Wed, 24 Jun 2015 07:30:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7isd-0002PY-IO for bug-gnu-emacs@gnu.org; Wed, 24 Jun 2015 07:30:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z7isa-0004Bl-Au for bug-gnu-emacs@gnu.org; Wed, 24 Jun 2015 07:30:11 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54433) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7isa-0004BZ-7e for bug-gnu-emacs@gnu.org; Wed, 24 Jun 2015 07:30:08 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Z7isY-0003zi-P0 for bug-gnu-emacs@gnu.org; Wed, 24 Jun 2015 07:30:07 -0400 X-Loop: help-debbugs@gnu.org Resent-From: joaotavora@gmail.com (=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Jun 2015 11:30:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 20892 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.143514536615269 (code B ref -1); Wed, 24 Jun 2015 11:30:05 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 Jun 2015 11:29:26 +0000 Original-Received: from localhost ([127.0.0.1]:55879 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z7irs-0003yC-Ve for submit@debbugs.gnu.org; Wed, 24 Jun 2015 07:29:25 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:39522) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z7irq-0003y0-Ts for submit@debbugs.gnu.org; Wed, 24 Jun 2015 07:29:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z7irk-0003Kw-Kn for submit@debbugs.gnu.org; Wed, 24 Jun 2015 07:29:17 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:37784) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7irk-0003Kq-HY for submit@debbugs.gnu.org; Wed, 24 Jun 2015 07:29:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7irj-0002Ib-5X for bug-gnu-emacs@gnu.org; Wed, 24 Jun 2015 07:29:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z7irf-0003I3-30 for bug-gnu-emacs@gnu.org; Wed, 24 Jun 2015 07:29:15 -0400 Original-Received: from mail-wi0-x22c.google.com ([2a00:1450:400c:c05::22c]:33169) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7ire-0003Ey-SM for bug-gnu-emacs@gnu.org; Wed, 24 Jun 2015 07:29:11 -0400 Original-Received: by wiwl6 with SMTP id l6so92399705wiw.0 for ; Wed, 24 Jun 2015 04:29:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding; bh=Pxn0Uhxa+nBz/+taDeI40tkMzmNvwc/qR1YbapeGGvE=; b=Oj/Nra6ygMrgLg2QdNDmQd7uh+MQUbOr8KXcYNNEMLrDS8OxfUl+hf0YnKpp+iqCKn /5+XYMuInR9B5OE4Yc50jpIxmLubLOzKOdCsA07GD+bHBHE+zJCP0gwK8Jcz4GYHJ9Jy X6l8rFu4lfcMVeLEBbVex92xHJ/wAka8GHRKmGlFBqbG22kDFypAGJ7hT2/hWWqOVKOj xOhDeoPR67nZ79lRCGl+OziNUdhqYaZZBOGhYj9OUuFoHVQHkkkgOJ58jUWQ5YthFRPY YHZrmYrmKQLImXjBHhhdAosHYhfwQ/LcE+LCQzfewcNUVuQNX601bbmaxA9EP41urYbY 4g7w== X-Received: by 10.195.17.199 with SMTP id gg7mr71473257wjd.121.1435145349690; Wed, 24 Jun 2015 04:29:09 -0700 (PDT) Original-Received: from GONDOMAR.yourcompany.com (53.236.108.93.rev.vodafone.pt. [93.108.236.53]) by mx.google.com with ESMTPSA id d3sm2075524wic.1.2015.06.24.04.29.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jun 2015 04:29:08 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (windows-nt) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:104296 Archived-At: Hello maintainers, 1. Navigate to a repository where files are tracked with CRLF line endings. =20=20=20 2. Modify one of those files. 3. Use M-x vc-root-diff. Observe how, in the latest trunk, the carriage return (represented as ^M) are visible as a part of the diff hunk's content. This is correct, in my opinion, if a little visually distracting. 4. Undo of of those diffs with C-c C-a 5. Redo the same hunk with C-c C-a again 6. Notive how diff-apply-hunk incorrectly applies the carriage return characters themselves. Here's a trivial patch to lisp/vc/diff-mode.el, or simply cherry-pick the commit=20 7ed2b6299425c4b2ea6bd8d8e8eb5eaa5e5ddf7e which is available in this url https://github.com/capitaomorte/emacs.git @@ -1799,7 +1799,8 @@=20 (with-current-buffer buf (goto-char (car pos)) (delete-region (car pos) (cdr pos)) - (insert (car new))) + (insert (decode-coding-string (car new) + buffer-file-coding-system))) ;; Display BUF in a window (set-window-point (display-buffer buf) (+ (car pos) (cdr new))) (diff-hunk-status-msg line-offset (diff-xor switched reverse) nil) The commit message is Consider coding system when applying diff-mode hunks. =20=20=20=20=20 Without this, applying hunks may garble line endings in the destination buffer. =20=20=20=20=20 * lisp/vc/diff-mode.el (diff-apply-hunk): Use decode-coding-string and buffer-file-coding-system. =20=20=20=20=20=20 Sorry I couldn't properly inline a patch, Thanks, Jo=E3o