From 085b4c76ef55c5d1470be826d436d3c991982bba Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 15 Feb 2012 22:31:54 +0100 Subject: faster git-rev-parse * tekuti/git.scm (git-rev-parse): Try to read the ref ourselves, first. Fall back to using git if that doesn't work (for example, if it's a packed ref). --- tekuti/git.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tekuti/git.scm b/tekuti/git.scm index 4bc7d60..3c9df31 100644 --- a/tekuti/git.scm +++ b/tekuti/git.scm @@ -167,7 +167,11 @@ "\n" 'suffix))))) (define (git-rev-parse rev) - (string-trim-both (git "rev-parse" rev))) + (or (false-if-exception + (let ((s (string-trim-both (call-with-input-file rev read-line)))) + (and (= (string-length s) 40) + s))) + (git "rev-parse" rev))) (define (git-rev-list rev n) (let lp ((lines (string-split -- cgit v1.2.3-54-g00ecf