guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/02: git: 'reference-available?' handles short commit IDs.


From: guix-commits
Subject: 02/02: git: 'reference-available?' handles short commit IDs.
Date: Fri, 4 Dec 2020 17:45:45 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit cde3a69a3769cbe8351ecf31179442481189194f
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri Dec 4 18:43:04 2020 +0100

    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.
---
 guix/git.scm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/guix/git.scm b/guix/git.scm
index 364b499..ca77b9f 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)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]