X-Git-Url: https://git.hcoop.net/jackhill/guix/guix.git/blobdiff_plain/68dd78e2e47248b3e1e7ba1807a92a8374b39097..a514b4ab19a628cbfa8b6d7c316ed7242018fcbf:/guix/git.scm diff --git a/guix/git.scm b/guix/git.scm index a5103547d3..776b03f33a 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017, 2020 Mathieu Othacehe ;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès +;;; Copyright © 2021 Kyle Meyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -185,10 +186,9 @@ make sure no empty directory is left behind." (lambda () (mkdir-p directory) - (let ((auth-method (%make-auth-ssh-agent))) - (clone url directory - (make-clone-options - #:fetch-options (make-default-fetch-options))))) + (clone url directory + (make-clone-options + #:fetch-options (make-default-fetch-options)))) (lambda _ (false-if-exception (rmdir directory))))) @@ -210,6 +210,9 @@ corresponding Git object." (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 @@ -341,7 +344,7 @@ definitely available in REPOSITORY, false otherwise." (define* (update-cached-checkout url #:key - (ref '(branch . "master")) + (ref '()) recursive? (check-out? #t) starting-commit @@ -357,6 +360,7 @@ provided) as returned by 'commit-relation'. REF is pair whose key is [branch | commit | tag | tag-or-commit ] and value the associated data: [ | | | ]. +If REF is the empty list, the remote HEAD is used. When RECURSIVE? is true, check out submodules as well, if any. @@ -375,6 +379,7 @@ it unchanged." ;; 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 + (() '(symref . "refs/remotes/origin/HEAD")) (('branch . branch) `(branch . ,(if (string-prefix? "origin/" branch) branch @@ -389,9 +394,8 @@ it unchanged." ;; Only fetch remote if it has not been cloned just before. (when (and cache-exists? (not (reference-available? repository ref))) - (let ((auth-method (%make-auth-ssh-agent))) - (remote-fetch (remote-lookup repository "origin") - #:fetch-options (make-default-fetch-options)))) + (remote-fetch (remote-lookup repository "origin") + #:fetch-options (make-default-fetch-options))) (when recursive? (update-submodules repository #:log-port log-port)) @@ -435,12 +439,13 @@ it unchanged." (log-port (%make-void-port "w")) (cache-directory (%repository-cache-directory)) - (ref '(branch . "master"))) + (ref '())) "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 reference to be checkout, once the repository is fetched, is specified by REF. REF is pair whose key is [branch | commit | tag] and value the associated -data, respectively [ | | ]. +data, respectively [ | | ]. If REF is the empty +list, the remote HEAD is used. When RECURSIVE? is true, check out submodules as well, if any. @@ -550,7 +555,7 @@ objects: 'ancestor (meaning that OLD is an ancestor of NEW), 'descendant, or git-checkout make-git-checkout git-checkout? (url git-checkout-url) - (branch git-checkout-branch (default "master")) + (branch git-checkout-branch (default #f)) (commit git-checkout-commit (default #f)) ;#f | tag | commit (recursive? git-checkout-recursive? (default #f))) @@ -589,9 +594,11 @@ objects: 'ancestor (meaning that OLD is an ancestor of NEW), 'descendant, or (match checkout (($ url branch commit recursive?) (latest-repository-commit* url - #:ref (if commit - `(tag-or-commit . ,commit) - `(branch . ,branch)) + #:ref (cond (commit + `(tag-or-commit . ,commit)) + (branch + `(branch . ,branch)) + (else '())) #:recursive? recursive? #:log-port (current-error-port)))))