{-# 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 (Ref -> Ref -> Bool
(Ref -> Ref -> Bool) -> (Ref -> Ref -> Bool) -> Eq Ref
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Ref -> Ref -> Bool
$c/= :: Ref -> Ref -> Bool
== :: Ref -> Ref -> Bool
$c== :: Ref -> Ref -> Bool
Eq)
foreign import ccall "ggit_ref_get_type"
    c_ggit_ref_get_type :: IO GType

instance GObject Ref where
    gobjectType :: IO GType
gobjectType = IO GType
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 :: Ref -> IO GValue
toGValue o :: Ref
o = do
        GType
gtype <- IO GType
c_ggit_ref_get_type
        Ref -> (Ptr Ref -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Ref
o (GType -> (GValue -> Ptr Ref -> IO ()) -> Ptr Ref -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Ref -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO Ref
fromGValue gv :: GValue
gv = do
        Ptr Ref
ptr <- GValue -> IO (Ptr Ref)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr Ref)
        (ManagedPtr Ref -> Ref) -> Ptr Ref -> IO Ref
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Ref -> Ref
Ref Ptr 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 :: o -> m Ref
toRef = IO Ref -> m Ref
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Ref -> m Ref) -> (o -> IO Ref) -> o -> m Ref
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Ref -> Ref) -> o -> IO Ref
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr Ref -> Ref
Ref

-- | A convenience alias for `Nothing` :: `Maybe` `Ref`.
noRef :: Maybe Ref
noRef :: Maybe Ref
noRef = Maybe Ref
forall a. Maybe a
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 :: a -> m ()
refDelete ref :: a
ref = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        (Ptr (Ptr GError) -> IO ()) -> IO ()
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO ()) -> IO ())
-> (Ptr (Ptr GError) -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ Ptr Ref -> Ptr (Ptr GError) -> IO ()
ggit_ref_delete Ptr Ref
ref'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: a -> m ()
refDeleteLog ref :: a
ref = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        (Ptr (Ptr GError) -> IO ()) -> IO ()
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO ()) -> IO ())
-> (Ptr (Ptr GError) -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ Ptr Ref -> Ptr (Ptr GError) -> IO ()
ggit_ref_delete_log Ptr Ref
ref'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: a -> m (Maybe Reflog)
refGetLog ref :: a
ref = IO (Maybe Reflog) -> m (Maybe Reflog)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Reflog) -> m (Maybe Reflog))
-> IO (Maybe Reflog) -> m (Maybe Reflog)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    IO (Maybe Reflog) -> IO () -> IO (Maybe Reflog)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Reflog
result <- (Ptr (Ptr GError) -> IO (Ptr Reflog)) -> IO (Ptr Reflog)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Reflog)) -> IO (Ptr Reflog))
-> (Ptr (Ptr GError) -> IO (Ptr Reflog)) -> IO (Ptr Reflog)
forall a b. (a -> b) -> a -> b
$ Ptr Ref -> Ptr (Ptr GError) -> IO (Ptr Reflog)
ggit_ref_get_log Ptr Ref
ref'
        Maybe Reflog
maybeResult <- Ptr Reflog -> (Ptr Reflog -> IO Reflog) -> IO (Maybe Reflog)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Reflog
result ((Ptr Reflog -> IO Reflog) -> IO (Maybe Reflog))
-> (Ptr Reflog -> IO Reflog) -> IO (Maybe Reflog)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr Reflog
result' -> do
            Reflog
result'' <- ((ManagedPtr Reflog -> Reflog) -> Ptr Reflog -> IO Reflog
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Reflog -> Reflog
Ggit.Reflog.Reflog) Ptr Reflog
result'
            Reflog -> IO Reflog
forall (m :: * -> *) a. Monad m => a -> m a
return Reflog
result''
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
        Maybe Reflog -> IO (Maybe Reflog)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Reflog
maybeResult
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: a -> m (Maybe Text)
refGetName ref :: a
ref = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    CString
result <- Ptr Ref -> IO CString
ggit_ref_get_name Ptr Ref
ref'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
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 :: a -> m (Maybe Repository)
refGetOwner ref :: a
ref = IO (Maybe Repository) -> m (Maybe Repository)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Repository) -> m (Maybe Repository))
-> IO (Maybe Repository) -> m (Maybe Repository)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    Ptr Repository
result <- Ptr Ref -> IO (Ptr Repository)
ggit_ref_get_owner Ptr Ref
ref'
    Maybe Repository
maybeResult <- Ptr Repository
-> (Ptr Repository -> IO Repository) -> IO (Maybe Repository)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Repository
result ((Ptr Repository -> IO Repository) -> IO (Maybe Repository))
-> (Ptr Repository -> IO Repository) -> IO (Maybe Repository)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr Repository
result' -> do
        Repository
result'' <- ((ManagedPtr Repository -> Repository)
-> Ptr Repository -> IO Repository
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Repository -> Repository
Ggit.Repository.Repository) Ptr Repository
result'
        Repository -> IO Repository
forall (m :: * -> *) a. Monad m => a -> m a
return Repository
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
    Maybe Repository -> IO (Maybe Repository)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Repository
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 :: a -> m RefType
refGetReferenceType ref :: a
ref = IO RefType -> m RefType
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO RefType -> m RefType) -> IO RefType -> m RefType
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    CUInt
result <- Ptr Ref -> IO CUInt
ggit_ref_get_reference_type Ptr Ref
ref'
    let result' :: RefType
result' = (Int -> RefType
forall a. Enum a => Int -> a
toEnum (Int -> RefType) -> (CUInt -> Int) -> CUInt -> RefType
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
    RefType -> IO RefType
forall (m :: * -> *) a. Monad m => a -> m a
return RefType
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 :: a -> m (Maybe Text)
refGetShorthand ref :: a
ref = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    CString
result <- Ptr Ref -> IO CString
ggit_ref_get_shorthand Ptr Ref
ref'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
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 :: a -> m (Maybe Text)
refGetSymbolicTarget ref :: a
ref = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    CString
result <- Ptr Ref -> IO CString
ggit_ref_get_symbolic_target Ptr Ref
ref'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
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 :: a -> m (Maybe OId)
refGetTarget ref :: a
ref = IO (Maybe OId) -> m (Maybe OId)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe OId) -> m (Maybe OId))
-> IO (Maybe OId) -> m (Maybe OId)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    Ptr OId
result <- Ptr Ref -> IO (Ptr OId)
ggit_ref_get_target Ptr Ref
ref'
    Maybe OId
maybeResult <- Ptr OId -> (Ptr OId -> IO OId) -> IO (Maybe OId)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr OId
result ((Ptr OId -> IO OId) -> IO (Maybe OId))
-> (Ptr OId -> IO OId) -> IO (Maybe OId)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr OId
result' -> do
        OId
result'' <- ((ManagedPtr OId -> OId) -> Ptr OId -> IO OId
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr OId -> OId
Ggit.OId.OId) Ptr OId
result'
        OId -> IO OId
forall (m :: * -> *) a. Monad m => a -> m a
return OId
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
    Maybe OId -> IO (Maybe OId)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe OId
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 :: a -> m Bool
refHasLog ref :: a
ref = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    CInt
result <- Ptr Ref -> IO CInt
ggit_ref_has_log Ptr Ref
ref'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: a -> m Bool
refIsBranch ref :: a
ref = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    CInt
result <- Ptr Ref -> IO CInt
ggit_ref_is_branch Ptr Ref
ref'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: a -> m Bool
refIsNote ref :: a
ref = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    CInt
result <- Ptr Ref -> IO CInt
ggit_ref_is_note Ptr Ref
ref'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: a -> m Bool
refIsRemote ref :: a
ref = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    CInt
result <- Ptr Ref -> IO CInt
ggit_ref_is_remote Ptr Ref
ref'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: a -> m Bool
refIsTag ref :: a
ref = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    CInt
result <- Ptr Ref -> IO CInt
ggit_ref_is_tag Ptr Ref
ref'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
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 :: a -> m (Maybe Object)
refLookup ref :: a
ref = IO (Maybe Object) -> m (Maybe Object)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Object) -> m (Maybe Object))
-> IO (Maybe Object) -> m (Maybe Object)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    IO (Maybe Object) -> IO () -> IO (Maybe Object)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Object
result <- (Ptr (Ptr GError) -> IO (Ptr Object)) -> IO (Ptr Object)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Object)) -> IO (Ptr Object))
-> (Ptr (Ptr GError) -> IO (Ptr Object)) -> IO (Ptr Object)
forall a b. (a -> b) -> a -> b
$ Ptr Ref -> Ptr (Ptr GError) -> IO (Ptr Object)
ggit_ref_lookup Ptr Ref
ref'
        Maybe Object
maybeResult <- Ptr Object -> (Ptr Object -> IO Object) -> IO (Maybe Object)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Object
result ((Ptr Object -> IO Object) -> IO (Maybe Object))
-> (Ptr Object -> IO Object) -> IO (Maybe Object)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr Object
result' -> do
            Object
result'' <- ((ManagedPtr Object -> Object) -> Ptr Object -> IO Object
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Object -> Object
Ggit.Object.Object) Ptr Object
result'
            Object -> IO Object
forall (m :: * -> *) a. Monad m => a -> m a
return Object
result''
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
        Maybe Object -> IO (Maybe Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Object
maybeResult
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: a -> Text -> Bool -> Text -> m (Maybe Ref)
refRename ref :: a
ref newName :: Text
newName force :: Bool
force logMessage :: Text
logMessage = IO (Maybe Ref) -> m (Maybe Ref)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Ref) -> m (Maybe Ref))
-> IO (Maybe Ref) -> m (Maybe Ref)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    CString
newName' <- Text -> IO CString
textToCString Text
newName
    let force' :: CInt
force' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
force
    CString
logMessage' <- Text -> IO CString
textToCString Text
logMessage
    IO (Maybe Ref) -> IO () -> IO (Maybe Ref)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Ref
result <- (Ptr (Ptr GError) -> IO (Ptr Ref)) -> IO (Ptr Ref)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Ref)) -> IO (Ptr Ref))
-> (Ptr (Ptr GError) -> IO (Ptr Ref)) -> IO (Ptr Ref)
forall a b. (a -> b) -> a -> b
$ Ptr Ref
-> CString -> CInt -> CString -> Ptr (Ptr GError) -> IO (Ptr Ref)
ggit_ref_rename Ptr Ref
ref' CString
newName' CInt
force' CString
logMessage'
        Maybe Ref
maybeResult <- Ptr Ref -> (Ptr Ref -> IO Ref) -> IO (Maybe Ref)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Ref
result ((Ptr Ref -> IO Ref) -> IO (Maybe Ref))
-> (Ptr Ref -> IO Ref) -> IO (Maybe Ref)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr Ref
result' -> do
            Ref
result'' <- ((ManagedPtr Ref -> Ref) -> Ptr Ref -> IO Ref
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Ref -> Ref
Ref) Ptr Ref
result'
            Ref -> IO Ref
forall (m :: * -> *) a. Monad m => a -> m a
return Ref
result''
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
newName'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
logMessage'
        Maybe Ref -> IO (Maybe Ref)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Ref
maybeResult
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
newName'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
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 :: a -> m (Maybe Ref)
refResolve ref :: a
ref = IO (Maybe Ref) -> m (Maybe Ref)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Ref) -> m (Maybe Ref))
-> IO (Maybe Ref) -> m (Maybe Ref)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    IO (Maybe Ref) -> IO () -> IO (Maybe Ref)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Ref
result <- (Ptr (Ptr GError) -> IO (Ptr Ref)) -> IO (Ptr Ref)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Ref)) -> IO (Ptr Ref))
-> (Ptr (Ptr GError) -> IO (Ptr Ref)) -> IO (Ptr Ref)
forall a b. (a -> b) -> a -> b
$ Ptr Ref -> Ptr (Ptr GError) -> IO (Ptr Ref)
ggit_ref_resolve Ptr Ref
ref'
        Maybe Ref
maybeResult <- Ptr Ref -> (Ptr Ref -> IO Ref) -> IO (Maybe Ref)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Ref
result ((Ptr Ref -> IO Ref) -> IO (Maybe Ref))
-> (Ptr Ref -> IO Ref) -> IO (Maybe Ref)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr Ref
result' -> do
            Ref
result'' <- ((ManagedPtr Ref -> Ref) -> Ptr Ref -> IO Ref
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Ref -> Ref
Ref) Ptr Ref
result'
            Ref -> IO Ref
forall (m :: * -> *) a. Monad m => a -> m a
return Ref
result''
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
        Maybe Ref -> IO (Maybe Ref)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Ref
maybeResult
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
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 :: a -> Text -> Text -> m (Maybe Ref)
refSetSymbolicTarget ref :: a
ref target :: Text
target logMessage :: Text
logMessage = IO (Maybe Ref) -> m (Maybe Ref)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Ref) -> m (Maybe Ref))
-> IO (Maybe Ref) -> m (Maybe Ref)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    CString
target' <- Text -> IO CString
textToCString Text
target
    CString
logMessage' <- Text -> IO CString
textToCString Text
logMessage
    IO (Maybe Ref) -> IO () -> IO (Maybe Ref)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Ref
result <- (Ptr (Ptr GError) -> IO (Ptr Ref)) -> IO (Ptr Ref)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Ref)) -> IO (Ptr Ref))
-> (Ptr (Ptr GError) -> IO (Ptr Ref)) -> IO (Ptr Ref)
forall a b. (a -> b) -> a -> b
$ Ptr Ref -> CString -> CString -> Ptr (Ptr GError) -> IO (Ptr Ref)
ggit_ref_set_symbolic_target Ptr Ref
ref' CString
target' CString
logMessage'
        Maybe Ref
maybeResult <- Ptr Ref -> (Ptr Ref -> IO Ref) -> IO (Maybe Ref)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Ref
result ((Ptr Ref -> IO Ref) -> IO (Maybe Ref))
-> (Ptr Ref -> IO Ref) -> IO (Maybe Ref)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr Ref
result' -> do
            Ref
result'' <- ((ManagedPtr Ref -> Ref) -> Ptr Ref -> IO Ref
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Ref -> Ref
Ref) Ptr Ref
result'
            Ref -> IO Ref
forall (m :: * -> *) a. Monad m => a -> m a
return Ref
result''
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
target'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
logMessage'
        Maybe Ref -> IO (Maybe Ref)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Ref
maybeResult
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
target'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
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 :: a -> OId -> Text -> m (Maybe Ref)
refSetTarget ref :: a
ref oid :: OId
oid logMessage :: Text
logMessage = IO (Maybe Ref) -> m (Maybe Ref)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Ref) -> m (Maybe Ref))
-> IO (Maybe Ref) -> m (Maybe Ref)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    Ptr OId
oid' <- OId -> IO (Ptr OId)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OId
oid
    CString
logMessage' <- Text -> IO CString
textToCString Text
logMessage
    IO (Maybe Ref) -> IO () -> IO (Maybe Ref)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Ref
result <- (Ptr (Ptr GError) -> IO (Ptr Ref)) -> IO (Ptr Ref)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Ref)) -> IO (Ptr Ref))
-> (Ptr (Ptr GError) -> IO (Ptr Ref)) -> IO (Ptr Ref)
forall a b. (a -> b) -> a -> b
$ Ptr Ref -> Ptr OId -> CString -> Ptr (Ptr GError) -> IO (Ptr Ref)
ggit_ref_set_target Ptr Ref
ref' Ptr OId
oid' CString
logMessage'
        Maybe Ref
maybeResult <- Ptr Ref -> (Ptr Ref -> IO Ref) -> IO (Maybe Ref)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Ref
result ((Ptr Ref -> IO Ref) -> IO (Maybe Ref))
-> (Ptr Ref -> IO Ref) -> IO (Maybe Ref)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr Ref
result' -> do
            Ref
result'' <- ((ManagedPtr Ref -> Ref) -> Ptr Ref -> IO Ref
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Ref -> Ref
Ref) Ptr Ref
result'
            Ref -> IO Ref
forall (m :: * -> *) a. Monad m => a -> m a
return Ref
result''
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
        OId -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OId
oid
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
logMessage'
        Maybe Ref -> IO (Maybe Ref)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Ref
maybeResult
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
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 :: a -> m (Maybe Text)
refToString ref :: a
ref = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Ref
ref' <- a -> IO (Ptr Ref)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
ref
    CString
result <- Ptr Ref -> IO CString
ggit_ref_to_string Ptr Ref
ref'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
ref
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
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 :: Text -> m Bool
refIsValidName name :: Text
name = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
name' <- Text -> IO CString
textToCString Text
name
    CInt
result <- CString -> IO CInt
ggit_ref_is_valid_name CString
name'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
#endif