Message ID | c5156f9a756c2a6a304dc789c00abf533c787fd8.1692281315.git.zimon.toutoune@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id DAFC527BBEA; Thu, 17 Aug 2023 15:10:25 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A18A127BBE9 for <patchwork@mira.cbaines.net>; Thu, 17 Aug 2023 15:10:24 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces@gnu.org>) id 1qWdhT-00078s-Uf; Thu, 17 Aug 2023 10:10:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1qWdhP-00073A-2T for guix-patches@gnu.org; Thu, 17 Aug 2023 10:10:07 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1qWdhK-0006Yy-Mc for guix-patches@gnu.org; Thu, 17 Aug 2023 10:10:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1qWdhK-0007c5-If for guix-patches@gnu.org; Thu, 17 Aug 2023 10:10:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65352] [PATCH 1/2] guix: git: Fix the procedure reference-available?. References: <87fs4h4vb9.fsf@gmail.com> In-Reply-To: <87fs4h4vb9.fsf@gmail.com> Resent-From: Simon Tournier <zimon.toutoune@gmail.com> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 17 Aug 2023 14:10:02 +0000 Resent-Message-ID: <handler.65352.B65352.169228136729204@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65352 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 65352@debbugs.gnu.org Cc: Simon Tournier <zimon.toutoune@gmail.com> Received: via spool by 65352-submit@debbugs.gnu.org id=B65352.169228136729204 (code B ref 65352); Thu, 17 Aug 2023 14:10:02 +0000 Received: (at 65352) by debbugs.gnu.org; 17 Aug 2023 14:09:27 +0000 Received: from localhost ([127.0.0.1]:45276 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1qWdgl-0007aw-II for submit@debbugs.gnu.org; Thu, 17 Aug 2023 10:09:27 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:40296) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <zimon.toutoune@gmail.com>) id 1qWdgj-0007ad-DP for 65352@debbugs.gnu.org; Thu, 17 Aug 2023 10:09:26 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fe8d816a40so12946805e9.1 for <65352@debbugs.gnu.org>; Thu, 17 Aug 2023 07:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692281359; x=1692886159; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=w0VqyJE+c55ki3izHRi5NJ+lBrraHalgA8+CazbDL7Q=; b=BwZ4eChkpc/xjqZ5Xm5hCE6xcOqFf7NiV4lv6PQKi41xw8Y2Voh3oeuz5bE0Vs796H M/qfsutLaa+C7wADg/RSi7dNS45IitlUh6oeCR+h0rjUZiblk8d3FsBpXJ5RksIQSxzZ 7GNAkRnw/dskn8ADN/b3WjzvbQKlGmfyNuLtWvozSgIVUGKo7jEC+NtXI/f8DxmygCnN 8/9WQEPfgA22MpeOXMpQnL7a4FJfHvpJZO2O8u4tr2vbfyBRvBx7ntf8XVuuBX+lprmG U0dzi4ZEiphaSXliVaLAPVqDJH4/52S06C7SCGYPXrsAK4BsMa28YHmwTYofvkG6fQjf xSVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692281359; x=1692886159; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=w0VqyJE+c55ki3izHRi5NJ+lBrraHalgA8+CazbDL7Q=; b=JitL+yRqgD/y3qz31a75I2y3DvrCPa2eAvb46P2IEsp6xkx3DGybC77ecMuKyX1Fkk GLvUwnTWuSJGD6tL1Q2zdNKkm1I3HwHwvz5CUbfahxYHALeSUxAYsio7E0G8X7HdBzk4 zNTiKYn4xb5le/MnhQGVdEoEUOF8NBtFlFtsf++P5cJ517FIPGxxcTKmC/n3BTx5EH/I AegKMvv87UWtGLZiTDZRR2mVoxPJL0/K2zfsibwEqYTQCtTpRBfMhGKXO3G+4yYYnWjA KqwDqXZZ1baEOWe+2KUPCh1ESTJZPPhdhuiugZINTBsrRn9ycL9U+HQyenmaqSiAqpYR YI1Q== X-Gm-Message-State: AOJu0YwVzyI6hx2lUAS7JinIEWsXa3E4aCrN/yYO6zia6tHdsST/90ix kapishSpIExiWn0CuSC9lT5xJO8le+g= X-Google-Smtp-Source: AGHT+IHKSBnsvIl3bH5fwa+HfUlKALFj67Ro5gNq7cmrjAuOVWHvl3JbHFzAH7BPZErCelqhZ/HpOQ== X-Received: by 2002:a05:600c:4710:b0:3fb:aadc:41dc with SMTP id v16-20020a05600c471000b003fbaadc41dcmr4594824wmo.4.1692281359460; Thu, 17 Aug 2023 07:09:19 -0700 (PDT) Received: from localhost.localdomain ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id 10-20020a05600c228a00b003fe4ca8decdsm3135502wmf.31.2023.08.17.07.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 07:09:19 -0700 (PDT) From: Simon Tournier <zimon.toutoune@gmail.com> Date: Thu, 17 Aug 2023 16:09:16 +0200 Message-Id: <c5156f9a756c2a6a304dc789c00abf533c787fd8.1692281315.git.zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches |
Series |
[bug#65352,1/2] guix: git: Fix the procedure reference-available?.
|
|
Commit Message
Simon Tournier
Aug. 17, 2023, 2:09 p.m. UTC
* guix/git/scm (reference-available?): Rely of the procedure resolve-reference to determine if the reference belongs to the local Git checkout. --- guix/git.scm | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) base-commit: 1b2d43fe016848ea2ec16ff18cbc14340944fc4e
Comments
Hi! Simon Tournier <zimon.toutoune@gmail.com> skribis: > * guix/git/scm (reference-available?): Rely of the procedure resolve-reference > to determine if the reference belongs to the local Git checkout. LGTM too, thanks! Ludo’.
Hi again, Simon Tournier <zimon.toutoune@gmail.com> skribis: > * guix/git/scm (reference-available?): Rely of the procedure resolve-reference > to determine if the reference belongs to the local Git checkout. > --- > guix/git.scm | 13 ++----------- > 1 file changed, 2 insertions(+), 11 deletions(-) > > diff --git a/guix/git.scm b/guix/git.scm > index dbc3b7caa7..ebe2600209 100644 > --- a/guix/git.scm > +++ b/guix/git.scm > @@ -360,17 +360,8 @@ (define-syntax-rule (false-if-git-not-found exp) > (define (reference-available? repository ref) > "Return true if REF, a reference such as '(commit . \"cabba9e\"), is > definitely available in REPOSITORY, false otherwise." > - (match ref > - ((or ('commit . commit) > - ('tag-or-commit . (? commit-id? commit))) > - (let ((len (string-length commit)) > - (oid (string->oid commit))) > - (false-if-git-not-found > - (->bool (if (< len 40) > - (object-lookup-prefix repository oid len OBJ-COMMIT) > - (commit-lookup repository oid)))))) > - (_ > - #f))) > + (false-if-git-not-found > + (->bool (resolve-reference repository ref)))) > > (define (clone-from-swh url tag-or-commit output) > "Attempt to clone TAG-OR-COMMIT (a string), which originates from URL, using > > base-commit: 1b2d43fe016848ea2ec16ff18cbc14340944fc4e In fact, now I recall why that procedure was written that way: it’s meant to say whether a given commit (and only a commit) is already in the checkout, meaning we don’t need to pull. By definition, it’s an answer that can only be given for a specific commit; we cannot tell whether “master” or “HEAD” is available, that wouldn’t make sense. Thus, I think we need to revert a789dd58656d5f7f1b8edf790d77753fc71670af, and probably add a comment explaining why it’s written this way. Thoughts? Ludo’.
Hi, On Mon, 04 Sep 2023 at 11:32, Ludovic Courtès <ludo@gnu.org> wrote: > In fact, now I recall why that procedure was written that way: it’s > meant to say whether a given commit (and only a commit) is already in > the checkout, meaning we don’t need to pull. By definition, it’s an > answer that can only be given for a specific commit; we cannot tell > whether “master” or “HEAD” is available, that wouldn’t make sense. Yeah, that’s the job of ’reference-available?’ to say if a given reference is or not in the repository, IMHO. The patch I proposed earlier fixes the issue you reported, I guess. When debugging, I have noticed that this update-cached-checkout is called many times. For instance, 79ec651a286c71a3d4c72be33a1f80e76a560031 introduced a call. Investigating, I notice that this new procedure is incorrect: --8<---------------cut here---------------start------------->8--- (define (validate-guix-channel channels) "Finds the Guix channel among CHANNELS, and validates that REF as captured from the closure, a git reference specification such as a commit hash or tag associated to CHANNEL, is valid and new enough to satisfy the 'guix time-machine' requirements. A `formatted-message' condition is raised otherwise." (let* ((guix-channel (find guix-channel? channels)) (checkout commit relation (update-cached-checkout (channel-url guix-channel) #:ref (or ref '()) #:starting-commit %oldest-possible-commit))) --8<---------------cut here---------------end--------------->8--- Here, the symbol ’ref’ is bound by: (ref (assoc-ref opts 'ref)) which comes from: (option '("commit") #t #f (lambda (opt name arg result) (alist-cons 'ref `(tag-or-commit . ,arg) result))) (option '("branch") #t #f (lambda (opt name arg result) (alist-cons 'ref `(branch . ,arg) result))) Therefore, it means that when none of the options --commit= or --branch= is provided by the user at the CLI, this ’ref’ is bounded to #false. Therefore, it can lead to unexpected behaviour when providing a channels.scm file. Well, instead, the correct something like: (let* ((guix-channel (find guix-channel? channels)) (reference (or ref (match (channel-commit guix-channel) (#f `(branch . ,(channel-branch guix-channel))) (commit `(tag-or-commit . ,commit))))) (checkout commit relation (update-cached-checkout (channel-url guix-channel) #:ref reference #:starting-commit %oldest-possible-commit))) which works using my tests (with or without network). The remaining issue is the order when displaying messages. This ’validate-guix-channel’ happens before “Updating channel 'guix'” therefore the progress bar appears before etc. I have not investigated how to improve cached-channel-instance. Let me know if the current tiny fix tweaking resolve-interface is enough for now waiting some rework of validate-guix-channel. :-) Cheers, simon
Hi, Simon Tournier <zimon.toutoune@gmail.com> writes: > * guix/git/scm (reference-available?): Rely of the procedure resolve-reference > to determine if the reference belongs to the local Git checkout. > --- > guix/git.scm | 13 ++----------- > 1 file changed, 2 insertions(+), 11 deletions(-) > > diff --git a/guix/git.scm b/guix/git.scm > index dbc3b7caa7..ebe2600209 100644 > --- a/guix/git.scm > +++ b/guix/git.scm > @@ -360,17 +360,8 @@ (define-syntax-rule (false-if-git-not-found exp) > (define (reference-available? repository ref) > "Return true if REF, a reference such as '(commit . \"cabba9e\"), is > definitely available in REPOSITORY, false otherwise." > - (match ref > - ((or ('commit . commit) > - ('tag-or-commit . (? commit-id? commit))) > - (let ((len (string-length commit)) > - (oid (string->oid commit))) > - (false-if-git-not-found > - (->bool (if (< len 40) > - (object-lookup-prefix repository oid len OBJ-COMMIT) > - (commit-lookup repository oid)))))) > - (_ > - #f))) > + (false-if-git-not-found > + (->bool (resolve-reference repository ref)))) This was applied some time ago as a789dd58656d5f7f1b8edf790d77753fc71670af. Closing.
Hi Maxim, On Tue, 5 Sept 2023 at 15:24, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote: > This was applied some time ago as > a789dd58656d5f7f1b8edf790d77753fc71670af. Thanks for having applied it. > Closing. However, I do not think it should be closed. Maybe you have missed: [bug#65352] Fix time-machine and network Ludovic Courtès <ludo@gnu.org> Mon, 04 Sep 2023 10:49:24 +0200 id:87wmx6qq5n.fsf_-_@gnu.org https://issues.guix.gnu.org//65352 https://issues.guix.gnu.org/msgid/87wmx6qq5n.fsf_-_@gnu.org https://yhetil.org/guix/87wmx6qq5n.fsf_-_@gnu.org And this thread contains some fixes. Well, from my point of view, the discussion is still pending... Cheers, simon
Hi, Ludovic Courtès <ludo@gnu.org> writes: > Hi again, > > Simon Tournier <zimon.toutoune@gmail.com> skribis: > >> * guix/git/scm (reference-available?): Rely of the procedure resolve-reference >> to determine if the reference belongs to the local Git checkout. >> --- >> guix/git.scm | 13 ++----------- >> 1 file changed, 2 insertions(+), 11 deletions(-) >> >> diff --git a/guix/git.scm b/guix/git.scm >> index dbc3b7caa7..ebe2600209 100644 >> --- a/guix/git.scm >> +++ b/guix/git.scm >> @@ -360,17 +360,8 @@ (define-syntax-rule (false-if-git-not-found exp) >> (define (reference-available? repository ref) >> "Return true if REF, a reference such as '(commit . \"cabba9e\"), is >> definitely available in REPOSITORY, false otherwise." >> - (match ref >> - ((or ('commit . commit) >> - ('tag-or-commit . (? commit-id? commit))) >> - (let ((len (string-length commit)) >> - (oid (string->oid commit))) >> - (false-if-git-not-found >> - (->bool (if (< len 40) >> - (object-lookup-prefix repository oid len OBJ-COMMIT) >> - (commit-lookup repository oid)))))) >> - (_ >> - #f))) >> + (false-if-git-not-found >> + (->bool (resolve-reference repository ref)))) >> >> (define (clone-from-swh url tag-or-commit output) >> "Attempt to clone TAG-OR-COMMIT (a string), which originates from URL, using >> >> base-commit: 1b2d43fe016848ea2ec16ff18cbc14340944fc4e > > In fact, now I recall why that procedure was written that way: it’s > meant to say whether a given commit (and only a commit) is already in > the checkout, meaning we don’t need to pull. By definition, it’s an > answer that can only be given for a specific commit; we cannot tell > whether “master” or “HEAD” is available, that wouldn’t make sense. > > Thus, I think we need to revert > a789dd58656d5f7f1b8edf790d77753fc71670af, and probably add a comment > explaining why it’s written this way. > > Thoughts? I've reviewed this thread and the code, and I agree. This is a special case. I've added a comment so we aren't tempted to use 'resolve-reference' there again. Will install shortly.
Hi Maxim, On Tue, 05 Sep 2023 at 16:39, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote: > I've reviewed this thread and the code, and I agree. This is a special > case. I've added a comment so we aren't tempted to use > 'resolve-reference' there again. I disagree. There is no special case. The culprit is the procedure ’validate-guix-channel’ as explained in: [bug#65352] Fix time-machine and network Simon Tournier <zimon.toutoune@gmail.com> Mon, 04 Sep 2023 19:37:08 +0200 id:87wmx5on5n.fsf@gmail.com https://issues.guix.gnu.org//65352 https://issues.guix.gnu.org/msgid/87wmx5on5n.fsf@gmail.com https://yhetil.org/guix/87wmx5on5n.fsf@gmail.com > Will install shortly. I do not know what you will install shortly. The fix belong to validate-guix-channel, something like: (let* ((guix-channel (find guix-channel? channels)) (reference (or ref (match (channel-commit guix-channel) (#f `(branch . ,(channel-branch guix-channel))) (commit `(tag-or-commit . ,commit))))) (checkout commit relation (update-cached-checkout (channel-url guix-channel) #:ref reference #:starting-commit %oldest-possible-commit))) and that would avoid to break the “contract” of resolve-reference. Before committing something, I was testing. Cheers, simon
Hi Simon, Simon Tournier <zimon.toutoune@gmail.com> writes: > Hi Maxim, > > On Tue, 5 Sept 2023 at 15:24, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote: > >> This was applied some time ago as >> a789dd58656d5f7f1b8edf790d77753fc71670af. > > Thanks for having applied it. > >> Closing. > > However, I do not think it should be closed. Maybe you have missed: > > [bug#65352] Fix time-machine and network > Ludovic Courtès <ludo@gnu.org> > Mon, 04 Sep 2023 10:49:24 +0200 > id:87wmx6qq5n.fsf_-_@gnu.org > https://issues.guix.gnu.org//65352 > https://issues.guix.gnu.org/msgid/87wmx6qq5n.fsf_-_@gnu.org > https://yhetil.org/guix/87wmx6qq5n.fsf_-_@gnu.org > > And this thread contains some fixes. Well, from my point of view, the > discussion is still pending... I had indeed missed its continuation! I've reverted a789dd5865 with 756e336fa0 and installed c3d48d024, which should now validate the branch/commit of a channel file as well.
Hi Simon, Simon Tournier <zimon.toutoune@gmail.com> writes: [...] > Well, instead, the correct something like: > > (let* ((guix-channel (find guix-channel? channels)) > (reference (or ref > (match (channel-commit guix-channel) > (#f `(branch . ,(channel-branch guix-channel))) > (commit `(tag-or-commit . ,commit))))) > (checkout commit relation (update-cached-checkout > (channel-url guix-channel) > #:ref reference > #:starting-commit > %oldest-possible-commit))) > > which works using my tests (with or without network). I've installed something along this with c3d48d0. If there are other issues, I think it'd be best if they are described clearly in a new issue, as that one is getting crowded :-).
Hi Maxim, On Wed, 6 Sept 2023 at 02:04, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote: > I had indeed missed its continuation! I've reverted a789dd5865 with > 756e336fa0 and installed c3d48d024, which should now validate the > branch/commit of a channel file as well. Thanks for the follow up. The other issue about the order of the progress bar and the message "Updating guix ..." is not yet fixed. :-) I am fine to open another issue for that but since it appears to me the same patch series as this one. Well you are applying patches faster than I am able to process my emails or comment your messages. ;-) Anyway, I will open a report for that order issue. However, this bug #65352 is not done. https://issues.guix.gnu.org/65352#0 The bug I report is, for instance, consider "guix time-machine --commit=v1.4.0", this will pass (tag-or-commit . "v1.4.0") as REF to reference-available? which is not a commit-id? if I read correctly. And so reference-available? will return #f triggered an network update when the reference if already in the cache checkout. It is similar with short commit hash as "guix time-machine --commit=4a027d2". That's what I reported. I am fine with the revert 756e336fa008c2469b4a7317ad5c641ed48f25d6 waiting my fix for what I am reporting. But I disagree with the comment because that's incorrect. In order to detect the tag or commit string, the procedure reference-available? needs to implement the string tag case and the short commit hash case, something like: (('tag-or-commit . str) (cond ((and (string-contains str "-g") (match (string-split str #\-) ((version ... revision g+commit) (if (and (> (string-length g+commit) 4) (string-every char-set:digit revision) (string-every char-set:hex-digit (string-drop g+commit 1))) ;; Looks like a 'git describe' style ID, like ;; v1.3.0-7-gaa34d4d28d. (string-drop g+commit 1) #f)) (_ #f))) => (lambda (commit) (resolve `(commit . ,commit)))) ((or (> (string-length str) 40) (not (string-every char-set:hex-digit str))) (resolve `(tag . ,str))) ;definitely a tag (else (catch 'git-error (lambda () (resolve `(tag . ,str))) (lambda _ ;; There's no such tag, so it must be a commit ID. (resolve `(commit . ,str))))))) which is the same as resolve-reference. ;-) Hence my proposal. I agree with your words: if REF passed to reference-available? is not a valid REF defined by the docstring of update-cached-checkout, it means that the "contract" is broken and so there is a bug. It appears to me inconsistent to allow the clause (_ #f) in reference-available? and not in resolve-reference. Therefore, the change I proposed that is now reverted has just exposed the bug. :-) All in all, this issue should be kept open. Cheers, simon
reopen 65352 quit Hi Simon, Simon Tournier <zimon.toutoune@gmail.com> writes: > Hi Maxim, > > On Wed, 6 Sept 2023 at 02:04, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote: > >> I had indeed missed its continuation! I've reverted a789dd5865 with >> 756e336fa0 and installed c3d48d024, which should now validate the >> branch/commit of a channel file as well. > > Thanks for the follow up. > > The other issue about the order of the progress bar and the message > "Updating guix ..." is not yet fixed. :-) I am fine to open another > issue for that but since it appears to me the same patch series as > this one. Well you are applying patches faster than I am able to > process my emails or comment your messages. ;-) Anyway, I will open a > report for that order issue. OK, thank you. It's a bit hard to keep track of multiple issues and their resolutions in a longish thread. > However, this bug #65352 is not done. > > https://issues.guix.gnu.org/65352#0 > > The bug I report is, for instance, consider "guix time-machine > --commit=v1.4.0", this will pass (tag-or-commit . "v1.4.0") as REF to > reference-available? which is not a commit-id? if I read correctly. > And so reference-available? will return #f triggered an network update > when the reference if already in the cache checkout. I don't know if we want to consider tags are immutable or not; the safest is to consider them an *not* immutable, which is what we had been doing. I agree it doesn't cover all the potential git refspecs; we can get there if we want (although I suppose it's uncommon for someone to try 'guix time-machine --commit=v1.3.0-47405-ge0767a24d0' or similar). > It is similar with short commit hash as "guix time-machine > --commit=4a027d2". That's what I reported. I'm not sure if short commit IDs should be treated as immutable, since in theory they can collide; the safest would be to check if there are collisions and report an error if there is; and this requires fetching new objects first. So, what is the behavior that we want?
Hi, Simon Tournier <zimon.toutoune@gmail.com> writes: > Hi Maxim, > > On Tue, 05 Sep 2023 at 16:39, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote: > >> I've reviewed this thread and the code, and I agree. This is a special >> case. I've added a comment so we aren't tempted to use >> 'resolve-reference' there again. > > I disagree. There is no special case. The culprit is the procedure > ’validate-guix-channel’ as explained in: I was referring to the special case of resolved-reference? (that it mustn't trust tags or branches in a git cache -- at least currently, compared to resolve-reference. Maybe we want to change that? > [bug#65352] Fix time-machine and network > Simon Tournier <zimon.toutoune@gmail.com> > Mon, 04 Sep 2023 19:37:08 +0200 > id:87wmx5on5n.fsf@gmail.com > https://issues.guix.gnu.org//65352 > https://issues.guix.gnu.org/msgid/87wmx5on5n.fsf@gmail.com > https://yhetil.org/guix/87wmx5on5n.fsf@gmail.com > > >> Will install shortly. > > I do not know what you will install shortly. The fix belong to > validate-guix-channel, something like: > > (let* ((guix-channel (find guix-channel? channels)) > (reference (or ref > (match (channel-commit guix-channel) > (#f `(branch . ,(channel-branch guix-channel))) > (commit `(tag-or-commit . ,commit))))) > (checkout commit relation (update-cached-checkout > (channel-url guix-channel) > #:ref reference > #:starting-commit > %oldest-possible-commit))) > > and that would avoid to break the “contract” of resolve-reference. > Before committing something, I was testing. That's orthogonal to the other issue discussed, right? What I was referring to about 'installing' was c3d48d02, which implements the above (with let-bound variables and 'if' instead of match, but the logic is the same). I feel like we need to agree on what reference-available? is supposed to achieve, and where it needs to differentiate from resolve-reference.
Hi, On Tue, 05 Sep 2023 at 22:00, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote: >> Anyway, I will open a >> report for that order issue. > > OK, thank you. It's a bit hard to keep track of multiple issues and > their resolutions in a longish thread. For cross-referencing, done with bug#65788, bug#65788: poor information when updating using “guix time-machine” Simon Tournier <zimon.toutoune@gmail.com> Wed, 06 Sep 2023 18:57:38 +0200 id:87pm2vme7x.fsf@gmail.com https://yhetil.org/guix/87pm2vme7x.fsf@gmail.com https://issues.guix.gnu.org/msgid/87pm2vme7x.fsf@gmail.com Cheers, simon
diff --git a/guix/git.scm b/guix/git.scm index dbc3b7caa7..ebe2600209 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -360,17 +360,8 @@ (define-syntax-rule (false-if-git-not-found exp) (define (reference-available? repository ref) "Return true if REF, a reference such as '(commit . \"cabba9e\"), is definitely available in REPOSITORY, false otherwise." - (match ref - ((or ('commit . commit) - ('tag-or-commit . (? commit-id? commit))) - (let ((len (string-length commit)) - (oid (string->oid commit))) - (false-if-git-not-found - (->bool (if (< len 40) - (object-lookup-prefix repository oid len OBJ-COMMIT) - (commit-lookup repository oid)))))) - (_ - #f))) + (false-if-git-not-found + (->bool (resolve-reference repository ref)))) (define (clone-from-swh url tag-or-commit output) "Attempt to clone TAG-OR-COMMIT (a string), which originates from URL, using