{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

Reprensents a git reference.
-}

module GI.Ggit.Objects.Ref
    ( 

-- * Exported types
    Ref(..)                                 ,
    IsRef                                   ,
    toRef                                   ,
    noRef                                   ,


 -- * Methods
-- ** delete #method:delete#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefDeleteMethodInfo                     ,
#endif
    refDelete                               ,


-- ** deleteLog #method:deleteLog#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefDeleteLogMethodInfo                  ,
#endif
    refDeleteLog                            ,


-- ** getLog #method:getLog#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefGetLogMethodInfo                     ,
#endif
    refGetLog                               ,


-- ** getName #method:getName#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefGetNameMethodInfo                    ,
#endif
    refGetName                              ,


-- ** getOwner #method:getOwner#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefGetOwnerMethodInfo                   ,
#endif
    refGetOwner                             ,


-- ** getReferenceType #method:getReferenceType#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefGetReferenceTypeMethodInfo           ,
#endif
    refGetReferenceType                     ,


-- ** getShorthand #method:getShorthand#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefGetShorthandMethodInfo               ,
#endif
    refGetShorthand                         ,


-- ** getSymbolicTarget #method:getSymbolicTarget#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefGetSymbolicTargetMethodInfo          ,
#endif
    refGetSymbolicTarget                    ,


-- ** getTarget #method:getTarget#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefGetTargetMethodInfo                  ,
#endif
    refGetTarget                            ,


-- ** hasLog #method:hasLog#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefHasLogMethodInfo                     ,
#endif
    refHasLog                               ,


-- ** isBranch #method:isBranch#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefIsBranchMethodInfo                   ,
#endif
    refIsBranch                             ,


-- ** isNote #method:isNote#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefIsNoteMethodInfo                     ,
#endif
    refIsNote                               ,


-- ** isRemote #method:isRemote#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefIsRemoteMethodInfo                   ,
#endif
    refIsRemote                             ,


-- ** isTag #method:isTag#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefIsTagMethodInfo                      ,
#endif
    refIsTag                                ,


-- ** isValidName #method:isValidName#
    refIsValidName                          ,


-- ** lookup #method:lookup#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefLookupMethodInfo                     ,
#endif
    refLookup                               ,


-- ** rename #method:rename#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefRenameMethodInfo                     ,
#endif
    refRename                               ,


-- ** resolve #method:resolve#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefResolveMethodInfo                    ,
#endif
    refResolve                              ,


-- ** setSymbolicTarget #method:setSymbolicTarget#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefSetSymbolicTargetMethodInfo          ,
#endif
    refSetSymbolicTarget                    ,


-- ** setTarget #method:setTarget#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RefSetTargetMethodInfo                  ,
#endif
    refSetTarget                            ,


-- ** toString #method:toString#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    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.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
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 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

newtype Ref = Ref (ManagedPtr Ref)
foreign import ccall "ggit_ref_get_type"
    c_ggit_ref_get_type :: IO GType

instance GObject Ref where
    gobjectType _ = c_ggit_ref_get_type
    

class GObject o => IsRef o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Ref a) =>
    IsRef a
#endif
instance IsRef Ref
instance Ggit.Native.IsNative Ref
instance Ggit.ObjectFactoryBase.IsObjectFactoryBase Ref
instance GObject.Object.IsObject Ref

toRef :: (MonadIO m, IsRef o) => o -> m Ref
toRef = liftIO . unsafeCastTo Ref

noRef :: Maybe Ref
noRef = Nothing

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
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 "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 "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveRefMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    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 "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) => O.IsLabelProxy t (Ref -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveRefMethod t Ref, O.MethodInfo info Ref p) => O.IsLabel t (Ref -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
instance O.HasAttributeList Ref
type instance O.AttributeList Ref = RefAttributeList
type RefAttributeList = ('[ '("native", Ggit.Native.NativeNativePropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
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 '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) && !defined(__HADDOCK_VERSION__)
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 '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) && !defined(__HADDOCK_VERSION__)
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 '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 'GI.Ggit.Objects.Ref.Ref'. -}
    -> m Ggit.Reflog.Reflog
    {- ^ __Returns:__ the reflog. /(Can throw 'Data.GI.Base.GError.GError')/ -}
refGetLog ref = liftIO $ do
    ref' <- unsafeManagedPtrCastPtr ref
    onException (do
        result <- propagateGError $ ggit_ref_get_log ref'
        checkUnexpectedReturnNULL "refGetLog" result
        result' <- (wrapBoxed Ggit.Reflog.Reflog) result
        touchManagedPtr ref
        return result'
     ) (do
        return ()
     )

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RefGetLogMethodInfo
instance (signature ~ (m 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 'GI.Ggit.Objects.Ref.Ref'. -}
    -> m T.Text
    {- ^ __Returns:__ the full name of a reference. -}
refGetName ref = liftIO $ do
    ref' <- unsafeManagedPtrCastPtr ref
    result <- ggit_ref_get_name ref'
    checkUnexpectedReturnNULL "refGetName" result
    result' <- cstringToText result
    touchManagedPtr ref
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RefGetNameMethodInfo
instance (signature ~ (m 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 'GI.Ggit.Objects.Ref.Ref'. -}
    -> m Ggit.Repository.Repository
    {- ^ __Returns:__ the repository where a reference resides. -}
refGetOwner ref = liftIO $ do
    ref' <- unsafeManagedPtrCastPtr ref
    result <- ggit_ref_get_owner ref'
    checkUnexpectedReturnNULL "refGetOwner" result
    result' <- (wrapObject Ggit.Repository.Repository) result
    touchManagedPtr ref
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RefGetOwnerMethodInfo
instance (signature ~ (m 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 '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) && !defined(__HADDOCK_VERSION__)
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 'GI.Ggit.Objects.Ref.Ref' -}
    -> m T.Text
    {- ^ __Returns:__ the shorthand name of a reference. -}
refGetShorthand ref = liftIO $ do
    ref' <- unsafeManagedPtrCastPtr ref
    result <- ggit_ref_get_shorthand ref'
    checkUnexpectedReturnNULL "refGetShorthand" result
    result' <- cstringToText result
    touchManagedPtr ref
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RefGetShorthandMethodInfo
instance (signature ~ (m 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 'GI.Ggit.Objects.Ref.Ref'. -}
    -> m T.Text
    {- ^ __Returns:__ the name if available, 'Nothing' otherwise. -}
refGetSymbolicTarget ref = liftIO $ do
    ref' <- unsafeManagedPtrCastPtr ref
    result <- ggit_ref_get_symbolic_target ref'
    checkUnexpectedReturnNULL "refGetSymbolicTarget" result
    result' <- cstringToText result
    touchManagedPtr ref
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RefGetSymbolicTargetMethodInfo
instance (signature ~ (m 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 'GI.Ggit.Objects.Ref.Ref'. -}
    -> m Ggit.OId.OId
    {- ^ __Returns:__ a new oid if available, 'Nothing' otherwise. -}
refGetTarget ref = liftIO $ do
    ref' <- unsafeManagedPtrCastPtr ref
    result <- ggit_ref_get_target ref'
    checkUnexpectedReturnNULL "refGetTarget" result
    result' <- (wrapBoxed Ggit.OId.OId) result
    touchManagedPtr ref
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RefGetTargetMethodInfo
instance (signature ~ (m 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 'GI.Ggit.Objects.Ref.Ref'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@ref@/ has a log, '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) && !defined(__HADDOCK_VERSION__)
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 'GI.Ggit.Objects.Ref.Ref'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the reference is a branch, '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) && !defined(__HADDOCK_VERSION__)
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 'GI.Ggit.Objects.Ref.Ref'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the reference is a note, '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) && !defined(__HADDOCK_VERSION__)
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 'GI.Ggit.Objects.Ref.Ref'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the reference is a remote, '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) && !defined(__HADDOCK_VERSION__)
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 'GI.Ggit.Objects.Ref.Ref'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the reference is a tag, '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) && !defined(__HADDOCK_VERSION__)
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 'GI.Ggit.Objects.Ref.Ref'. -}
    -> m Ggit.Object.Object
    {- ^ __Returns:__ a 'GI.Ggit.Objects.Object.Object'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
refLookup ref = liftIO $ do
    ref' <- unsafeManagedPtrCastPtr ref
    onException (do
        result <- propagateGError $ ggit_ref_lookup ref'
        checkUnexpectedReturnNULL "refLookup" result
        result' <- (wrapObject Ggit.Object.Object) result
        touchManagedPtr ref
        return result'
     ) (do
        return ()
     )

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RefLookupMethodInfo
instance (signature ~ (m 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 '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 'GI.Ggit.Objects.Ref.Ref'. -}
    -> T.Text
    {- ^ /@newName@/: the new name. -}
    -> Bool
    {- ^ /@force@/: 'True' to force the renaming. -}
    -> T.Text
    {- ^ /@logMessage@/: The one line long message to be appended to the reflog. -}
    -> m Ref
    {- ^ __Returns:__ a newly created 'GI.Ggit.Objects.Ref.Ref'. /(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'
        checkUnexpectedReturnNULL "refRename" result
        result' <- (wrapObject Ref) result
        touchManagedPtr ref
        freeMem newName'
        freeMem logMessage'
        return result'
     ) (do
        freeMem newName'
        freeMem logMessage'
     )

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RefRenameMethodInfo
instance (signature ~ (T.Text -> Bool -> T.Text -> m 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 'GI.Ggit.Objects.Ref.Ref'. -}
    -> m Ref
    {- ^ __Returns:__ the resolved reference to the peeled one. /(Can throw 'Data.GI.Base.GError.GError')/ -}
refResolve ref = liftIO $ do
    ref' <- unsafeManagedPtrCastPtr ref
    onException (do
        result <- propagateGError $ ggit_ref_resolve ref'
        checkUnexpectedReturnNULL "refResolve" result
        result' <- (wrapObject Ref) result
        touchManagedPtr ref
        return result'
     ) (do
        return ()
     )

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RefResolveMethodInfo
instance (signature ~ (m 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 '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 Ref
    {- ^ __Returns:__ the newly created 'GI.Ggit.Objects.Ref.Ref'. /(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'
        checkUnexpectedReturnNULL "refSetSymbolicTarget" result
        result' <- (wrapObject Ref) result
        touchManagedPtr ref
        freeMem target'
        freeMem logMessage'
        return result'
     ) (do
        freeMem target'
        freeMem logMessage'
     )

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RefSetSymbolicTargetMethodInfo
instance (signature ~ (T.Text -> T.Text -> m 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 'GI.Ggit.Objects.Ref.Ref'. -}
    -> Ggit.OId.OId
    {- ^ /@oid@/: a 'GI.Ggit.Structs.OId.OId'. -}
    -> T.Text
    {- ^ /@logMessage@/: The one line long message to be appended to the reflog. -}
    -> m Ref
    {- ^ __Returns:__ the newly created 'GI.Ggit.Objects.Ref.Ref'. /(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'
        checkUnexpectedReturnNULL "refSetTarget" result
        result' <- (wrapObject Ref) result
        touchManagedPtr ref
        touchManagedPtr oid
        freeMem logMessage'
        return result'
     ) (do
        freeMem logMessage'
     )

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RefSetTargetMethodInfo
instance (signature ~ (Ggit.OId.OId -> T.Text -> m 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 'GI.Ggit.Objects.Ref.Ref'. -}
    -> m T.Text
    {- ^ __Returns:__ a string representation of the ref. -}
refToString ref = liftIO $ do
    ref' <- unsafeManagedPtrCastPtr ref
    result <- ggit_ref_to_string ref'
    checkUnexpectedReturnNULL "refToString" result
    result' <- cstringToText result
    touchManagedPtr ref
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RefToStringMethodInfo
instance (signature ~ (m 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:__ 'True' if /@name@/ is valid, '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) && !defined(__HADDOCK_VERSION__)
#endif