summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
Diffstat (limited to 'guix')
-rw-r--r--guix/scripts/hash.scm14
1 files changed, 14 insertions, 0 deletions
diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm
index debe8b4068..d73e3d13dd 100644
--- a/guix/scripts/hash.scm
+++ b/guix/scripts/hash.scm
@@ -35,6 +35,7 @@
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-37)
+ #:autoload (disarchive git-hash) (git-hash-file git-hash-directory)
#:export (guix-hash))
@@ -60,6 +61,17 @@
(call-with-input-file file
(cute port-hash algorithm <>)))))
+(define* (git-hash file #:optional
+ (algorithm (assoc-ref %default-options 'hash-algorithm))
+ select?)
+ (define directory?
+ (case (stat:type (stat file))
+ ((directory) #t)
+ (else #f)))
+ (if directory?
+ (git-hash-directory file algorithm)
+ (git-hash-file file algorithm)))
+
;;;
;;; Command-line options.
@@ -138,6 +150,8 @@ use '--serializer' instead~%"))
default-hash)
("nar"
nar-hash)
+ ("git"
+ git-hash)
(x
(leave (G_ "unsupported serializer type: ~a~%")
arg))))