Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SHA: add Git.SHA

Include showDigestBS from Data.Digest.Pure.SHA
  • Loading branch information...
commit 15f00b09ed024f75258537f64d7e253f98eeb61e 1 parent d6c47e8
@kfish authored
Showing with 23 additions and 0 deletions.
  1. +22 −0 Git/SHA.hs
  2. +1 −0  ght.cabal
View
22 Git/SHA.hs
@@ -0,0 +1,22 @@
+{-# OPTIONS -Wall #-}
+
+module Git.SHA (
+ showDigestBS
+) where
+
+import Data.Bits
+import Data.ByteString (ByteString)
+import qualified Data.ByteString as BS
+import Data.Char
+
+------------------------------------------------------------
+-- From Data.Digest.Pure.SHA
+
+-- |Prints out a bytestring in hexadecimal. Just for convenience.
+showDigestBS :: ByteString -> String
+showDigestBS bs = foldr paddedShowHex [] (BS.unpack bs)
+ where
+ paddedShowHex x xs = intToDigit (fromIntegral (x `shiftR` 4))
+ : intToDigit (fromIntegral (x .&. 0xf))
+ : xs
+
View
1  ght.cabal
@@ -30,6 +30,7 @@ library
Git.Pack
Git.PackIndex
Git.Path
+ Git.SHA
------------------------------------------------------------
-- ght tool
Please sign in to comment.
Something went wrong with that request. Please try again.