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

Represents a commit object.
-}

module GI.Ggit.Objects.Commit
    ( 

-- * Exported types
    Commit(..)                              ,
    IsCommit                                ,
    toCommit                                ,
    noCommit                                ,


 -- * Methods
-- ** amend #method:amend#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    CommitAmendMethodInfo                   ,
#endif
    commitAmend                             ,


-- ** getAuthor #method:getAuthor#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    CommitGetAuthorMethodInfo               ,
#endif
    commitGetAuthor                         ,


-- ** getCommitter #method:getCommitter#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    CommitGetCommitterMethodInfo            ,
#endif
    commitGetCommitter                      ,


-- ** getMessage #method:getMessage#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    CommitGetMessageMethodInfo              ,
#endif
    commitGetMessage                        ,


-- ** getMessageEncoding #method:getMessageEncoding#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    CommitGetMessageEncodingMethodInfo      ,
#endif
    commitGetMessageEncoding                ,


-- ** getNthAncestor #method:getNthAncestor#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    CommitGetNthAncestorMethodInfo          ,
#endif
    commitGetNthAncestor                    ,


-- ** getParents #method:getParents#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    CommitGetParentsMethodInfo              ,
#endif
    commitGetParents                        ,


-- ** getSubject #method:getSubject#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    CommitGetSubjectMethodInfo              ,
#endif
    commitGetSubject                        ,


-- ** getTree #method:getTree#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    CommitGetTreeMethodInfo                 ,
#endif
    commitGetTree                           ,


-- ** getTreeId #method:getTreeId#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    CommitGetTreeIdMethodInfo               ,
#endif
    commitGetTreeId                         ,




    ) 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.Objects.CommitParents as Ggit.CommitParents
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.Signature as Ggit.Signature
import {-# SOURCE #-} qualified GI.Ggit.Objects.Tree as Ggit.Tree
import {-# SOURCE #-} qualified GI.Ggit.Structs.OId as Ggit.OId

newtype Commit = Commit (ManagedPtr Commit)
foreign import ccall "ggit_commit_get_type"
    c_ggit_commit_get_type :: IO GType

instance GObject Commit where
    gobjectType _ = c_ggit_commit_get_type
    

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

toCommit :: (MonadIO m, IsCommit o) => o -> m Commit
toCommit = liftIO . unsafeCastTo Commit

noCommit :: Maybe Commit
noCommit = Nothing

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveCommitMethod (t :: Symbol) (o :: *) :: * where
    ResolveCommitMethod "amend" o = CommitAmendMethodInfo
    ResolveCommitMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveCommitMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveCommitMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveCommitMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveCommitMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveCommitMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveCommitMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveCommitMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveCommitMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveCommitMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveCommitMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveCommitMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveCommitMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveCommitMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveCommitMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveCommitMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveCommitMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveCommitMethod "getAuthor" o = CommitGetAuthorMethodInfo
    ResolveCommitMethod "getCommitter" o = CommitGetCommitterMethodInfo
    ResolveCommitMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveCommitMethod "getId" o = Ggit.Object.ObjectGetIdMethodInfo
    ResolveCommitMethod "getMessage" o = CommitGetMessageMethodInfo
    ResolveCommitMethod "getMessageEncoding" o = CommitGetMessageEncodingMethodInfo
    ResolveCommitMethod "getNthAncestor" o = CommitGetNthAncestorMethodInfo
    ResolveCommitMethod "getOwner" o = Ggit.Object.ObjectGetOwnerMethodInfo
    ResolveCommitMethod "getParents" o = CommitGetParentsMethodInfo
    ResolveCommitMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveCommitMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveCommitMethod "getSubject" o = CommitGetSubjectMethodInfo
    ResolveCommitMethod "getTree" o = CommitGetTreeMethodInfo
    ResolveCommitMethod "getTreeId" o = CommitGetTreeIdMethodInfo
    ResolveCommitMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveCommitMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveCommitMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveCommitMethod t Commit, O.MethodInfo info Commit p) => O.IsLabelProxy t (Commit -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveCommitMethod t Commit, O.MethodInfo info Commit p) => O.IsLabel t (Commit -> 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 Commit
type instance O.AttributeList Commit = CommitAttributeList
type CommitAttributeList = ('[ '("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 Commit = CommitSignalList
type CommitSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method Commit::amend
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "commit", argType = TInterface (Name {namespace = "Ggit", name = "Commit"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitCommit.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "update_ref", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "name of the reference to update.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "author", argType = TInterface (Name {namespace = "Ggit", name = "Signature"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "author signature.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "committer", argType = TInterface (Name {namespace = "Ggit", name = "Signature"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "committer signature (and time of commit).", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "message_encoding", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "message encoding.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "message", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "commit message.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "tree", argType = TInterface (Name {namespace = "Ggit", name = "Tree"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the tree of objects to commit.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "OId"}))
-- throws : True
-- Skip return : False

foreign import ccall "ggit_commit_amend" ggit_commit_amend :: 
    Ptr Commit ->                           -- commit : TInterface (Name {namespace = "Ggit", name = "Commit"})
    CString ->                              -- update_ref : TBasicType TUTF8
    Ptr Ggit.Signature.Signature ->         -- author : TInterface (Name {namespace = "Ggit", name = "Signature"})
    Ptr Ggit.Signature.Signature ->         -- committer : TInterface (Name {namespace = "Ggit", name = "Signature"})
    CString ->                              -- message_encoding : TBasicType TUTF8
    CString ->                              -- message : TBasicType TUTF8
    Ptr Ggit.Tree.Tree ->                   -- tree : TInterface (Name {namespace = "Ggit", name = "Tree"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Ggit.OId.OId)

{- |
Amend an existing commit. If /@updateRef@/ is not 'Nothing', the given reference will
be updated to point to the newly created commit. Use \"HEAD\" to update the
HEAD of the current branch and make it point to this commit.

If /@messageEncoding@/ is set to 'Nothing', \"UTF-8\" encoding is assumed for the
provided /@message@/. Note that /@message@/ will not be cleaned up automatically.
You can use @/ggit_message_prettify/@ to do this yourself if needed.
-}
commitAmend ::
    (B.CallStack.HasCallStack, MonadIO m, IsCommit a, Ggit.Signature.IsSignature b, Ggit.Signature.IsSignature c, Ggit.Tree.IsTree d) =>
    a
    {- ^ /@commit@/: a 'GI.Ggit.Objects.Commit.Commit'. -}
    -> Maybe (T.Text)
    {- ^ /@updateRef@/: name of the reference to update. -}
    -> b
    {- ^ /@author@/: author signature. -}
    -> c
    {- ^ /@committer@/: committer signature (and time of commit). -}
    -> Maybe (T.Text)
    {- ^ /@messageEncoding@/: message encoding. -}
    -> T.Text
    {- ^ /@message@/: commit message. -}
    -> d
    {- ^ /@tree@/: the tree of objects to commit. -}
    -> m Ggit.OId.OId
    {- ^ __Returns:__ the 'GI.Ggit.Structs.OId.OId' of the created commit object, or 'Nothing' in case of an error. /(Can throw 'Data.GI.Base.GError.GError')/ -}
commitAmend commit updateRef author committer messageEncoding message tree = liftIO $ do
    commit' <- unsafeManagedPtrCastPtr commit
    maybeUpdateRef <- case updateRef of
        Nothing -> return nullPtr
        Just jUpdateRef -> do
            jUpdateRef' <- textToCString jUpdateRef
            return jUpdateRef'
    author' <- unsafeManagedPtrCastPtr author
    committer' <- unsafeManagedPtrCastPtr committer
    maybeMessageEncoding <- case messageEncoding of
        Nothing -> return nullPtr
        Just jMessageEncoding -> do
            jMessageEncoding' <- textToCString jMessageEncoding
            return jMessageEncoding'
    message' <- textToCString message
    tree' <- unsafeManagedPtrCastPtr tree
    onException (do
        result <- propagateGError $ ggit_commit_amend commit' maybeUpdateRef author' committer' maybeMessageEncoding message' tree'
        checkUnexpectedReturnNULL "commitAmend" result
        result' <- (wrapBoxed Ggit.OId.OId) result
        touchManagedPtr commit
        touchManagedPtr author
        touchManagedPtr committer
        touchManagedPtr tree
        freeMem maybeUpdateRef
        freeMem maybeMessageEncoding
        freeMem message'
        return result'
     ) (do
        freeMem maybeUpdateRef
        freeMem maybeMessageEncoding
        freeMem message'
     )

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data CommitAmendMethodInfo
instance (signature ~ (Maybe (T.Text) -> b -> c -> Maybe (T.Text) -> T.Text -> d -> m Ggit.OId.OId), MonadIO m, IsCommit a, Ggit.Signature.IsSignature b, Ggit.Signature.IsSignature c, Ggit.Tree.IsTree d) => O.MethodInfo CommitAmendMethodInfo a signature where
    overloadedMethod _ = commitAmend

#endif

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

foreign import ccall "ggit_commit_get_author" ggit_commit_get_author :: 
    Ptr Commit ->                           -- commit : TInterface (Name {namespace = "Ggit", name = "Commit"})
    IO (Ptr Ggit.Signature.Signature)

{- |
Gets the author of /@commit@/. The returned value must be free\'d with
'GI.GObject.Objects.Object.objectUnref'.
-}
commitGetAuthor ::
    (B.CallStack.HasCallStack, MonadIO m, IsCommit a) =>
    a
    {- ^ /@commit@/: a 'GI.Ggit.Objects.Commit.Commit'. -}
    -> m Ggit.Signature.Signature
    {- ^ __Returns:__ the author of the commit. -}
commitGetAuthor commit = liftIO $ do
    commit' <- unsafeManagedPtrCastPtr commit
    result <- ggit_commit_get_author commit'
    checkUnexpectedReturnNULL "commitGetAuthor" result
    result' <- (wrapObject Ggit.Signature.Signature) result
    touchManagedPtr commit
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data CommitGetAuthorMethodInfo
instance (signature ~ (m Ggit.Signature.Signature), MonadIO m, IsCommit a) => O.MethodInfo CommitGetAuthorMethodInfo a signature where
    overloadedMethod _ = commitGetAuthor

#endif

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

foreign import ccall "ggit_commit_get_committer" ggit_commit_get_committer :: 
    Ptr Commit ->                           -- commit : TInterface (Name {namespace = "Ggit", name = "Commit"})
    IO (Ptr Ggit.Signature.Signature)

{- |
Gets the committer of /@commit@/. The returned value must be free\'d with
'GI.GObject.Objects.Object.objectUnref'.
-}
commitGetCommitter ::
    (B.CallStack.HasCallStack, MonadIO m, IsCommit a) =>
    a
    {- ^ /@commit@/: a 'GI.Ggit.Objects.Commit.Commit'. -}
    -> m Ggit.Signature.Signature
    {- ^ __Returns:__ the committer of the commit. -}
commitGetCommitter commit = liftIO $ do
    commit' <- unsafeManagedPtrCastPtr commit
    result <- ggit_commit_get_committer commit'
    checkUnexpectedReturnNULL "commitGetCommitter" result
    result' <- (wrapObject Ggit.Signature.Signature) result
    touchManagedPtr commit
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data CommitGetCommitterMethodInfo
instance (signature ~ (m Ggit.Signature.Signature), MonadIO m, IsCommit a) => O.MethodInfo CommitGetCommitterMethodInfo a signature where
    overloadedMethod _ = commitGetCommitter

#endif

-- method Commit::get_message
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "commit", argType = TInterface (Name {namespace = "Ggit", name = "Commit"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitCommit.", 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_commit_get_message" ggit_commit_get_message :: 
    Ptr Commit ->                           -- commit : TInterface (Name {namespace = "Ggit", name = "Commit"})
    IO CString

{- |
Gets the full message of /@commit@/. The resulting message is always encoded
in UTF-8.
-}
commitGetMessage ::
    (B.CallStack.HasCallStack, MonadIO m, IsCommit a) =>
    a
    {- ^ /@commit@/: a 'GI.Ggit.Objects.Commit.Commit'. -}
    -> m T.Text
    {- ^ __Returns:__ the message of the commit. -}
commitGetMessage commit = liftIO $ do
    commit' <- unsafeManagedPtrCastPtr commit
    result <- ggit_commit_get_message commit'
    checkUnexpectedReturnNULL "commitGetMessage" result
    result' <- cstringToText result
    touchManagedPtr commit
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data CommitGetMessageMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsCommit a) => O.MethodInfo CommitGetMessageMethodInfo a signature where
    overloadedMethod _ = commitGetMessage

#endif

-- method Commit::get_message_encoding
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "commit", argType = TInterface (Name {namespace = "Ggit", name = "Commit"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitCommit.", 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_commit_get_message_encoding" ggit_commit_get_message_encoding :: 
    Ptr Commit ->                           -- commit : TInterface (Name {namespace = "Ggit", name = "Commit"})
    IO CString

{- |
Get the encoding for the message of a commit,
as a string representing a standard encoding name.

The encoding may be 'Nothing' if the \'encoding\' header
in the commit is missing; in that case UTF-8 is assumed.
-}
commitGetMessageEncoding ::
    (B.CallStack.HasCallStack, MonadIO m, IsCommit a) =>
    a
    {- ^ /@commit@/: a 'GI.Ggit.Objects.Commit.Commit'. -}
    -> m T.Text
    {- ^ __Returns:__ the encoding of the commit message or 'Nothing'. -}
commitGetMessageEncoding commit = liftIO $ do
    commit' <- unsafeManagedPtrCastPtr commit
    result <- ggit_commit_get_message_encoding commit'
    checkUnexpectedReturnNULL "commitGetMessageEncoding" result
    result' <- cstringToText result
    touchManagedPtr commit
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data CommitGetMessageEncodingMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsCommit a) => O.MethodInfo CommitGetMessageEncodingMethodInfo a signature where
    overloadedMethod _ = commitGetMessageEncoding

#endif

-- method Commit::get_nth_ancestor
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "commit", argType = TInterface (Name {namespace = "Ggit", name = "Commit"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitCommit.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the requested ancestor.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "Commit"}))
-- throws : True
-- Skip return : False

foreign import ccall "ggit_commit_get_nth_ancestor" ggit_commit_get_nth_ancestor :: 
    Ptr Commit ->                           -- commit : TInterface (Name {namespace = "Ggit", name = "Commit"})
    Word32 ->                               -- n : TBasicType TUInt
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Commit)

{- |
Gets the commit object that is the n-th generation ancestor
of the named commit object, following only the first parents.
Passing @/0/@ to the /@n@/ parameter returns another instance of /@commit@/.
-}
commitGetNthAncestor ::
    (B.CallStack.HasCallStack, MonadIO m, IsCommit a) =>
    a
    {- ^ /@commit@/: a 'GI.Ggit.Objects.Commit.Commit'. -}
    -> Word32
    {- ^ /@n@/: the requested ancestor. -}
    -> m Commit
    {- ^ __Returns:__ the /@n@/ ancestor commit. /(Can throw 'Data.GI.Base.GError.GError')/ -}
commitGetNthAncestor commit n = liftIO $ do
    commit' <- unsafeManagedPtrCastPtr commit
    onException (do
        result <- propagateGError $ ggit_commit_get_nth_ancestor commit' n
        checkUnexpectedReturnNULL "commitGetNthAncestor" result
        result' <- (wrapObject Commit) result
        touchManagedPtr commit
        return result'
     ) (do
        return ()
     )

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data CommitGetNthAncestorMethodInfo
instance (signature ~ (Word32 -> m Commit), MonadIO m, IsCommit a) => O.MethodInfo CommitGetNthAncestorMethodInfo a signature where
    overloadedMethod _ = commitGetNthAncestor

#endif

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

foreign import ccall "ggit_commit_get_parents" ggit_commit_get_parents :: 
    Ptr Commit ->                           -- commit : TInterface (Name {namespace = "Ggit", name = "Commit"})
    IO (Ptr Ggit.CommitParents.CommitParents)

{- |
Gets the parents collection for /@commit@/.
-}
commitGetParents ::
    (B.CallStack.HasCallStack, MonadIO m, IsCommit a) =>
    a
    {- ^ /@commit@/: a 'GI.Ggit.Objects.Commit.Commit'. -}
    -> m Ggit.CommitParents.CommitParents
    {- ^ __Returns:__ the parents collection of the commit. -}
commitGetParents commit = liftIO $ do
    commit' <- unsafeManagedPtrCastPtr commit
    result <- ggit_commit_get_parents commit'
    checkUnexpectedReturnNULL "commitGetParents" result
    result' <- (wrapObject Ggit.CommitParents.CommitParents) result
    touchManagedPtr commit
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data CommitGetParentsMethodInfo
instance (signature ~ (m Ggit.CommitParents.CommitParents), MonadIO m, IsCommit a) => O.MethodInfo CommitGetParentsMethodInfo a signature where
    overloadedMethod _ = commitGetParents

#endif

-- method Commit::get_subject
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "commit", argType = TInterface (Name {namespace = "Ggit", name = "Commit"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitCommit.", 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_commit_get_subject" ggit_commit_get_subject :: 
    Ptr Commit ->                           -- commit : TInterface (Name {namespace = "Ggit", name = "Commit"})
    IO CString

{- |
Gets the subject of /@commit@/. The subject of a commit is the first line of
the commit message (as per convention). The resulting subject is always
encoded in UTF-8.
-}
commitGetSubject ::
    (B.CallStack.HasCallStack, MonadIO m, IsCommit a) =>
    a
    {- ^ /@commit@/: a 'GI.Ggit.Objects.Commit.Commit'. -}
    -> m T.Text
    {- ^ __Returns:__ the subject of the commit. -}
commitGetSubject commit = liftIO $ do
    commit' <- unsafeManagedPtrCastPtr commit
    result <- ggit_commit_get_subject commit'
    checkUnexpectedReturnNULL "commitGetSubject" result
    result' <- cstringToText result
    touchManagedPtr commit
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data CommitGetSubjectMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsCommit a) => O.MethodInfo CommitGetSubjectMethodInfo a signature where
    overloadedMethod _ = commitGetSubject

#endif

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

foreign import ccall "ggit_commit_get_tree" ggit_commit_get_tree :: 
    Ptr Commit ->                           -- commit : TInterface (Name {namespace = "Ggit", name = "Commit"})
    IO (Ptr Ggit.Tree.Tree)

{- |
Get the tree object for /@commit@/.
-}
commitGetTree ::
    (B.CallStack.HasCallStack, MonadIO m, IsCommit a) =>
    a
    {- ^ /@commit@/: a 'GI.Ggit.Objects.Commit.Commit'. -}
    -> m Ggit.Tree.Tree
    {- ^ __Returns:__ a 'GI.Ggit.Objects.Tree.Tree'. -}
commitGetTree commit = liftIO $ do
    commit' <- unsafeManagedPtrCastPtr commit
    result <- ggit_commit_get_tree commit'
    checkUnexpectedReturnNULL "commitGetTree" result
    result' <- (wrapObject Ggit.Tree.Tree) result
    touchManagedPtr commit
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data CommitGetTreeMethodInfo
instance (signature ~ (m Ggit.Tree.Tree), MonadIO m, IsCommit a) => O.MethodInfo CommitGetTreeMethodInfo a signature where
    overloadedMethod _ = commitGetTree

#endif

-- method Commit::get_tree_id
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "commit", argType = TInterface (Name {namespace = "Ggit", name = "Commit"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitCommit.", 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_commit_get_tree_id" ggit_commit_get_tree_id :: 
    Ptr Commit ->                           -- commit : TInterface (Name {namespace = "Ggit", name = "Commit"})
    IO (Ptr Ggit.OId.OId)

{- |
Get the 'GI.Ggit.Structs.OId.OId' of the tree of /@commit@/. Note that this is more efficient
than getting the tree object with 'GI.Ggit.Objects.Commit.commitGetTree' because no additional
files need to be read from disk.
-}
commitGetTreeId ::
    (B.CallStack.HasCallStack, MonadIO m, IsCommit a) =>
    a
    {- ^ /@commit@/: a 'GI.Ggit.Objects.Commit.Commit'. -}
    -> m Ggit.OId.OId
    {- ^ __Returns:__ a 'GI.Ggit.Structs.OId.OId'. -}
commitGetTreeId commit = liftIO $ do
    commit' <- unsafeManagedPtrCastPtr commit
    result <- ggit_commit_get_tree_id commit'
    checkUnexpectedReturnNULL "commitGetTreeId" result
    result' <- (wrapBoxed Ggit.OId.OId) result
    touchManagedPtr commit
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data CommitGetTreeIdMethodInfo
instance (signature ~ (m Ggit.OId.OId), MonadIO m, IsCommit a) => O.MethodInfo CommitGetTreeIdMethodInfo a signature where
    overloadedMethod _ = commitGetTreeId

#endif