From: Attila Lendvai <attila@lendvai.name>
To: 54893@debbugs.gnu.org
Cc: Attila Lendvai <attila@lendvai.name>
Subject: bug#54893: [PATCH] guix: git-download: Set locale to deal with Unicode in git metadata.
Date: Tue, 19 Apr 2022 20:09:55 +0200 [thread overview]
Message-ID: <20220419180954.9636-1-attila@lendvai.name> (raw)
In-Reply-To: <dgH8LAbYICFwRYBwMqWgymICHzzpPfoGjhJaxzv82-4I5UNd6NWdkLbJehfCHGTEpQk2KvGwhI0OIeRkSu2F85hvrJelJKM_Hv2OEwTp5B0=@lendvai.name>
Without this the git-fetch GEXP is run in an environment that uses ASCII
character encoding when strings are crossing the Guile - C boundary. It means
that e.g. tag names that have Unicode chars in them will cause problems,
e.g. when walking and deleting the .git directory.
An example in the wild: https://github.com/klauspost/pgzip/tags
For more details see: https://issues.guix.gnu.org/54893
* guix/git-download.scm (git-fetch): Call setlocale to set it to en_US.utf8.
---
thanks Maxime, this indeed seems to work! and i have successfully
guix pull'ed it, too.
guix/git-download.scm | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/guix/git-download.scm b/guix/git-download.scm
index 5e624b9ae9..2fc5a06490 100644
--- a/guix/git-download.scm
+++ b/guix/git-download.scm
@@ -104,6 +104,9 @@ (define guile-zlib
(define gnutls
(module-ref (resolve-interface '(gnu packages tls)) 'gnutls))
+ (define glibc-locales
+ (module-ref (resolve-interface '(gnu packages base)) 'glibc-locales))
+
(define modules
(delete '(guix config)
(source-module-closure '((guix build git)
@@ -121,6 +124,13 @@ (define build
(guix build download-nar)
(guix swh)
(ice-9 match))
+ ;; We must set the locale to something/anything that will make the
+ ;; Guile FFI use a character encoding that is idempotent through a
+ ;; bytes->string string->bytes roundtrip. Otherwise e.g. git tags
+ ;; with Unicode characters would break things. For more details
+ ;; and an example see https://issues.guix.gnu.org/54893
+ (setenv "GUIX_LOCPATH" #+(file-append glibc-locales "/lib/locale"))
+ (setlocale LC_ALL "en_US.utf8")
(define recursive?
(call-with-input-string (getenv "git recursive?") read))
--
2.35.1
next prev parent reply other threads:[~2022-04-19 18:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-12 19:47 bug#54893: guix-daemon, locale, LANG, and unicode in git tag names Attila Lendvai
2022-04-12 20:40 ` Maxime Devos
2022-04-13 7:51 ` Attila Lendvai
2022-04-13 8:03 ` Maxime Devos
2022-04-13 8:45 ` Attila Lendvai
2022-04-19 11:38 ` Attila Lendvai
2022-04-19 15:45 ` Maxime Devos
2022-04-19 16:07 ` Maxime Devos
2022-04-13 8:22 ` Maxime Devos
2022-04-13 10:40 ` Liliana Marie Prikler
2022-04-13 10:57 ` Maxime Devos
2022-04-13 8:29 ` Maxime Devos
2022-04-19 18:09 ` Attila Lendvai [this message]
2022-04-20 20:12 ` Ludovic Courtès
2022-04-20 22:15 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220419180954.9636-1-attila@lendvai.name \
--to=attila@lendvai.name \
--cc=54893@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).