Subject: Allow install package from git repo when autocrlf is true

From: "Yue Yi" <[email-masked]>
Date: Wed, 2 Apr 2025 09:17:16 +0800

Hello Emacs, As is well known, when compiling Emacs on Windows, it is best to set autocrlf to false before cloning the code to avoid issues with the autogen.sh script failing to run properly: git config --global core.autocrlf false Similarly, when autocrlf is set to true, installing a package via `package-vc-install' will result in the following error: Debugger entered--Lisp error: (error "Invalid version syntax: ‘0.2\15’")   error("Invalid version syntax: `%s'" "0.2\15")   version-to-list("0.2\15")   package-strip-rcs-id("0.2\15")   package-vc--version(#s(package-desc ...))   package-vc--generate-description-file(#s(package-desc ...))   package-vc--unpack-1(#s(package-desc ...))   package-vc--unpack(#s(package-desc ...))   package-vc-install("https://github.com/someone/some-package") In the error message above, \15 corresponds to decimal 13, which is the ASCII CR (displayed as ^M in Emacs). A simple inspection reveals that `lm-header', which is called within `package-vc--version', does not remove the trailing CR character. To address this, one possible solution is to modify the regular expression in lm-header to match and remove the CR character: diff --git a/lisp/emacs-lisp/lisp-mnt.el b/lisp/emacs-lisp/lisp-mnt.el index 111d512ef59..9cac77eb524 100644 --- a/lisp/emacs-lisp/lisp-mnt.el +++ b/lisp/emacs-lisp/lisp-mnt.el @@ -261,7 +261,7 @@ lm-header  		(if (save-excursion  		      (skip-chars-backward "^$" (match-beginning 0))  		      (= (point) (match-beginning 0))) -		    "[^\n]+" "[^$\n]+"))) +		    "[^\r\n]+" "[^$\r\n]+")))        (match-string-no-properties 0))))    (defun lm-header-multiline (header) However, at this point, the ^M characters in the buffer will affect the docstring, leading to numerous errors during byte compilation. Warning: docstring contains control char #x0d (position xxx) For this issue, is it a better choice to set autocrlf to input or false rather than modifying the code in package-vc?