{-# LANGUAGE TypeApplications #-} -- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte -- License : LGPL-2.1 -- Maintainer : Iñaki García Etxebarria -- -- Reprensents a git reference. #if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__)) #define ENABLE_OVERLOADING #endif module GI.Ggit.Objects.Ref ( -- * Exported types Ref(..) , IsRef , toRef , noRef , -- * Methods -- ** Overloaded methods #method:Overloaded methods# #if defined(ENABLE_OVERLOADING) ResolveRefMethod , #endif -- ** delete #method:delete# #if defined(ENABLE_OVERLOADING) RefDeleteMethodInfo , #endif refDelete , -- ** deleteLog #method:deleteLog# #if defined(ENABLE_OVERLOADING) RefDeleteLogMethodInfo , #endif refDeleteLog , -- ** getLog #method:getLog# #if defined(ENABLE_OVERLOADING) RefGetLogMethodInfo , #endif refGetLog , -- ** getName #method:getName# #if defined(ENABLE_OVERLOADING) RefGetNameMethodInfo , #endif refGetName , -- ** getOwner #method:getOwner# #if defined(ENABLE_OVERLOADING) RefGetOwnerMethodInfo , #endif refGetOwner , -- ** getReferenceType #method:getReferenceType# #if defined(ENABLE_OVERLOADING) RefGetReferenceTypeMethodInfo , #endif refGetReferenceType , -- ** getShorthand #method:getShorthand# #if defined(ENABLE_OVERLOADING) RefGetShorthandMethodInfo , #endif refGetShorthand , -- ** getSymbolicTarget #method:getSymbolicTarget# #if defined(ENABLE_OVERLOADING) RefGetSymbolicTargetMethodInfo , #endif refGetSymbolicTarget , -- ** getTarget #method:getTarget# #if defined(ENABLE_OVERLOADING) RefGetTargetMethodInfo , #endif refGetTarget , -- ** hasLog #method:hasLog# #if defined(ENABLE_OVERLOADING) RefHasLogMethodInfo , #endif refHasLog , -- ** isBranch #method:isBranch# #if defined(ENABLE_OVERLOADING) RefIsBranchMethodInfo , #endif refIsBranch , -- ** isNote #method:isNote# #if defined(ENABLE_OVERLOADING) RefIsNoteMethodInfo , #endif refIsNote , -- ** isRemote #method:isRemote# #if defined(ENABLE_OVERLOADING) RefIsRemoteMethodInfo , #endif refIsRemote , -- ** isTag #method:isTag# #if defined(ENABLE_OVERLOADING) RefIsTagMethodInfo , #endif refIsTag , -- ** isValidName #method:isValidName# refIsValidName , -- ** lookup #method:lookup# #if defined(ENABLE_OVERLOADING) RefLookupMethodInfo , #endif refLookup , -- ** rename #method:rename# #if defined(ENABLE_OVERLOADING) RefRenameMethodInfo , #endif refRename , -- ** resolve #method:resolve# #if defined(ENABLE_OVERLOADING) RefResolveMethodInfo , #endif refResolve , -- ** setSymbolicTarget #method:setSymbolicTarget# #if defined(ENABLE_OVERLOADING) RefSetSymbolicTargetMethodInfo , #endif refSetSymbolicTarget , -- ** setTarget #method:setTarget# #if defined(ENABLE_OVERLOADING) RefSetTargetMethodInfo , #endif refSetTarget , -- ** toString #method:toString# #if defined(ENABLE_OVERLOADING) RefToStringMethodInfo , #endif refToString , ) where import Data.GI.Base.ShortPrelude import qualified Data.GI.Base.ShortPrelude as SP import qualified Data.GI.Base.Overloading as O import qualified Prelude as P import qualified Data.GI.Base.Attributes as GI.Attributes import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr import qualified Data.GI.Base.GClosure as B.GClosure import qualified Data.GI.Base.GError as B.GError import qualified Data.GI.Base.GVariant as B.GVariant import qualified Data.GI.Base.GValue as B.GValue import qualified Data.GI.Base.GParamSpec as B.GParamSpec import qualified Data.GI.Base.CallStack as B.CallStack import qualified Data.GI.Base.Properties as B.Properties import qualified Data.GI.Base.Signals as B.Signals import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import qualified Foreign.Ptr as FP import qualified GHC.OverloadedLabels as OL import qualified GI.GObject.Objects.Object as GObject.Object import {-# SOURCE #-} qualified GI.Ggit.Enums as Ggit.Enums import {-# SOURCE #-} qualified GI.Ggit.Objects.Native as Ggit.Native import {-# SOURCE #-} qualified GI.Ggit.Objects.Object as Ggit.Object import {-# SOURCE #-} qualified GI.Ggit.Objects.ObjectFactoryBase as Ggit.ObjectFactoryBase import {-# SOURCE #-} qualified GI.Ggit.Objects.Repository as Ggit.Repository import {-# SOURCE #-} qualified GI.Ggit.Structs.OId as Ggit.OId import {-# SOURCE #-} qualified GI.Ggit.Structs.Reflog as Ggit.Reflog -- | Memory-managed wrapper type. newtype Ref = Ref (ManagedPtr Ref) deriving (Eq) foreign import ccall "ggit_ref_get_type" c_ggit_ref_get_type :: IO GType instance GObject Ref where gobjectType = c_ggit_ref_get_type -- | Convert 'Ref' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'. instance B.GValue.IsGValue Ref where toGValue o = do gtype <- c_ggit_ref_get_type B.ManagedPtr.withManagedPtr o (B.GValue.buildGValue gtype B.GValue.set_object) fromGValue gv = do ptr <- B.GValue.get_object gv :: IO (Ptr Ref) B.ManagedPtr.newObject Ref ptr -- | Type class for types which can be safely cast to `Ref`, for instance with `toRef`. class (GObject o, O.IsDescendantOf Ref o) => IsRef o instance (GObject o, O.IsDescendantOf Ref o) => IsRef o instance O.HasParentTypes Ref type instance O.ParentTypes Ref = '[Ggit.Native.Native, Ggit.ObjectFactoryBase.ObjectFactoryBase, GObject.Object.Object] -- | Cast to `Ref`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`. toRef :: (MonadIO m, IsRef o) => o -> m Ref toRef = liftIO . unsafeCastTo Ref -- | A convenience alias for `Nothing` :: `Maybe` `Ref`. noRef :: Maybe Ref noRef = Nothing #if defined(ENABLE_OVERLOADING) type family ResolveRefMethod (t :: Symbol) (o :: *) :: * where ResolveRefMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo ResolveRefMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo ResolveRefMethod "delete" o = RefDeleteMethodInfo ResolveRefMethod "deleteLog" o = RefDeleteLogMethodInfo ResolveRefMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo ResolveRefMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo ResolveRefMethod "getv" o = GObject.Object.ObjectGetvMethodInfo ResolveRefMethod "hasLog" o = RefHasLogMethodInfo ResolveRefMethod "isBranch" o = RefIsBranchMethodInfo ResolveRefMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo ResolveRefMethod "isNote" o = RefIsNoteMethodInfo ResolveRefMethod "isRemote" o = RefIsRemoteMethodInfo ResolveRefMethod "isTag" o = RefIsTagMethodInfo ResolveRefMethod "lookup" o = RefLookupMethodInfo ResolveRefMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo ResolveRefMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo ResolveRefMethod "ref" o = GObject.Object.ObjectRefMethodInfo ResolveRefMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo ResolveRefMethod "rename" o = RefRenameMethodInfo ResolveRefMethod "resolve" o = RefResolveMethodInfo ResolveRefMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo ResolveRefMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo ResolveRefMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo ResolveRefMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo ResolveRefMethod "toString" o = RefToStringMethodInfo ResolveRefMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo ResolveRefMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo ResolveRefMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo ResolveRefMethod "getLog" o = RefGetLogMethodInfo ResolveRefMethod "getName" o = RefGetNameMethodInfo ResolveRefMethod "getOwner" o = RefGetOwnerMethodInfo ResolveRefMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo ResolveRefMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo ResolveRefMethod "getReferenceType" o = RefGetReferenceTypeMethodInfo ResolveRefMethod "getShorthand" o = RefGetShorthandMethodInfo ResolveRefMethod "getSymbolicTarget" o = RefGetSymbolicTargetMethodInfo ResolveRefMethod "getTarget" o = RefGetTargetMethodInfo ResolveRefMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo ResolveRefMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo ResolveRefMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo ResolveRefMethod "setSymbolicTarget" o = RefSetSymbolicTargetMethodInfo ResolveRefMethod "setTarget" o = RefSetTargetMethodInfo ResolveRefMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveRefMethod t Ref, O.MethodInfo info Ref p) => OL.IsLabel t (Ref -> p) where #if MIN_VERSION_base(4,10,0) fromLabel = O.overloadedMethod @info #else fromLabel _ = O.overloadedMethod @info #endif #endif #if defined(ENABLE_OVERLOADING) instance O.HasAttributeList Ref type instance O.AttributeList Ref = RefAttributeList type RefAttributeList = ('[ '("native", Ggit.Native.NativeNativePropertyInfo)] :: [(Symbol, *)]) #endif #if defined(ENABLE_OVERLOADING) #endif #if defined(ENABLE_OVERLOADING) type instance O.SignalList Ref = RefSignalList type RefSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)]) #endif -- method Ref::delete -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Nothing -- throws : True -- Skip return : False foreign import ccall "ggit_ref_delete" ggit_ref_delete :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) Ptr (Ptr GError) -> -- error IO () -- | Deletes /@ref@/. -- -- This method works for both direct and symbolic references. -- -- The reference will be immediately removed on disk and from -- memory. The given reference pointer will no longer be valid. refDelete :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m () -- ^ /(Can throw 'Data.GI.Base.GError.GError')/ refDelete ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref onException (do propagateGError $ ggit_ref_delete ref' touchManagedPtr ref return () ) (do return () ) #if defined(ENABLE_OVERLOADING) data RefDeleteMethodInfo instance (signature ~ (m ()), MonadIO m, IsRef a) => O.MethodInfo RefDeleteMethodInfo a signature where overloadedMethod = refDelete #endif -- method Ref::delete_log -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Nothing -- throws : True -- Skip return : False foreign import ccall "ggit_ref_delete_log" ggit_ref_delete_log :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) Ptr (Ptr GError) -> -- error IO () -- | Deletes the log for /@ref@/, on error /@error@/ is set. refDeleteLog :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m () -- ^ /(Can throw 'Data.GI.Base.GError.GError')/ refDeleteLog ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref onException (do propagateGError $ ggit_ref_delete_log ref' touchManagedPtr ref return () ) (do return () ) #if defined(ENABLE_OVERLOADING) data RefDeleteLogMethodInfo instance (signature ~ (m ()), MonadIO m, IsRef a) => O.MethodInfo RefDeleteLogMethodInfo a signature where overloadedMethod = refDeleteLog #endif -- method Ref::get_log -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TInterface Name { namespace = "Ggit" , name = "Reflog" }) -- throws : True -- Skip return : False foreign import ccall "ggit_ref_get_log" ggit_ref_get_log :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) Ptr (Ptr GError) -> -- error IO (Ptr Ggit.Reflog.Reflog) -- | Gets the t'GI.Ggit.Structs.Reflog.Reflog' for /@ref@/. The reflog will be created if it doesn\'t exist -- yet. refGetLog :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m (Maybe Ggit.Reflog.Reflog) -- ^ __Returns:__ the reflog or 'P.Nothing'. /(Can throw 'Data.GI.Base.GError.GError')/ refGetLog ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref onException (do result <- propagateGError $ ggit_ref_get_log ref' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapBoxed Ggit.Reflog.Reflog) result' return result'' touchManagedPtr ref return maybeResult ) (do return () ) #if defined(ENABLE_OVERLOADING) data RefGetLogMethodInfo instance (signature ~ (m (Maybe Ggit.Reflog.Reflog)), MonadIO m, IsRef a) => O.MethodInfo RefGetLogMethodInfo a signature where overloadedMethod = refGetLog #endif -- method Ref::get_name -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "ggit_ref_get_name" ggit_ref_get_name :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) IO CString -- | Gets the full name of /@ref@/. refGetName :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m (Maybe T.Text) -- ^ __Returns:__ the full name of a reference or 'P.Nothing'. refGetName ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref result <- ggit_ref_get_name ref' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- cstringToText result' return result'' touchManagedPtr ref return maybeResult #if defined(ENABLE_OVERLOADING) data RefGetNameMethodInfo instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsRef a) => O.MethodInfo RefGetNameMethodInfo a signature where overloadedMethod = refGetName #endif -- method Ref::get_owner -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TInterface Name { namespace = "Ggit" , name = "Repository" }) -- throws : False -- Skip return : False foreign import ccall "ggit_ref_get_owner" ggit_ref_get_owner :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) IO (Ptr Ggit.Repository.Repository) -- | Gets the repository where /@ref@/ resides. refGetOwner :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m (Maybe Ggit.Repository.Repository) -- ^ __Returns:__ the repository where a reference resides or 'P.Nothing'. refGetOwner ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref result <- ggit_ref_get_owner ref' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapObject Ggit.Repository.Repository) result' return result'' touchManagedPtr ref return maybeResult #if defined(ENABLE_OVERLOADING) data RefGetOwnerMethodInfo instance (signature ~ (m (Maybe Ggit.Repository.Repository)), MonadIO m, IsRef a) => O.MethodInfo RefGetOwnerMethodInfo a signature where overloadedMethod = refGetOwner #endif -- method Ref::get_reference_type -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TInterface Name { namespace = "Ggit" , name = "RefType" }) -- throws : False -- Skip return : False foreign import ccall "ggit_ref_get_reference_type" ggit_ref_get_reference_type :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) IO CUInt -- | Gets the type of /@ref@/. Either direct (@/GGIT_REF_OID/@) or -- symbolic (@/GGIT_REF_SYMBOLIC/@). refGetReferenceType :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m Ggit.Enums.RefType -- ^ __Returns:__ the type of a reference. refGetReferenceType ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref result <- ggit_ref_get_reference_type ref' let result' = (toEnum . fromIntegral) result touchManagedPtr ref return result' #if defined(ENABLE_OVERLOADING) data RefGetReferenceTypeMethodInfo instance (signature ~ (m Ggit.Enums.RefType), MonadIO m, IsRef a) => O.MethodInfo RefGetReferenceTypeMethodInfo a signature where overloadedMethod = refGetReferenceType #endif -- method Ref::get_shorthand -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef" , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "ggit_ref_get_shorthand" ggit_ref_get_shorthand :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) IO CString -- | Gets the shorthand name of /@ref@/. refGetShorthand :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref' -> m (Maybe T.Text) -- ^ __Returns:__ the shorthand name of a reference or 'P.Nothing'. refGetShorthand ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref result <- ggit_ref_get_shorthand ref' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- cstringToText result' return result'' touchManagedPtr ref return maybeResult #if defined(ENABLE_OVERLOADING) data RefGetShorthandMethodInfo instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsRef a) => O.MethodInfo RefGetShorthandMethodInfo a signature where overloadedMethod = refGetShorthand #endif -- method Ref::get_symbolic_target -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "ggit_ref_get_symbolic_target" ggit_ref_get_symbolic_target :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) IO CString -- | Get full name to the reference pointed to by a symbolic reference. -- Only available if the reference is symbolic. refGetSymbolicTarget :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m (Maybe T.Text) -- ^ __Returns:__ the name if available, 'P.Nothing' otherwise. refGetSymbolicTarget ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref result <- ggit_ref_get_symbolic_target ref' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- cstringToText result' return result'' touchManagedPtr ref return maybeResult #if defined(ENABLE_OVERLOADING) data RefGetSymbolicTargetMethodInfo instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsRef a) => O.MethodInfo RefGetSymbolicTargetMethodInfo a signature where overloadedMethod = refGetSymbolicTarget #endif -- method Ref::get_target -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TInterface Name { namespace = "Ggit" , name = "OId" }) -- throws : False -- Skip return : False foreign import ccall "ggit_ref_get_target" ggit_ref_get_target :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) IO (Ptr Ggit.OId.OId) -- | Get the OID pointed to by a direct reference. -- Only available if the reference is direct (i.e. an object id reference, -- not a symbolic one). refGetTarget :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m (Maybe Ggit.OId.OId) -- ^ __Returns:__ a new oid if available, 'P.Nothing' otherwise. refGetTarget ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref result <- ggit_ref_get_target ref' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapBoxed Ggit.OId.OId) result' return result'' touchManagedPtr ref return maybeResult #if defined(ENABLE_OVERLOADING) data RefGetTargetMethodInfo instance (signature ~ (m (Maybe Ggit.OId.OId)), MonadIO m, IsRef a) => O.MethodInfo RefGetTargetMethodInfo a signature where overloadedMethod = refGetTarget #endif -- method Ref::has_log -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "ggit_ref_has_log" ggit_ref_has_log :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) IO CInt -- | Get whether /@ref@/ has an existing log. refHasLog :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m Bool -- ^ __Returns:__ 'P.True' if /@ref@/ has a log, 'P.False' otherwise. refHasLog ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref result <- ggit_ref_has_log ref' let result' = (/= 0) result touchManagedPtr ref return result' #if defined(ENABLE_OVERLOADING) data RefHasLogMethodInfo instance (signature ~ (m Bool), MonadIO m, IsRef a) => O.MethodInfo RefHasLogMethodInfo a signature where overloadedMethod = refHasLog #endif -- method Ref::is_branch -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "ggit_ref_is_branch" ggit_ref_is_branch :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) IO CInt -- | Check whether the reference is a branch. refIsBranch :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m Bool -- ^ __Returns:__ 'P.True' if the reference is a branch, 'P.False' otherwise. refIsBranch ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref result <- ggit_ref_is_branch ref' let result' = (/= 0) result touchManagedPtr ref return result' #if defined(ENABLE_OVERLOADING) data RefIsBranchMethodInfo instance (signature ~ (m Bool), MonadIO m, IsRef a) => O.MethodInfo RefIsBranchMethodInfo a signature where overloadedMethod = refIsBranch #endif -- method Ref::is_note -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "ggit_ref_is_note" ggit_ref_is_note :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) IO CInt -- | Check whether the reference is a note. refIsNote :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m Bool -- ^ __Returns:__ 'P.True' if the reference is a note, 'P.False' otherwise. refIsNote ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref result <- ggit_ref_is_note ref' let result' = (/= 0) result touchManagedPtr ref return result' #if defined(ENABLE_OVERLOADING) data RefIsNoteMethodInfo instance (signature ~ (m Bool), MonadIO m, IsRef a) => O.MethodInfo RefIsNoteMethodInfo a signature where overloadedMethod = refIsNote #endif -- method Ref::is_remote -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "ggit_ref_is_remote" ggit_ref_is_remote :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) IO CInt -- | Check whether the reference is a remote. refIsRemote :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m Bool -- ^ __Returns:__ 'P.True' if the reference is a remote, 'P.False' otherwise. refIsRemote ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref result <- ggit_ref_is_remote ref' let result' = (/= 0) result touchManagedPtr ref return result' #if defined(ENABLE_OVERLOADING) data RefIsRemoteMethodInfo instance (signature ~ (m Bool), MonadIO m, IsRef a) => O.MethodInfo RefIsRemoteMethodInfo a signature where overloadedMethod = refIsRemote #endif -- method Ref::is_tag -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "ggit_ref_is_tag" ggit_ref_is_tag :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) IO CInt -- | Check whether the reference is a tag. refIsTag :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m Bool -- ^ __Returns:__ 'P.True' if the reference is a tag, 'P.False' otherwise. refIsTag ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref result <- ggit_ref_is_tag ref' let result' = (/= 0) result touchManagedPtr ref return result' #if defined(ENABLE_OVERLOADING) data RefIsTagMethodInfo instance (signature ~ (m Bool), MonadIO m, IsRef a) => O.MethodInfo RefIsTagMethodInfo a signature where overloadedMethod = refIsTag #endif -- method Ref::lookup -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TInterface Name { namespace = "Ggit" , name = "Object" }) -- throws : True -- Skip return : False foreign import ccall "ggit_ref_lookup" ggit_ref_lookup :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) Ptr (Ptr GError) -> -- error IO (Ptr Ggit.Object.Object) -- | Convenient method to resolve a reference to an object. refLookup :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m (Maybe Ggit.Object.Object) -- ^ __Returns:__ a t'GI.Ggit.Objects.Object.Object' or 'P.Nothing'. /(Can throw 'Data.GI.Base.GError.GError')/ refLookup ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref onException (do result <- propagateGError $ ggit_ref_lookup ref' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapObject Ggit.Object.Object) result' return result'' touchManagedPtr ref return maybeResult ) (do return () ) #if defined(ENABLE_OVERLOADING) data RefLookupMethodInfo instance (signature ~ (m (Maybe Ggit.Object.Object)), MonadIO m, IsRef a) => O.MethodInfo RefLookupMethodInfo a signature where overloadedMethod = refLookup #endif -- method Ref::rename -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "new_name" -- , argType = TBasicType TUTF8 -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "the new name." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "force" -- , argType = TBasicType TBoolean -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "%TRUE to force the renaming." -- , sinceVersion = Nothing -- } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "log_message" -- , argType = TBasicType TUTF8 -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = -- Just "The one line long message to be appended to the reflog." -- , sinceVersion = Nothing -- } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TInterface Name { namespace = "Ggit" , name = "Ref" }) -- throws : True -- Skip return : False foreign import ccall "ggit_ref_rename" ggit_ref_rename :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) CString -> -- new_name : TBasicType TUTF8 CInt -> -- force : TBasicType TBoolean CString -> -- log_message : TBasicType TUTF8 Ptr (Ptr GError) -> -- error IO (Ptr Ref) -- | Rename an existing reference. -- -- This method works for both direct and symbolic references. -- -- The new name will be checked for validity. -- See @ggit_ref_create_symbolic()@ for rules about valid names. -- -- If not error, /@ref@/ will be deleted from disk and a -- new t'GI.Ggit.Objects.Ref.Ref' will be returned. -- -- The reference will be immediately renamed in-memory and on disk. -- -- If the @force@ flag is not enabled, and there\'s already -- a reference with the given name, the renaming will fail. -- -- IMPORTANT: -- The user needs to write a proper reflog entry if the -- reflog is enabled for the repository. We only rename -- the reflog if it exists. refRename :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> T.Text -- ^ /@newName@/: the new name. -> Bool -- ^ /@force@/: 'P.True' to force the renaming. -> T.Text -- ^ /@logMessage@/: The one line long message to be appended to the reflog. -> m (Maybe Ref) -- ^ __Returns:__ a newly created t'GI.Ggit.Objects.Ref.Ref' or 'P.Nothing'. /(Can throw 'Data.GI.Base.GError.GError')/ refRename ref newName force logMessage = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref newName' <- textToCString newName let force' = (fromIntegral . fromEnum) force logMessage' <- textToCString logMessage onException (do result <- propagateGError $ ggit_ref_rename ref' newName' force' logMessage' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapObject Ref) result' return result'' touchManagedPtr ref freeMem newName' freeMem logMessage' return maybeResult ) (do freeMem newName' freeMem logMessage' ) #if defined(ENABLE_OVERLOADING) data RefRenameMethodInfo instance (signature ~ (T.Text -> Bool -> T.Text -> m (Maybe Ref)), MonadIO m, IsRef a) => O.MethodInfo RefRenameMethodInfo a signature where overloadedMethod = refRename #endif -- method Ref::resolve -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TInterface Name { namespace = "Ggit" , name = "Ref" }) -- throws : True -- Skip return : False foreign import ccall "ggit_ref_resolve" ggit_ref_resolve :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) Ptr (Ptr GError) -> -- error IO (Ptr Ref) -- | Resolves a symbolic reference. -- -- This method iteratively peels a symbolic reference -- until it resolves to a direct reference to an OID. -- -- If a direct reference is passed as an argument, -- that reference is returned immediately. refResolve :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m (Maybe Ref) -- ^ __Returns:__ the resolved reference to the peeled one or 'P.Nothing'. /(Can throw 'Data.GI.Base.GError.GError')/ refResolve ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref onException (do result <- propagateGError $ ggit_ref_resolve ref' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapObject Ref) result' return result'' touchManagedPtr ref return maybeResult ) (do return () ) #if defined(ENABLE_OVERLOADING) data RefResolveMethodInfo instance (signature ~ (m (Maybe Ref)), MonadIO m, IsRef a) => O.MethodInfo RefResolveMethodInfo a signature where overloadedMethod = refResolve #endif -- method Ref::set_symbolic_target -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "target" -- , argType = TBasicType TUTF8 -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "The new target for the reference." -- , sinceVersion = Nothing -- } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "log_message" -- , argType = TBasicType TUTF8 -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = -- Just "The one line long message to be appended to the reflog." -- , sinceVersion = Nothing -- } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TInterface Name { namespace = "Ggit" , name = "Ref" }) -- throws : True -- Skip return : False foreign import ccall "ggit_ref_set_symbolic_target" ggit_ref_set_symbolic_target :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) CString -> -- target : TBasicType TUTF8 CString -> -- log_message : TBasicType TUTF8 Ptr (Ptr GError) -> -- error IO (Ptr Ref) -- | Create a new reference with the same name as the given reference but a -- different symbolic target. The reference must be a symbolic reference, -- otherwise this will fail. -- -- The new reference will be written to disk, overwriting the given reference. -- -- The target name will be checked for validity. -- See @ggit_ref_create_symbolic()@ for rules about valid names. refSetSymbolicTarget :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> T.Text -- ^ /@target@/: The new target for the reference. -> T.Text -- ^ /@logMessage@/: The one line long message to be appended to the reflog. -> m (Maybe Ref) -- ^ __Returns:__ the newly created t'GI.Ggit.Objects.Ref.Ref' or 'P.Nothing'. /(Can throw 'Data.GI.Base.GError.GError')/ refSetSymbolicTarget ref target logMessage = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref target' <- textToCString target logMessage' <- textToCString logMessage onException (do result <- propagateGError $ ggit_ref_set_symbolic_target ref' target' logMessage' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapObject Ref) result' return result'' touchManagedPtr ref freeMem target' freeMem logMessage' return maybeResult ) (do freeMem target' freeMem logMessage' ) #if defined(ENABLE_OVERLOADING) data RefSetSymbolicTargetMethodInfo instance (signature ~ (T.Text -> T.Text -> m (Maybe Ref)), MonadIO m, IsRef a) => O.MethodInfo RefSetSymbolicTargetMethodInfo a signature where overloadedMethod = refSetSymbolicTarget #endif -- method Ref::set_target -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "oid" -- , argType = TInterface Name { namespace = "Ggit" , name = "OId" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitOId." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "log_message" -- , argType = TBasicType TUTF8 -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = -- Just "The one line long message to be appended to the reflog." -- , sinceVersion = Nothing -- } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TInterface Name { namespace = "Ggit" , name = "Ref" }) -- throws : True -- Skip return : False foreign import ccall "ggit_ref_set_target" ggit_ref_set_target :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) Ptr Ggit.OId.OId -> -- oid : TInterface (Name {namespace = "Ggit", name = "OId"}) CString -> -- log_message : TBasicType TUTF8 Ptr (Ptr GError) -> -- error IO (Ptr Ref) -- | Create a new reference with the same name as the given reference but a -- different OID target. The reference must be a direct reference, otherwise -- this will fail. -- -- The new reference will be written to disk, overwriting the given reference. refSetTarget :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> Ggit.OId.OId -- ^ /@oid@/: a t'GI.Ggit.Structs.OId.OId'. -> T.Text -- ^ /@logMessage@/: The one line long message to be appended to the reflog. -> m (Maybe Ref) -- ^ __Returns:__ the newly created t'GI.Ggit.Objects.Ref.Ref' or 'P.Nothing'. /(Can throw 'Data.GI.Base.GError.GError')/ refSetTarget ref oid logMessage = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref oid' <- unsafeManagedPtrGetPtr oid logMessage' <- textToCString logMessage onException (do result <- propagateGError $ ggit_ref_set_target ref' oid' logMessage' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapObject Ref) result' return result'' touchManagedPtr ref touchManagedPtr oid freeMem logMessage' return maybeResult ) (do freeMem logMessage' ) #if defined(ENABLE_OVERLOADING) data RefSetTargetMethodInfo instance (signature ~ (Ggit.OId.OId -> T.Text -> m (Maybe Ref)), MonadIO m, IsRef a) => O.MethodInfo RefSetTargetMethodInfo a signature where overloadedMethod = refSetTarget #endif -- method Ref::to_string -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "ref" -- , argType = TInterface Name { namespace = "Ggit" , name = "Ref" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitRef." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "ggit_ref_to_string" ggit_ref_to_string :: Ptr Ref -> -- ref : TInterface (Name {namespace = "Ggit", name = "Ref"}) IO CString -- | Get a string representation of the ref. refToString :: (B.CallStack.HasCallStack, MonadIO m, IsRef a) => a -- ^ /@ref@/: a t'GI.Ggit.Objects.Ref.Ref'. -> m (Maybe T.Text) -- ^ __Returns:__ a string representation of the ref or 'P.Nothing'. refToString ref = liftIO $ do ref' <- unsafeManagedPtrCastPtr ref result <- ggit_ref_to_string ref' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- cstringToText result' return result'' touchManagedPtr ref return maybeResult #if defined(ENABLE_OVERLOADING) data RefToStringMethodInfo instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsRef a) => O.MethodInfo RefToStringMethodInfo a signature where overloadedMethod = refToString #endif -- method Ref::is_valid_name -- method type : MemberFunction -- Args: [ Arg -- { argCName = "name" -- , argType = TBasicType TUTF8 -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "the name to validate." -- , sinceVersion = Nothing -- } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "ggit_ref_is_valid_name" ggit_ref_is_valid_name :: CString -> -- name : TBasicType TUTF8 IO CInt -- | Check if the given /@name@/ is a valid name for a reference. Note that /@name@/ -- should be the full ref name (including prefixes). -- -- Valid toplevel names can contain only capital letters and underscores -- and must start and end with a letter (e.g. HEAD, ORIG_HEAD). -- -- Valid refs\/ names may contain any characters, except \'~\', \'^\', \':\', \'\\\', \'?\', -- \'[\', \'*\', \"..\" and \"\@{\", because they are interpreted by revparse. refIsValidName :: (B.CallStack.HasCallStack, MonadIO m) => T.Text -- ^ /@name@/: the name to validate. -> m Bool -- ^ __Returns:__ 'P.True' if /@name@/ is valid, 'P.False' otherwise. refIsValidName name = liftIO $ do name' <- textToCString name result <- ggit_ref_is_valid_name name' let result' = (/= 0) result freeMem name' return result' #if defined(ENABLE_OVERLOADING) #endif