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

From: Ludovic Courtès <[email-masked]>
Date: Fri, 09 Apr 2021 15:50:41 +0200

Hi!

Kyle Meyer <[email-masked]> skribis:

> Subject: [PATCH] git: Update cached checkout to the remote HEAD by default.
>
> Fixes <https://bugs.gnu.org/45187>.
> Reported by Ricardo Wurmus <[email-masked]>.
>
> update-cached-checkout hard codes "master" as the default branch, leading to a
> failure when the clone doesn't have a "master" branch.  Instead use the remote
> HEAD symref as an indicator of what the primary branch is.
>
> * guix/git.scm (resolve-reference): Support resolving symrefs.
> (update-cached-checkout, latest-repository-commit): Default to the remote HEAD
> symref.
> (<git-checkout>): Add symref field that defaults to "HEAD", and change branch
> field's default to #f.
> (git-checkout-compiler): Handle symref field of <git-checkout>.

[...]

>    git-checkout make-git-checkout
>    git-checkout?
>    (url     git-checkout-url)
> -  (branch  git-checkout-branch (default "master"))
> +  (branch  git-checkout-branch (default #f))
> +  (symref  git-checkout-symref (default "HEAD"))

I know it’s established Git jargon, but “symref” looks obscure to me.
I find it OK for ‘update-cached-checkout’, because it’s an “internal”
procedure for die-hard hackers, but a bit ugly here.

Another option would be to not add this ‘symref’ field and instead, when
‘branch’ and ‘commit’ are both #f, translate that to '(symref . "HEAD").

WDYT?

The rest of the patch LGTM, thanks!

Ludo’.