From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:54573) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOjod-0002Si-Ay for guix-patches@gnu.org; Wed, 15 Apr 2020 11:19:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jOjoc-0000x0-4u for guix-patches@gnu.org; Wed, 15 Apr 2020 11:19:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53622) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jOjoc-0000ww-2K for guix-patches@gnu.org; Wed, 15 Apr 2020 11:19:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jOjob-0001e7-Tu for guix-patches@gnu.org; Wed, 15 Apr 2020 11:19:01 -0400 Subject: [bug#40643] [PATCH] git-version: Handle invalid arguments gracefully Resent-Message-ID: Received: from eggs.gnu.org ([2001:470:142:3::10]:54536) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOjoG-0002OE-NF for guix-patches@gnu.org; Wed, 15 Apr 2020 11:18:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jOjoF-0000pQ-0s for guix-patches@gnu.org; Wed, 15 Apr 2020 11:18:40 -0400 Received: from pat.zlotemysli.pl ([37.59.186.212]:36144) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jOjoE-0000nY-Nr for guix-patches@gnu.org; Wed, 15 Apr 2020 11:18:38 -0400 From: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Date: Wed, 15 Apr 2020 17:18:23 +0200 Message-Id: <20200415151824.22988-1-kuba@kadziolka.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 40643@debbugs.gnu.org * guix/git-download.scm (git-version): Add a check for commit ID length. --- If you're curious for the motivation, see [1]. This took a while to debug, so I'm hoping to ease this for the next person who inevitably stumbles upon this. Is a change like this okay? [1]: http://logs.guix.gnu.org/guix/2020-04-14.log#162809 guix/git-download.scm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/guix/git-download.scm b/guix/git-download.scm index 1eae035fc4..40d81c72b9 100644 --- a/guix/git-download.scm +++ b/guix/git-download.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès ;;; Copyright © 2017 Mathieu Lirzin ;;; Copyright © 2017 Christopher Baines +;;; Copyright © 2020 Jakub Kądziołka ;;; ;;; This file is part of GNU Guix. ;;; @@ -30,6 +31,7 @@ #:use-module (ice-9 match) #:use-module (ice-9 vlist) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-35) #:export (git-reference git-reference? git-reference-url @@ -170,6 +172,13 @@ HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f." (define (git-version version revision commit) "Return the version string for packages using git-download." + ;; git-version is almost exclusively executed while modules are being loaded. + ;; This makes any errors hide their backtrace. Avoid the mysterious error + ;; "Value out of range 0 to N: 7" when the commit ID is too short, which + ;; can happen, for example, when the user swapped the revision and commit + ;; arguments by mistake. + (when (< (string-length commit) 7) + (error "git-version: commit ID unexpectedly short")) (string-append version "-" revision "." (string-take commit 7))) (define (git-file-name name version) -- 2.26.0