git: Don't require users to specifiy "origin/" for branches.
Fixes <https://bugs.gnu.org/32618>. Reported by Eric Brown <brown@fastmail.com>. * guix/git.scm (update-cached-checkout): Remove "origin/" from default REF. Define CANONICAL-REF and use it instead of REF. (latest-repository-commit): Remove "origin/" from default REF. * guix/channels.scm (%default-channels): Remove "origin/" from 'branch'.master
parent
cb341c1219
commit
37a6cdbf1b
|
@ -78,7 +78,7 @@
|
||||||
;; Default list of channels.
|
;; Default list of channels.
|
||||||
(list (channel
|
(list (channel
|
||||||
(name 'guix)
|
(name 'guix)
|
||||||
(branch "origin/master")
|
(branch "master")
|
||||||
(url "https://git.savannah.gnu.org/git/guix.git"))))
|
(url "https://git.savannah.gnu.org/git/guix.git"))))
|
||||||
|
|
||||||
(define (guix-channel? channel)
|
(define (guix-channel? channel)
|
||||||
|
|
17
guix/git.scm
17
guix/git.scm
|
@ -112,7 +112,7 @@ OID (roughly the commit hash) corresponding to REF."
|
||||||
|
|
||||||
(define* (update-cached-checkout url
|
(define* (update-cached-checkout url
|
||||||
#:key
|
#:key
|
||||||
(ref '(branch . "origin/master"))
|
(ref '(branch . "master"))
|
||||||
(cache-directory
|
(cache-directory
|
||||||
(url-cache-directory
|
(url-cache-directory
|
||||||
url (%repository-cache-directory))))
|
url (%repository-cache-directory))))
|
||||||
|
@ -122,6 +122,17 @@ to REF.
|
||||||
|
|
||||||
REF is pair whose key is [branch | commit | tag] and value the associated
|
REF is pair whose key is [branch | commit | tag] and value the associated
|
||||||
data, respectively [<branch name> | <sha1> | <tag name>]."
|
data, respectively [<branch name> | <sha1> | <tag name>]."
|
||||||
|
(define canonical-ref
|
||||||
|
;; We used to require callers to specify "origin/" for each branch, which
|
||||||
|
;; made little sense since the cache should be transparent to them. So
|
||||||
|
;; here we append "origin/" if it's missing and otherwise keep it.
|
||||||
|
(match ref
|
||||||
|
(('branch . branch)
|
||||||
|
`(branch . ,(if (string-prefix? "origin/" branch)
|
||||||
|
branch
|
||||||
|
(string-append "origin/" branch))))
|
||||||
|
(_ ref)))
|
||||||
|
|
||||||
(with-libgit2
|
(with-libgit2
|
||||||
(let* ((cache-exists? (openable-repository? cache-directory))
|
(let* ((cache-exists? (openable-repository? cache-directory))
|
||||||
(repository (if cache-exists?
|
(repository (if cache-exists?
|
||||||
|
@ -130,7 +141,7 @@ data, respectively [<branch name> | <sha1> | <tag name>]."
|
||||||
;; Only fetch remote if it has not been cloned just before.
|
;; Only fetch remote if it has not been cloned just before.
|
||||||
(when cache-exists?
|
(when cache-exists?
|
||||||
(remote-fetch (remote-lookup repository "origin")))
|
(remote-fetch (remote-lookup repository "origin")))
|
||||||
(let ((oid (switch-to-ref repository ref)))
|
(let ((oid (switch-to-ref repository canonical-ref)))
|
||||||
|
|
||||||
;; Reclaim file descriptors and memory mappings associated with
|
;; Reclaim file descriptors and memory mappings associated with
|
||||||
;; REPOSITORY as soon as possible.
|
;; REPOSITORY as soon as possible.
|
||||||
|
@ -144,7 +155,7 @@ data, respectively [<branch name> | <sha1> | <tag name>]."
|
||||||
#:key
|
#:key
|
||||||
(cache-directory
|
(cache-directory
|
||||||
(%repository-cache-directory))
|
(%repository-cache-directory))
|
||||||
(ref '(branch . "origin/master")))
|
(ref '(branch . "master")))
|
||||||
"Return two values: the content of the git repository at URL copied into a
|
"Return two values: the content of the git repository at URL copied into a
|
||||||
store directory and the sha1 of the top level commit in this directory. The
|
store directory and the sha1 of the top level commit in this directory. The
|
||||||
reference to be checkout, once the repository is fetched, is specified by REF.
|
reference to be checkout, once the repository is fetched, is specified by REF.
|
||||||
|
|
Loading…
Reference in New Issue