@@ -46,24 +46,27 @@ writeReflog (Reference rfp) (OID ofp) (Signature sfp) str =
4646
4747-- | Get the number of log entries in a reflog
4848entryCount :: Reflog -> IO Int
49- entryCount = undefined -- callRetNum {#call git_reflog_entrycount#}
49+ entryCount (Reflog rfp) =
50+ withForeignPtr rfp $ retNum . {# call git_reflog_entrycount# }
5051
5152-- | Lookup an entry by its index
5253entryByIndex :: Reflog -> Int -> IO (Maybe ReflogEntry )
5354entryByIndex (Reflog rfp) n =
54- withForeignPtr rfp $ \ r ->
55- undefined -- ReflogEntry ({#call git_reflog_entry_byindex#} r (fromIntegral n))
56-
57- {- unsafeCallStr :: CWrapper a => (CPtr -> IO CString) -> a -> String-}
58- unsafeCallStr call = undefined -- unsafePerformIO . (peekCString =<<) . call . unwrap
55+ withForeignPtr rfp $ \ r -> do
56+ ptr <- mkFPtr =<< {# call git_reflog_entry_byindex# } r (fromIntegral n)
57+ retRes ReflogEntry ptr
5958
6059-- | Get the old oid
6160oldOID :: ReflogEntry -> String
62- oldOID = unsafeCallStr {# call unsafe git_reflog_entry_oidold# }
61+ oldOID (ReflogEntry rfp) = unsafePerformIO $
62+ withForeignPtr rfp $ \ r ->
63+ peekCString =<< {# call unsafe git_reflog_entry_oidold# } r
6364
6465-- | Get the new oid
6566newOID :: ReflogEntry -> String
66- newOID = unsafeCallStr {# call unsafe git_reflog_entry_oidnew# }
67+ newOID (ReflogEntry rfp) = unsafePerformIO $
68+ withForeignPtr rfp $ \ r ->
69+ peekCString =<< {# call unsafe git_reflog_entry_oidnew# } r
6770
6871-- | Get the committer of this entry
6972committer :: ReflogEntry -> Signature
@@ -75,5 +78,7 @@ committer (ReflogEntry rfp) = unsafePerformIO $
7578
7679-- | Get the log msg
7780entryMsg :: ReflogEntry -> String
78- entryMsg = unsafeCallStr {# call unsafe git_reflog_entry_msg# }
81+ entryMsg (ReflogEntry rfp) = unsafePerformIO $
82+ withForeignPtr rfp $ \ r ->
83+ peekCString =<< {# call unsafe git_reflog_entry_msg# } r
7984
0 commit comments