Subject: git download defaults to origin/master

From: Ricardo Wurmus <[email-masked]>
Date: Fri, 11 Dec 2020 22:02:40 +0100

Importing https://github.com/immunogenomics/scpost with the CRAN
importer fails, because the git repository does not have an
origin/master branch.  This repository only has a “main” branch.

Arguably, this shouldn’t matter, but (guix git) has the “master” name
set up as the default.  When cloning a repository it may be better to
fetch everything and select the default branch — whichever name it may
have.

Here is a reproducer:

--8<---------------cut here---------------start------------->8---
$ guix import cran -r -a git https://github.com/immunogenomics/scpost
Backtrace:
In ice-9/boot-9.scm:
  1736:10 19 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
  1731:15 18 (with-exception-handler #<procedure 7f65768171e0 at ice-9/boot-9.scm:1815:7…> …)
In guix/scripts/import/cran.scm:
   103:26 17 (_)
In guix/import/utils.scm:
   458:31 16 (recursive-import "https://github.com/immunogenomics/scpost" # _ #:guix-name …)
   449:33 15 (lookup-node "https://github.com/immunogenomics/scpost" #f)
In guix/memoization.scm:
     98:0 14 (mproc "https://github.com/immunogenomics/scpost" #:version #f #:repo git)
In unknown file:
          13 (_ #<procedure 7f6576843ae0 at guix/memoization.scm:179:32 ()> #<procedure …> …)
In guix/import/cran.scm:
   576:24 12 (_ "https://github.com/immunogenomics/scpost" #:repo _ #:version _)
   269:25 11 (fetch-description _ "https://github.com/immunogenomics/scpost")
In guix/memoization.scm:
     98:0 10 (mproc "https://github.com/immunogenomics/scpost" #:method git)
In unknown file:
           9 (_ #<procedure 7f6576843a80 at guix/memoization.scm:179:32 ()> #<procedure …> …)
In ice-9/boot-9.scm:
  1736:10  8 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
In guix/store.scm:
   632:37  7 (thunk)
In guix/git.scm:
    424:8  6 (latest-repository-commit #<store-connection 256.99 7f6577201460> "https://…" …)
    240:2  5 (update-cached-checkout _ #:ref _ #:recursive? _ #:check-out? _ # _ # _ # _)
   208:19  4 (resolve _)
In git/branch.scm:
    101:8  3 (_ _ _ _)
In git/bindings.scm:
     77:2  2 (raise-git-error _)
In ice-9/boot-9.scm:
  1669:16  1 (raise-exception _ #:continuable? _)
  1669:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1669:16: In procedure raise-exception:
Git error: cannot locate remote-tracking branch 'origin/master'
--8<---------------cut here---------------end--------------->8---

-- 
Ricardo