git: Update cached checkout to the remote HEAD by default.
authorKyle Meyer <kyle@kyleam.com>
Sat, 10 Apr 2021 03:50:13 +0000 (23:50 -0400)
committerLudovic Courtès <ludo@gnu.org>
Sat, 10 Apr 2021 20:59:52 +0000 (22:59 +0200)
commitcb41c15827a2e910aa56fb5d1917ba8a085c95c7
tree7bddca672e5e0e7625069d2f90bec1d20df970c8
parentd7e57e2a5bad55415551fc2c53552142c32056d5
git: Update cached checkout to the remote HEAD by default.

Fixes <https://bugs.gnu.org/45187>.
Reported by Ricardo Wurmus <rekado@elephly.net>.

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): Change the default for REF
to the empty list and translate it to the remote HEAD symref.
(<git-checkout>): Change branch field's default to #f.
(git-checkout-compiler): When branch and commit fields are both #f, call
latest-repository-commit* with the empty list as the ref.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
guix/git.scm