GNU bug report logs - #45187
git download defaults to origin/master

Previous Next

Package: guix;

Reported by: Ricardo Wurmus <rekado <at> elephly.net>

Date: Fri, 11 Dec 2020 21:04:02 UTC

Severity: normal

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Kyle Meyer <kyle <at> kyleam.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Ricardo Wurmus <rekado <at> elephly.net>, 45187 <at> debbugs.gnu.org, Marius Bakke <marius <at> gnu.org>
Subject: bug#45187: git download defaults to origin/master
Date: Tue, 15 Dec 2020 06:07:17 GMT
Ludovic Courtès writes:

>>  (define* (update-cached-checkout url
>>                                   #:key
>> -                                 (ref '(branch . "master"))
>> +                                 (ref '(symref . "refs/remotes/origin/HEAD"))
>>                                   recursive?
>>                                   (check-out? #t)
>>                                   starting-commit
>> @@ -395,7 +398,7 @@ (define* (latest-repository-commit store url
>>                                     (log-port (%make-void-port "w"))
>>                                     (cache-directory
>>                                      (%repository-cache-directory))
>> -                                   (ref '(branch . "master")))
>> +                                   (ref '(symref . "refs/remotes/origin/HEAD")))
>
> Do we really need to add “remotes/origin” in there?  Or is there a way
> to just say HEAD and later specify that we’re talking about the remote
> head, as is done fro branches?

Thanks for the feedback.  Sure, that sounds fine to me.  As far as I can
tell, in this context it'd make sense to assume HEAD should always be
the one under refs/remotes/origin.  (It really was a "quick check that
my suggestion to use the remote HEAD symref works" sort of patch :))

Another thing that doesn't feel suitable for the proper patch is the
introduction of the `symref' symbol...

> We also need to change the defaults in <git-checkout> & co., like Marius did.

...which didn't seem particularly nice to add as a field to
<git-checkout>.

However, without the introduction of something like `symref', I'm not
spotting a straightforward way to deal with refs/remotes/origin/HEAD in
resolve-reference.

FWIW if we were to go in the direction Marius suggested, I believe the
main change needed on top of Marius's patch in order to use the remote
symref would be

diff --git a/guix/git.scm b/guix/git.scm
index 0c49859e42..5caf715916 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -313,9 +313,7 @@ (define* (update-cached-checkout url
       (('branch . branch)
        `(branch . ,(if (string-prefix? "origin/" branch)
                        branch
-                       (if (string=? "HEAD" branch)
-                           branch
-                           (string-append "origin/" branch)))))
+                       (string-append "origin/" branch))))
       (_ ref)))
 
   (with-libgit2




This bug report was last modified 4 years and 101 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.