git: Override the user’s ‘core.autocrlf’ settings.

Fixes <https://issues.guix.gnu.org/77214>.

Fixes a bug whereby setting ‘core.autocrlf’ to ‘true’ in ~/.gitconfig
would lead ‘guix pull’ & co. to obtain non-bit-identical files,
including possibly syntactically-invalid Scheme files.

* guix/git.scm (clone*): Set ‘core.autocrlf’ to ‘input’.

Reported-by: Jodi Jodingtonstinski <jodijodingtondev@gmail.com>
Change-Id: I11fb20813a9fc1e14828ca8ebf5092c4b1181e5c
This commit is contained in:
Ludovic Courtès 2025-04-14 16:54:45 +02:00
parent 0502a30d31
commit b5e567bb2b
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2018-2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018-2025 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2021 Kyle Meyer <kyle@kyleam.com>
;;; Copyright © 2021 Marius Bakke <marius@gnu.org>
;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
@ -236,10 +236,18 @@ make sure no empty directory is left behind."
(lambda ()
(mkdir-p directory)
(let* ((repository
(clone url directory
(make-clone-options
#:fetch-options (make-default-fetch-options
#:verify-certificate? verify-certificate?))))
#:verify-certificate?
verify-certificate?))))
(config (repository-config repository)))
;; Override 'core.autocrlf' as set in ~/.gitconfig to ensure files are
;; left unchanged when cloning and pulling.
(set-config-string config "core.autocrlf" "input")
repository))
(lambda _
(false-if-exception (rmdir directory)))))