Subject: bug#45187: git download defaults to origin/master

From: Ludovic Courtès <[email-masked]>
Date: Mon, 14 Dec 2020 11:28:56 +0100

Hi,

Kyle Meyer <[email-masked]> skribis:

> diff --git a/guix/git.scm b/guix/git.scm
> index ca77b9f54b..7320c0d6c8 100644
> --- a/guix/git.scm
> +++ b/guix/git.scm
> @@ -207,6 +207,9 @@ (define (resolve-reference repository ref)
>         (let ((oid (reference-target
>                     (branch-lookup repository branch BRANCH-REMOTE))))
>           (object-lookup repository oid)))
> +      (('symref . symref)
> +       (let ((oid (reference-name->oid repository symref)))
> +         (object-lookup repository oid)))
>        (('commit . commit)
>         (let ((len (string-length commit)))
>           ;; 'object-lookup-prefix' appeared in Guile-Git in Mar. 2018, so we
> @@ -320,7 +323,7 @@ (define (reference-available? repository ref)
>  
>  (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?

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

Thanks,
Ludo’.