From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 19 14:12:06 2022 Received: (at 54893) by debbugs.gnu.org; 19 Apr 2022 18:12:06 +0000 Received: from localhost ([127.0.0.1]:44082 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ngsKc-000473-6k for submit@debbugs.gnu.org; Tue, 19 Apr 2022 14:12:06 -0400 Received: from mail-ej1-f53.google.com ([209.85.218.53]:37487) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ngsKa-00046Y-JH for 54893@debbugs.gnu.org; Tue, 19 Apr 2022 14:12:04 -0400 Received: by mail-ej1-f53.google.com with SMTP id g13so6859385ejb.4 for <54893@debbugs.gnu.org>; Tue, 19 Apr 2022 11:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oPMirPXaNqaUKVCh1kbQV00gtS/MM3BC36m6OU58du8=; b=TnSbaalwIAQJlcUL+UhksRApl4YimXFqCRRHt9G7wQf9cJhAOBq7qm0xqb2iOG3C9O SsRnu0JDgMZyLg39hft/4NCx+gZ2PvRhcGEebrZeYGmpezrj0cdu7hwqTS1DRcJXA38P kvB9QuPKlXhjEobd7zGAf/OMtBLhPhDqocaIQPcjyjmGsvdq2t8uEIetiTbSPxPTdhO6 wiezKpJwGbj+tMJdb/rMyYX7BQ6dxWy0KTz/GGoOw7U9p0xCsWAyVKHL1sI7xF21DZbq xeT8ONZ6jNDNi6OkvA3HvkYHfHuQMh7b9sQdCSIvVPqdMNo0JCVWXfX+jKRHCOeQ8kSS zRdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=oPMirPXaNqaUKVCh1kbQV00gtS/MM3BC36m6OU58du8=; b=A43HIK6QsUuwZdo8ZioCr9xeYIRy01/mbL65rjd0scnGnrcsovg/A9hKdQVbwwUmu7 JUSD87yjBvJrzEiJyS5XsQZQr0KWFfr5sPlOAaoc3+ilzLl6PTSZpzE6ha/FEbGAKmP0 h1Q52l3M7yCEypTVvATYshqEamJqiY3slqUN0gujT2buO+OkSHspPpZsyJn/C71LmMZs ECjAqvVIjXeWz2w8geackAsJyOwvFVBeHQ3Lt6TLew7xiPHaw8xa7Gk7TncWOENIGkXI eCBiP8b2RV5wt4beNxDuiu23f0eUWbb9Oo4ljaWt3Pnn/Dr+2Z8f4nAwkmFqpwxxFr2u IUYg== X-Gm-Message-State: AOAM530aLsHlszfZG2J10f3b/I8yX0QS2y6tn8AEaH4M9zTrRyp+xhHo zBhhNdMgatveaxjsML6DNacuNXSgkC4= X-Google-Smtp-Source: ABdhPJyFghx6sCVRNSND963jh0kllFzEkqQquSfaGCw6npscw4ySjN/3I8UMnIYRKJstXczN7XOxdQ== X-Received: by 2002:a17:907:a425:b0:6ef:8e2f:4215 with SMTP id sg37-20020a170907a42500b006ef8e2f4215mr11943199ejc.283.1650391918683; Tue, 19 Apr 2022 11:11:58 -0700 (PDT) Received: from lelap.local (catv-89-132-245-188.catv.fixed.vodafone.hu. [89.132.245.188]) by smtp.gmail.com with ESMTPSA id n16-20020a05640204d000b0042062f9f0e1sm8808264edw.15.2022.04.19.11.11.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 11:11:57 -0700 (PDT) From: Attila Lendvai To: 54893@debbugs.gnu.org Subject: [PATCH] guix: git-download: Set locale to deal with Unicode in git metadata. Date: Tue, 19 Apr 2022 20:09:55 +0200 Message-Id: <20220419180954.9636-1-attila@lendvai.name> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 54893 Cc: Attila Lendvai X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) 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