summaryrefslogtreecommitdiff
path: root/guix/git.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-12-04 18:43:04 +0100
committerLudovic Courtès <ludo@gnu.org>2020-12-04 23:45:09 +0100
commitcde3a69a3769cbe8351ecf31179442481189194f (patch)
tree6a59204db741ed429b69335cbed1647668a86d74 /guix/git.scm
parent611ae310f4ca1d93600c280e940a69b07e20c350 (diff)
git: 'reference-available?' handles short commit IDs.
Reported by Simon Tournier on #guix. Until now 'reference-available?' would always return #f when passed a short commit ID. * guix/git.scm (reference-available?): Call 'object-lookup-prefix' when COMMIT is shorter than 40 characters.
Diffstat (limited to 'guix/git.scm')
-rw-r--r--guix/git.scm8
1 files changed, 6 insertions, 2 deletions
diff --git a/guix/git.scm b/guix/git.scm
index 364b4997ae..ca77b9f54b 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -309,8 +309,12 @@ dynamic extent of EXP."
definitely available in REPOSITORY, false otherwise."
(match ref
(('commit . commit)
- (false-if-git-not-found
- (->bool (commit-lookup repository (string->oid commit)))))
+ (let ((len (string-length commit))
+ (oid (string->oid commit)))
+ (false-if-git-not-found
+ (->bool (if (< len 40)
+ (object-lookup-prefix repository oid len OBJ-COMMIT)
+ (commit-lookup repository oid))))))
(_
#f)))