{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- Represents a git submodule.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Ggit.Structs.Submodule
    (

-- * Exported types
    Submodule(..)                           ,
    noSubmodule                             ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveSubmoduleMethod                  ,
#endif


-- ** getFetchRecurse #method:getFetchRecurse#

#if defined(ENABLE_OVERLOADING)
    SubmoduleGetFetchRecurseMethodInfo      ,
#endif
    submoduleGetFetchRecurse                ,


-- ** getHeadId #method:getHeadId#

#if defined(ENABLE_OVERLOADING)
    SubmoduleGetHeadIdMethodInfo            ,
#endif
    submoduleGetHeadId                      ,


-- ** getIgnore #method:getIgnore#

#if defined(ENABLE_OVERLOADING)
    SubmoduleGetIgnoreMethodInfo            ,
#endif
    submoduleGetIgnore                      ,


-- ** getIndexId #method:getIndexId#

#if defined(ENABLE_OVERLOADING)
    SubmoduleGetIndexIdMethodInfo           ,
#endif
    submoduleGetIndexId                     ,


-- ** getName #method:getName#

#if defined(ENABLE_OVERLOADING)
    SubmoduleGetNameMethodInfo              ,
#endif
    submoduleGetName                        ,


-- ** getOwner #method:getOwner#

#if defined(ENABLE_OVERLOADING)
    SubmoduleGetOwnerMethodInfo             ,
#endif
    submoduleGetOwner                       ,


-- ** getPath #method:getPath#

#if defined(ENABLE_OVERLOADING)
    SubmoduleGetPathMethodInfo              ,
#endif
    submoduleGetPath                        ,


-- ** getUpdate #method:getUpdate#

#if defined(ENABLE_OVERLOADING)
    SubmoduleGetUpdateMethodInfo            ,
#endif
    submoduleGetUpdate                      ,


-- ** getUrl #method:getUrl#

#if defined(ENABLE_OVERLOADING)
    SubmoduleGetUrlMethodInfo               ,
#endif
    submoduleGetUrl                         ,


-- ** getWorkdirId #method:getWorkdirId#

#if defined(ENABLE_OVERLOADING)
    SubmoduleGetWorkdirIdMethodInfo         ,
#endif
    submoduleGetWorkdirId                   ,


-- ** init #method:init#

#if defined(ENABLE_OVERLOADING)
    SubmoduleInitMethodInfo                 ,
#endif
    submoduleInit                           ,


-- ** open #method:open#

#if defined(ENABLE_OVERLOADING)
    SubmoduleOpenMethodInfo                 ,
#endif
    submoduleOpen                           ,


-- ** ref #method:ref#

#if defined(ENABLE_OVERLOADING)
    SubmoduleRefMethodInfo                  ,
#endif
    submoduleRef                            ,


-- ** reload #method:reload#

#if defined(ENABLE_OVERLOADING)
    SubmoduleReloadMethodInfo               ,
#endif
    submoduleReload                         ,


-- ** sync #method:sync#

#if defined(ENABLE_OVERLOADING)
    SubmoduleSyncMethodInfo                 ,
#endif
    submoduleSync                           ,


-- ** unref #method:unref#

#if defined(ENABLE_OVERLOADING)
    SubmoduleUnrefMethodInfo                ,
#endif
    submoduleUnref                          ,


-- ** update #method:update#

#if defined(ENABLE_OVERLOADING)
    SubmoduleUpdateMethodInfo               ,
#endif
    submoduleUpdate                         ,




    ) 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 {-# SOURCE #-} qualified GI.Ggit.Enums as Ggit.Enums
import {-# SOURCE #-} qualified GI.Ggit.Objects.Repository as Ggit.Repository
import {-# SOURCE #-} qualified GI.Ggit.Objects.SubmoduleUpdateOptions as Ggit.SubmoduleUpdateOptions
import {-# SOURCE #-} qualified GI.Ggit.Structs.OId as Ggit.OId

-- | Memory-managed wrapper type.
newtype Submodule = Submodule (ManagedPtr Submodule)
    deriving (Eq)
foreign import ccall "ggit_submodule_get_type" c_ggit_submodule_get_type ::
    IO GType

instance BoxedObject Submodule where
    boxedType _ = c_ggit_submodule_get_type

-- | Convert 'Submodule' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue Submodule where
    toGValue o = do
        gtype <- c_ggit_submodule_get_type
        B.ManagedPtr.withManagedPtr o (B.GValue.buildGValue gtype B.GValue.set_boxed)

    fromGValue gv = do
        ptr <- B.GValue.get_boxed gv :: IO (Ptr Submodule)
        B.ManagedPtr.newBoxed Submodule ptr



-- | A convenience alias for `Nothing` :: `Maybe` `Submodule`.
noSubmodule :: Maybe Submodule
noSubmodule = Nothing


#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Submodule
type instance O.AttributeList Submodule = SubmoduleAttributeList
type SubmoduleAttributeList = ('[ ] :: [(Symbol, *)])
#endif

-- method Submodule::get_fetch_recurse
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , 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_submodule_get_fetch_recurse" ggit_submodule_get_fetch_recurse ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    IO CInt

-- | Gets whether to fetch recursively. See see gitmodules(5) fetchRecurseSubmodules.
submoduleGetFetchRecurse ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> m Bool
    -- ^ __Returns:__ whether or not fetch recursively.
submoduleGetFetchRecurse submodule = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    result <- ggit_submodule_get_fetch_recurse submodule'
    let result' = (/= 0) result
    touchManagedPtr submodule
    return result'

#if defined(ENABLE_OVERLOADING)
data SubmoduleGetFetchRecurseMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo SubmoduleGetFetchRecurseMethodInfo Submodule signature where
    overloadedMethod = submoduleGetFetchRecurse

#endif

-- method Submodule::get_head_id
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , 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_submodule_get_head_id" ggit_submodule_get_head_id ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    IO (Ptr Ggit.OId.OId)

-- | /No description available in the introspection data./
submoduleGetHeadId ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -> m Ggit.OId.OId
submoduleGetHeadId submodule = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    result <- ggit_submodule_get_head_id submodule'
    checkUnexpectedReturnNULL "submoduleGetHeadId" result
    result' <- (wrapBoxed Ggit.OId.OId) result
    touchManagedPtr submodule
    return result'

#if defined(ENABLE_OVERLOADING)
data SubmoduleGetHeadIdMethodInfo
instance (signature ~ (m Ggit.OId.OId), MonadIO m) => O.MethodInfo SubmoduleGetHeadIdMethodInfo Submodule signature where
    overloadedMethod = submoduleGetHeadId

#endif

-- method Submodule::get_ignore
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "Ggit" , name = "SubmoduleIgnore" })
-- throws : False
-- Skip return : False

foreign import ccall "ggit_submodule_get_ignore" ggit_submodule_get_ignore ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    IO CInt

-- | Gets a t'GI.Ggit.Enums.SubmoduleIgnore'. See see gitmodules(5) ignore.
submoduleGetIgnore ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> m Ggit.Enums.SubmoduleIgnore
    -- ^ __Returns:__ the t'GI.Ggit.Enums.SubmoduleIgnore'.
submoduleGetIgnore submodule = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    result <- ggit_submodule_get_ignore submodule'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr submodule
    return result'

#if defined(ENABLE_OVERLOADING)
data SubmoduleGetIgnoreMethodInfo
instance (signature ~ (m Ggit.Enums.SubmoduleIgnore), MonadIO m) => O.MethodInfo SubmoduleGetIgnoreMethodInfo Submodule signature where
    overloadedMethod = submoduleGetIgnore

#endif

-- method Submodule::get_index_id
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , 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_submodule_get_index_id" ggit_submodule_get_index_id ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    IO (Ptr Ggit.OId.OId)

-- | Gets the OID for the submodule in the index or 'P.Nothing' if there is no index.
submoduleGetIndexId ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> m (Maybe Ggit.OId.OId)
    -- ^ __Returns:__ the OID for the submodule in the index or 'P.Nothing'.
submoduleGetIndexId submodule = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    result <- ggit_submodule_get_index_id submodule'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Ggit.OId.OId) result'
        return result''
    touchManagedPtr submodule
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data SubmoduleGetIndexIdMethodInfo
instance (signature ~ (m (Maybe Ggit.OId.OId)), MonadIO m) => O.MethodInfo SubmoduleGetIndexIdMethodInfo Submodule signature where
    overloadedMethod = submoduleGetIndexId

#endif

-- method Submodule::get_name
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , 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_submodule_get_name" ggit_submodule_get_name ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    IO CString

-- | Gets the name of the submodule from .gitmodules.
submoduleGetName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> m (Maybe T.Text)
    -- ^ __Returns:__ the name of the submodule from .gitmodules or 'P.Nothing'.
submoduleGetName submodule = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    result <- ggit_submodule_get_name submodule'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        return result''
    touchManagedPtr submodule
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data SubmoduleGetNameMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m) => O.MethodInfo SubmoduleGetNameMethodInfo Submodule signature where
    overloadedMethod = submoduleGetName

#endif

-- method Submodule::get_owner
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , 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_submodule_get_owner" ggit_submodule_get_owner ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    IO (Ptr Ggit.Repository.Repository)

-- | Gets the containing repository for a submodule.
submoduleGetOwner ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> m (Maybe Ggit.Repository.Repository)
    -- ^ __Returns:__ the containing repository for a submodule or 'P.Nothing'.
submoduleGetOwner submodule = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    result <- ggit_submodule_get_owner submodule'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Ggit.Repository.Repository) result'
        return result''
    touchManagedPtr submodule
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data SubmoduleGetOwnerMethodInfo
instance (signature ~ (m (Maybe Ggit.Repository.Repository)), MonadIO m) => O.MethodInfo SubmoduleGetOwnerMethodInfo Submodule signature where
    overloadedMethod = submoduleGetOwner

#endif

-- method Submodule::get_path
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , 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_submodule_get_path" ggit_submodule_get_path ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    IO CString

-- | Gets the path to the submodule from the repo working directory.
-- It is almost always the same as the name.
-- See 'GI.Ggit.Structs.Submodule.submoduleGetName'.
submoduleGetPath ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> m (Maybe T.Text)
    -- ^ __Returns:__ the path to the submodule from
    -- the repo working directory or 'P.Nothing'.
submoduleGetPath submodule = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    result <- ggit_submodule_get_path submodule'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        return result''
    touchManagedPtr submodule
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data SubmoduleGetPathMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m) => O.MethodInfo SubmoduleGetPathMethodInfo Submodule signature where
    overloadedMethod = submoduleGetPath

#endif

-- method Submodule::get_update
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "Ggit" , name = "SubmoduleUpdate" })
-- throws : False
-- Skip return : False

foreign import ccall "ggit_submodule_get_update" ggit_submodule_get_update ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    IO CUInt

-- | Gets a t'GI.Ggit.Enums.SubmoduleUpdate'. See see gitmodules(5) update.
submoduleGetUpdate ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> m Ggit.Enums.SubmoduleUpdate
    -- ^ __Returns:__ the t'GI.Ggit.Enums.SubmoduleUpdate'.
submoduleGetUpdate submodule = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    result <- ggit_submodule_get_update submodule'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr submodule
    return result'

#if defined(ENABLE_OVERLOADING)
data SubmoduleGetUpdateMethodInfo
instance (signature ~ (m Ggit.Enums.SubmoduleUpdate), MonadIO m) => O.MethodInfo SubmoduleGetUpdateMethodInfo Submodule signature where
    overloadedMethod = submoduleGetUpdate

#endif

-- method Submodule::get_url
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , 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_submodule_get_url" ggit_submodule_get_url ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    IO CString

-- | Gets the url for the submodule or 'P.Nothing' if the submodule has been deleted
-- but not yet committed.
submoduleGetUrl ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> m (Maybe T.Text)
    -- ^ __Returns:__ the url for the submodule or 'P.Nothing'.
submoduleGetUrl submodule = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    result <- ggit_submodule_get_url submodule'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        return result''
    touchManagedPtr submodule
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data SubmoduleGetUrlMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m) => O.MethodInfo SubmoduleGetUrlMethodInfo Submodule signature where
    overloadedMethod = submoduleGetUrl

#endif

-- method Submodule::get_workdir_id
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , 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_submodule_get_workdir_id" ggit_submodule_get_workdir_id ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    IO (Ptr Ggit.OId.OId)

-- | Gets the OID for the submodule in the current working directory.
-- Corresponds to looking up \'HEAD\' in the checked out submodule.
-- If there are pending changes in the index or anything
-- else, this won\'t notice that.  You should call @/ggit_submodule_status()/@
-- for a more complete picture about the state of the working directory.
submoduleGetWorkdirId ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> m (Maybe Ggit.OId.OId)
    -- ^ __Returns:__ the OID for the submodule in the current working directory or 'P.Nothing'.
submoduleGetWorkdirId submodule = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    result <- ggit_submodule_get_workdir_id submodule'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Ggit.OId.OId) result'
        return result''
    touchManagedPtr submodule
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data SubmoduleGetWorkdirIdMethodInfo
instance (signature ~ (m (Maybe Ggit.OId.OId)), MonadIO m) => O.MethodInfo SubmoduleGetWorkdirIdMethodInfo Submodule signature where
    overloadedMethod = submoduleGetWorkdirId

#endif

-- method Submodule::init
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "overwrite"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "forces existing entries to be updated."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ggit_submodule_init" ggit_submodule_init ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    CInt ->                                 -- overwrite : TBasicType TBoolean
    Ptr (Ptr GError) ->                     -- error
    IO ()

-- | Just like \"git submodule init\", this copies information about the
-- submodule into \".git\/config\".  You can use the accessor functions
-- above to alter the in-memory git_submodule object and control what
-- is written to the config, overriding what is in .gitmodules.
submoduleInit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> Bool
    -- ^ /@overwrite@/: forces existing entries to be updated.
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
submoduleInit submodule overwrite = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    let overwrite' = (fromIntegral . fromEnum) overwrite
    onException (do
        propagateGError $ ggit_submodule_init submodule' overwrite'
        touchManagedPtr submodule
        return ()
     ) (do
        return ()
     )

#if defined(ENABLE_OVERLOADING)
data SubmoduleInitMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo SubmoduleInitMethodInfo Submodule signature where
    overloadedMethod = submoduleInit

#endif

-- method Submodule::open
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Ggit" , name = "Repository" })
-- throws : True
-- Skip return : False

foreign import ccall "ggit_submodule_open" ggit_submodule_open ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Ggit.Repository.Repository)

-- | Open the repository for a submodule. Multiple calls to this function
-- will return distinct t'GI.Ggit.Objects.Repository.Repository' objects. Only submodules which are
-- checked out in the working directory can be opened.
submoduleOpen ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> m (Maybe Ggit.Repository.Repository)
    -- ^ __Returns:__ the opened t'GI.Ggit.Objects.Repository.Repository' or 'P.Nothing' in case of an
    --                           error. /(Can throw 'Data.GI.Base.GError.GError')/
submoduleOpen submodule = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    onException (do
        result <- propagateGError $ ggit_submodule_open submodule'
        maybeResult <- convertIfNonNull result $ \result' -> do
            result'' <- (wrapObject Ggit.Repository.Repository) result'
            return result''
        touchManagedPtr submodule
        return maybeResult
     ) (do
        return ()
     )

#if defined(ENABLE_OVERLOADING)
data SubmoduleOpenMethodInfo
instance (signature ~ (m (Maybe Ggit.Repository.Repository)), MonadIO m) => O.MethodInfo SubmoduleOpenMethodInfo Submodule signature where
    overloadedMethod = submoduleOpen

#endif

-- method Submodule::ref
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Ggit" , name = "Submodule" })
-- throws : False
-- Skip return : False

foreign import ccall "ggit_submodule_ref" ggit_submodule_ref ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    IO (Ptr Submodule)

-- | Atomically increments the reference count of /@submodule@/ by one.
-- This function is MT-safe and may be called from any thread.
submoduleRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> m (Maybe Submodule)
    -- ^ __Returns:__ the passed in t'GI.Ggit.Structs.Submodule.Submodule' or 'P.Nothing'.
submoduleRef submodule = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    result <- ggit_submodule_ref submodule'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newBoxed Submodule) result'
        return result''
    touchManagedPtr submodule
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data SubmoduleRefMethodInfo
instance (signature ~ (m (Maybe Submodule)), MonadIO m) => O.MethodInfo SubmoduleRefMethodInfo Submodule signature where
    overloadedMethod = submoduleRef

#endif

-- method Submodule::reload
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , 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 "reload even if the data doesn't seem out of date."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ggit_submodule_reload" ggit_submodule_reload ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    CInt ->                                 -- force : TBasicType TBoolean
    Ptr (Ptr GError) ->                     -- error
    IO ()

-- | Rereads submodule info from config, index, and HEAD.
-- Call this if you have reason to believe that it has changed.
submoduleReload ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> Bool
    -- ^ /@force@/: reload even if the data doesn\'t seem out of date.
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
submoduleReload submodule force = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    let force' = (fromIntegral . fromEnum) force
    onException (do
        propagateGError $ ggit_submodule_reload submodule' force'
        touchManagedPtr submodule
        return ()
     ) (do
        return ()
     )

#if defined(ENABLE_OVERLOADING)
data SubmoduleReloadMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo SubmoduleReloadMethodInfo Submodule signature where
    overloadedMethod = submoduleReload

#endif

-- method Submodule::sync
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ggit_submodule_sync" ggit_submodule_sync ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    Ptr (Ptr GError) ->                     -- error
    IO ()

-- | Copies the information about the submodules URL into the checked out
-- submodule config, acting like \"git submodule sync\".  This is useful if
-- you have altered the URL for the submodule (or it has been altered by a
-- fetch of upstream changes) and you need to update your local repo.
submoduleSync ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
submoduleSync submodule = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    onException (do
        propagateGError $ ggit_submodule_sync submodule'
        touchManagedPtr submodule
        return ()
     ) (do
        return ()
     )

#if defined(ENABLE_OVERLOADING)
data SubmoduleSyncMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo SubmoduleSyncMethodInfo Submodule signature where
    overloadedMethod = submoduleSync

#endif

-- method Submodule::unref
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ggit_submodule_unref" ggit_submodule_unref ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    IO ()

-- | Atomically decrements the reference count of /@submodule@/ by one.
-- If the reference count drops to 0, /@remote@/ is freed.
submoduleUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> m ()
submoduleUnref submodule = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    ggit_submodule_unref submodule'
    touchManagedPtr submodule
    return ()

#if defined(ENABLE_OVERLOADING)
data SubmoduleUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo SubmoduleUnrefMethodInfo Submodule signature where
    overloadedMethod = submoduleUnref

#endif

-- method Submodule::update
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "submodule"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "Submodule" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmodule." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "init"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "If the submodule is not initialized, setting this flag to true\n       will initialize the submodule before updating. Otherwise, this\n       will return an error if attempting to update an uninitialzed\n       repository. but setting this to true forces them to be updated."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "options"
--           , argType =
--               TInterface
--                 Name { namespace = "Ggit" , name = "SubmoduleUpdateOptions" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitSubmoduleUpdateOptions object."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ggit_submodule_update" ggit_submodule_update ::
    Ptr Submodule ->                        -- submodule : TInterface (Name {namespace = "Ggit", name = "Submodule"})
    CInt ->                                 -- init : TBasicType TBoolean
    Ptr Ggit.SubmoduleUpdateOptions.SubmoduleUpdateOptions -> -- options : TInterface (Name {namespace = "Ggit", name = "SubmoduleUpdateOptions"})
    Ptr (Ptr GError) ->                     -- error
    IO ()

-- | Update a submodule. This will clone a missing submodule and checkout
-- the subrepository to the commit specified in the index of the containing
-- repository. If the submodule repository doesn\'t contain the target commit
-- (e.g. because fetchRecurseSubmodules isn\'t set), then the submodule is
-- fetched using the fetch options supplied in options.
submoduleUpdate ::
    (B.CallStack.HasCallStack, MonadIO m, Ggit.SubmoduleUpdateOptions.IsSubmoduleUpdateOptions a) =>
    Submodule
    -- ^ /@submodule@/: a t'GI.Ggit.Structs.Submodule.Submodule'.
    -> Bool
    -- ^ /@init@/: If the submodule is not initialized, setting this flag to true
    --        will initialize the submodule before updating. Otherwise, this
    --        will return an error if attempting to update an uninitialzed
    --        repository. but setting this to true forces them to be updated.
    -> a
    -- ^ /@options@/: a t'GI.Ggit.Objects.SubmoduleUpdateOptions.SubmoduleUpdateOptions' object.
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
submoduleUpdate submodule init options = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    let init' = (fromIntegral . fromEnum) init
    options' <- unsafeManagedPtrCastPtr options
    onException (do
        propagateGError $ ggit_submodule_update submodule' init' options'
        touchManagedPtr submodule
        touchManagedPtr options
        return ()
     ) (do
        return ()
     )

#if defined(ENABLE_OVERLOADING)
data SubmoduleUpdateMethodInfo
instance (signature ~ (Bool -> a -> m ()), MonadIO m, Ggit.SubmoduleUpdateOptions.IsSubmoduleUpdateOptions a) => O.MethodInfo SubmoduleUpdateMethodInfo Submodule signature where
    overloadedMethod = submoduleUpdate

#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveSubmoduleMethod (t :: Symbol) (o :: *) :: * where
    ResolveSubmoduleMethod "init" o = SubmoduleInitMethodInfo
    ResolveSubmoduleMethod "open" o = SubmoduleOpenMethodInfo
    ResolveSubmoduleMethod "ref" o = SubmoduleRefMethodInfo
    ResolveSubmoduleMethod "reload" o = SubmoduleReloadMethodInfo
    ResolveSubmoduleMethod "sync" o = SubmoduleSyncMethodInfo
    ResolveSubmoduleMethod "unref" o = SubmoduleUnrefMethodInfo
    ResolveSubmoduleMethod "update" o = SubmoduleUpdateMethodInfo
    ResolveSubmoduleMethod "getFetchRecurse" o = SubmoduleGetFetchRecurseMethodInfo
    ResolveSubmoduleMethod "getHeadId" o = SubmoduleGetHeadIdMethodInfo
    ResolveSubmoduleMethod "getIgnore" o = SubmoduleGetIgnoreMethodInfo
    ResolveSubmoduleMethod "getIndexId" o = SubmoduleGetIndexIdMethodInfo
    ResolveSubmoduleMethod "getName" o = SubmoduleGetNameMethodInfo
    ResolveSubmoduleMethod "getOwner" o = SubmoduleGetOwnerMethodInfo
    ResolveSubmoduleMethod "getPath" o = SubmoduleGetPathMethodInfo
    ResolveSubmoduleMethod "getUpdate" o = SubmoduleGetUpdateMethodInfo
    ResolveSubmoduleMethod "getUrl" o = SubmoduleGetUrlMethodInfo
    ResolveSubmoduleMethod "getWorkdirId" o = SubmoduleGetWorkdirIdMethodInfo
    ResolveSubmoduleMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveSubmoduleMethod t Submodule, O.MethodInfo info Submodule p) => OL.IsLabel t (Submodule -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif