summaryrefslogtreecommitdiff
path: root/guix/git.scm
diff options
context:
space:
mode:
authorMarius Bakke <marius@gnu.org>2020-06-08 19:05:56 +0200
committerMarius Bakke <marius@gnu.org>2020-06-08 19:05:56 +0200
commitdd2d3ed2d30b5d705f9ed8695ab3171c29469f76 (patch)
tree22e909cfe9de99fab471621a907b9f87045bb3bd /guix/git.scm
parent24b61fb8ea8a9e8c5320d1db1447f9b62ad04b3d (diff)
parent1fd2c00efbe701a81d86c254d5f4f285e63c1cde (diff)
downloadguix-patches-dd2d3ed2d30b5d705f9ed8695ab3171c29469f76.tar
guix-patches-dd2d3ed2d30b5d705f9ed8695ab3171c29469f76.tar.gz
Merge branch 'master' into staging
Diffstat (limited to 'guix/git.scm')
-rw-r--r--guix/git.scm29
1 files changed, 19 insertions, 10 deletions
diff --git a/guix/git.scm b/guix/git.scm
index ab3b5075b1..1671f57d9f 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -39,6 +39,7 @@
honor-system-x509-certificates!
with-repository
+ false-if-git-not-found
update-cached-checkout
url+commit->name
latest-repository-commit
@@ -243,18 +244,23 @@ Return true on success, false on failure."
(G_ "Support for submodules is missing; \
please upgrade Guile-Git.~%"))))
+(define-syntax-rule (false-if-git-not-found exp)
+ "Evaluate EXP, returning #false if a GIT_ENOTFOUND error is raised."
+ (catch 'git-error
+ (lambda ()
+ exp)
+ (lambda (key error . rest)
+ (if (= GIT_ENOTFOUND (git-error-code error))
+ #f
+ (apply throw key error rest)))))
+
(define (reference-available? repository ref)
"Return true if REF, a reference such as '(commit . \"cabba9e\"), is
definitely available in REPOSITORY, false otherwise."
(match ref
(('commit . commit)
- (catch 'git-error
- (lambda ()
- (->bool (commit-lookup repository (string->oid commit))))
- (lambda (key error . rest)
- (if (= GIT_ENOTFOUND (git-error-code error))
- #f
- (apply throw key error rest)))))
+ (false-if-git-not-found
+ (->bool (commit-lookup repository (string->oid commit)))))
(_
#f)))
@@ -311,10 +317,13 @@ When RECURSIVE? is true, check out submodules as well, if any."
(new (and starting-commit
(commit-lookup repository oid)))
(old (and starting-commit
- (commit-lookup repository
- (string->oid starting-commit))))
+ (false-if-git-not-found
+ (commit-lookup repository
+ (string->oid starting-commit)))))
(relation (and starting-commit
- (commit-relation old new))))
+ (if old
+ (commit-relation old new)
+ 'unrelated))))
;; Reclaim file descriptors and memory mappings associated with
;; REPOSITORY as soon as possible.