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

Represents a diff list.
-}

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

module GI.Ggit.Objects.Diff
    (
#if ENABLE_OVERLOADING
    DiffForeachMethodInfo                   ,
#endif
#if ENABLE_OVERLOADING
    DiffBlobToBufferMethodInfo              ,
#endif
#if ENABLE_OVERLOADING
    DiffBlobsMethodInfo                     ,
#endif

-- * Exported types
    Diff(..)                                ,
    IsDiff                                  ,
    toDiff                                  ,
    noDiff                                  ,


 -- * Methods
-- ** findSimilar #method:findSimilar#

#if ENABLE_OVERLOADING
    DiffFindSimilarMethodInfo               ,
#endif
    diffFindSimilar                         ,


-- ** formatEmail #method:formatEmail#

#if ENABLE_OVERLOADING
    DiffFormatEmailMethodInfo               ,
#endif
    diffFormatEmail                         ,


-- ** getDelta #method:getDelta#

#if ENABLE_OVERLOADING
    DiffGetDeltaMethodInfo                  ,
#endif
    diffGetDelta                            ,


-- ** getNumDeltas #method:getNumDeltas#

#if ENABLE_OVERLOADING
    DiffGetNumDeltasMethodInfo              ,
#endif
    diffGetNumDeltas                        ,


-- ** merge #method:merge#

#if ENABLE_OVERLOADING
    DiffMergeMethodInfo                     ,
#endif
    diffMerge                               ,


-- ** newIndexToWorkdir #method:newIndexToWorkdir#

    diffNewIndexToWorkdir                   ,


-- ** newTreeToIndex #method:newTreeToIndex#

    diffNewTreeToIndex                      ,


-- ** newTreeToTree #method:newTreeToTree#

    diffNewTreeToTree                       ,


-- ** newTreeToWorkdir #method:newTreeToWorkdir#

    diffNewTreeToWorkdir                    ,


-- ** print #method:print#

#if ENABLE_OVERLOADING
    DiffPrintMethodInfo                     ,
#endif
    diffPrint                               ,




 -- * Properties
-- ** repository #attr:repository#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    DiffRepositoryPropertyInfo              ,
#endif
    constructDiffRepository                 ,
#if ENABLE_OVERLOADING
    diffRepository                          ,
#endif
    getDiffRepository                       ,




    ) 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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Ggit.Callbacks as Ggit.Callbacks
import {-# SOURCE #-} qualified GI.Ggit.Enums as Ggit.Enums
import {-# SOURCE #-} qualified GI.Ggit.Objects.DiffFindOptions as Ggit.DiffFindOptions
import {-# SOURCE #-} qualified GI.Ggit.Objects.DiffFormatEmailOptions as Ggit.DiffFormatEmailOptions
import {-# SOURCE #-} qualified GI.Ggit.Objects.DiffOptions as Ggit.DiffOptions
import {-# SOURCE #-} qualified GI.Ggit.Objects.Index as Ggit.Index
import {-# SOURCE #-} qualified GI.Ggit.Objects.Native as Ggit.Native
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.Objects.Tree as Ggit.Tree
import {-# SOURCE #-} qualified GI.Ggit.Structs.DiffDelta as Ggit.DiffDelta

-- | Memory-managed wrapper type.
newtype Diff = Diff (ManagedPtr Diff)
foreign import ccall "ggit_diff_get_type"
    c_ggit_diff_get_type :: IO GType

instance GObject Diff where
    gobjectType = c_ggit_diff_get_type


-- | Type class for types which can be safely cast to `Diff`, for instance with `toDiff`.
class (GObject o, O.IsDescendantOf Diff o) => IsDiff o
instance (GObject o, O.IsDescendantOf Diff o) => IsDiff o

instance O.HasParentTypes Diff
type instance O.ParentTypes Diff = '[Ggit.Native.Native, Ggit.ObjectFactoryBase.ObjectFactoryBase, GObject.Object.Object]

-- | Cast to `Diff`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toDiff :: (MonadIO m, IsDiff o) => o -> m Diff
toDiff = liftIO . unsafeCastTo Diff

-- | A convenience alias for `Nothing` :: `Maybe` `Diff`.
noDiff :: Maybe Diff
noDiff = Nothing

#if ENABLE_OVERLOADING
type family ResolveDiffMethod (t :: Symbol) (o :: *) :: * where
    ResolveDiffMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveDiffMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveDiffMethod "findSimilar" o = DiffFindSimilarMethodInfo
    ResolveDiffMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveDiffMethod "foreach" o = DiffForeachMethodInfo
    ResolveDiffMethod "formatEmail" o = DiffFormatEmailMethodInfo
    ResolveDiffMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveDiffMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveDiffMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveDiffMethod "merge" o = DiffMergeMethodInfo
    ResolveDiffMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveDiffMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveDiffMethod "print" o = DiffPrintMethodInfo
    ResolveDiffMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveDiffMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveDiffMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveDiffMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveDiffMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveDiffMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveDiffMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveDiffMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveDiffMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveDiffMethod "getDelta" o = DiffGetDeltaMethodInfo
    ResolveDiffMethod "getNumDeltas" o = DiffGetNumDeltasMethodInfo
    ResolveDiffMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveDiffMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveDiffMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveDiffMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDiffMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDiffMethod t Diff, O.MethodInfo info Diff p) => OL.IsLabel t (Diff -> 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

-- VVV Prop "repository"
   -- Type: TInterface (Name {namespace = "Ggit", name = "Repository"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

{- |
Get the value of the “@repository@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' diff #repository
@
-}
getDiffRepository :: (MonadIO m, IsDiff o) => o -> m (Maybe Ggit.Repository.Repository)
getDiffRepository obj = liftIO $ B.Properties.getObjectPropertyObject obj "repository" Ggit.Repository.Repository

{- |
Construct a `GValueConstruct` with valid value for the “@repository@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructDiffRepository :: (IsDiff o, Ggit.Repository.IsRepository a) => a -> IO (GValueConstruct o)
constructDiffRepository val = B.Properties.constructObjectPropertyObject "repository" (Just val)

#if ENABLE_OVERLOADING
data DiffRepositoryPropertyInfo
instance AttrInfo DiffRepositoryPropertyInfo where
    type AttrAllowedOps DiffRepositoryPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DiffRepositoryPropertyInfo = Ggit.Repository.IsRepository
    type AttrBaseTypeConstraint DiffRepositoryPropertyInfo = IsDiff
    type AttrGetType DiffRepositoryPropertyInfo = (Maybe Ggit.Repository.Repository)
    type AttrLabel DiffRepositoryPropertyInfo = "repository"
    type AttrOrigin DiffRepositoryPropertyInfo = Diff
    attrGet _ = getDiffRepository
    attrSet _ = undefined
    attrConstruct _ = constructDiffRepository
    attrClear _ = undefined
#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList Diff
type instance O.AttributeList Diff = DiffAttributeList
type DiffAttributeList = ('[ '("native", Ggit.Native.NativeNativePropertyInfo), '("repository", DiffRepositoryPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
diffRepository :: AttrLabelProxy "repository"
diffRepository = AttrLabelProxy

#endif

#if ENABLE_OVERLOADING
type instance O.SignalList Diff = DiffSignalList
type DiffSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method Diff::new_index_to_workdir
-- method type : Constructor
-- Args : [Arg {argCName = "repository", argType = TInterface (Name {namespace = "Ggit", name = "Repository"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRepository.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "index", argType = TInterface (Name {namespace = "Ggit", name = "Index"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GgitIndex, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "diff_options", argType = TInterface (Name {namespace = "Ggit", name = "DiffOptions"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GgitDiffOptions, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "Diff"}))
-- throws : True
-- Skip return : False

foreign import ccall "ggit_diff_new_index_to_workdir" ggit_diff_new_index_to_workdir ::
    Ptr Ggit.Repository.Repository ->       -- repository : TInterface (Name {namespace = "Ggit", name = "Repository"})
    Ptr Ggit.Index.Index ->                 -- index : TInterface (Name {namespace = "Ggit", name = "Index"})
    Ptr Ggit.DiffOptions.DiffOptions ->     -- diff_options : TInterface (Name {namespace = "Ggit", name = "DiffOptions"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Diff)

{- |
Creates a 'GI.Ggit.Objects.Diff.Diff' which compares the working directory and the index.

If /@index@/ is 'Nothing' then /@repository@/ index is used.
If /@diffOptions@/ is 'Nothing' then the defaults specified in
'GI.Ggit.Objects.DiffOptions.diffOptionsNew' are used.
-}
diffNewIndexToWorkdir ::
    (B.CallStack.HasCallStack, MonadIO m, Ggit.Repository.IsRepository a, Ggit.Index.IsIndex b, Ggit.DiffOptions.IsDiffOptions c) =>
    a
    {- ^ /@repository@/: a 'GI.Ggit.Objects.Repository.Repository'. -}
    -> Maybe (b)
    {- ^ /@index@/: a 'GI.Ggit.Objects.Index.Index', or 'Nothing'. -}
    -> Maybe (c)
    {- ^ /@diffOptions@/: a 'GI.Ggit.Objects.DiffOptions.DiffOptions', or 'Nothing'. -}
    -> m (Maybe Diff)
    {- ^ __Returns:__ a newly allocated 'GI.Ggit.Objects.Diff.Diff' if
there was no error, 'Nothing' otherwise. /(Can throw 'Data.GI.Base.GError.GError')/ -}
diffNewIndexToWorkdir repository index diffOptions = liftIO $ do
    repository' <- unsafeManagedPtrCastPtr repository
    maybeIndex <- case index of
        Nothing -> return nullPtr
        Just jIndex -> do
            jIndex' <- unsafeManagedPtrCastPtr jIndex
            return jIndex'
    maybeDiffOptions <- case diffOptions of
        Nothing -> return nullPtr
        Just jDiffOptions -> do
            jDiffOptions' <- unsafeManagedPtrCastPtr jDiffOptions
            return jDiffOptions'
    onException (do
        result <- propagateGError $ ggit_diff_new_index_to_workdir repository' maybeIndex maybeDiffOptions
        maybeResult <- convertIfNonNull result $ \result' -> do
            result'' <- (wrapObject Diff) result'
            return result''
        touchManagedPtr repository
        whenJust index touchManagedPtr
        whenJust diffOptions touchManagedPtr
        return maybeResult
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
#endif

-- method Diff::new_tree_to_index
-- method type : Constructor
-- Args : [Arg {argCName = "repository", argType = TInterface (Name {namespace = "Ggit", name = "Repository"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRepository.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "old_tree", argType = TInterface (Name {namespace = "Ggit", name = "Tree"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GgitTree to diff from.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "index", argType = TInterface (Name {namespace = "Ggit", name = "Index"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GgitIndex, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "diff_options", argType = TInterface (Name {namespace = "Ggit", name = "DiffOptions"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GgitDiffOptions, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "Diff"}))
-- throws : True
-- Skip return : False

foreign import ccall "ggit_diff_new_tree_to_index" ggit_diff_new_tree_to_index ::
    Ptr Ggit.Repository.Repository ->       -- repository : TInterface (Name {namespace = "Ggit", name = "Repository"})
    Ptr Ggit.Tree.Tree ->                   -- old_tree : TInterface (Name {namespace = "Ggit", name = "Tree"})
    Ptr Ggit.Index.Index ->                 -- index : TInterface (Name {namespace = "Ggit", name = "Index"})
    Ptr Ggit.DiffOptions.DiffOptions ->     -- diff_options : TInterface (Name {namespace = "Ggit", name = "DiffOptions"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Diff)

{- |
Creates a 'GI.Ggit.Objects.Diff.Diff' which compares /@oldTree@/ and the index.

If /@index@/ is 'Nothing' then /@repository@/ index is used.
If /@diffOptions@/ is 'Nothing' then the defaults specified in
'GI.Ggit.Objects.DiffOptions.diffOptionsNew' are used.
-}
diffNewTreeToIndex ::
    (B.CallStack.HasCallStack, MonadIO m, Ggit.Repository.IsRepository a, Ggit.Tree.IsTree b, Ggit.Index.IsIndex c, Ggit.DiffOptions.IsDiffOptions d) =>
    a
    {- ^ /@repository@/: a 'GI.Ggit.Objects.Repository.Repository'. -}
    -> Maybe (b)
    {- ^ /@oldTree@/: a 'GI.Ggit.Objects.Tree.Tree' to diff from. -}
    -> Maybe (c)
    {- ^ /@index@/: a 'GI.Ggit.Objects.Index.Index', or 'Nothing'. -}
    -> Maybe (d)
    {- ^ /@diffOptions@/: a 'GI.Ggit.Objects.DiffOptions.DiffOptions', or 'Nothing'. -}
    -> m (Maybe Diff)
    {- ^ __Returns:__ a newly allocated 'GI.Ggit.Objects.Diff.Diff' if
there was no error, 'Nothing' otherwise. /(Can throw 'Data.GI.Base.GError.GError')/ -}
diffNewTreeToIndex repository oldTree index diffOptions = liftIO $ do
    repository' <- unsafeManagedPtrCastPtr repository
    maybeOldTree <- case oldTree of
        Nothing -> return nullPtr
        Just jOldTree -> do
            jOldTree' <- unsafeManagedPtrCastPtr jOldTree
            return jOldTree'
    maybeIndex <- case index of
        Nothing -> return nullPtr
        Just jIndex -> do
            jIndex' <- unsafeManagedPtrCastPtr jIndex
            return jIndex'
    maybeDiffOptions <- case diffOptions of
        Nothing -> return nullPtr
        Just jDiffOptions -> do
            jDiffOptions' <- unsafeManagedPtrCastPtr jDiffOptions
            return jDiffOptions'
    onException (do
        result <- propagateGError $ ggit_diff_new_tree_to_index repository' maybeOldTree maybeIndex maybeDiffOptions
        maybeResult <- convertIfNonNull result $ \result' -> do
            result'' <- (wrapObject Diff) result'
            return result''
        touchManagedPtr repository
        whenJust oldTree touchManagedPtr
        whenJust index touchManagedPtr
        whenJust diffOptions touchManagedPtr
        return maybeResult
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
#endif

-- method Diff::new_tree_to_tree
-- method type : Constructor
-- Args : [Arg {argCName = "repository", argType = TInterface (Name {namespace = "Ggit", name = "Repository"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRepository.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "old_tree", argType = TInterface (Name {namespace = "Ggit", name = "Tree"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GgitTree to diff from.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "new_tree", argType = TInterface (Name {namespace = "Ggit", name = "Tree"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GgitTree to diff to.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "diff_options", argType = TInterface (Name {namespace = "Ggit", name = "DiffOptions"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GgitDiffOptions, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "Diff"}))
-- throws : True
-- Skip return : False

foreign import ccall "ggit_diff_new_tree_to_tree" ggit_diff_new_tree_to_tree ::
    Ptr Ggit.Repository.Repository ->       -- repository : TInterface (Name {namespace = "Ggit", name = "Repository"})
    Ptr Ggit.Tree.Tree ->                   -- old_tree : TInterface (Name {namespace = "Ggit", name = "Tree"})
    Ptr Ggit.Tree.Tree ->                   -- new_tree : TInterface (Name {namespace = "Ggit", name = "Tree"})
    Ptr Ggit.DiffOptions.DiffOptions ->     -- diff_options : TInterface (Name {namespace = "Ggit", name = "DiffOptions"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Diff)

{- |
Creates a 'GI.Ggit.Objects.Diff.Diff' which compares /@oldTree@/ and /@newTree@/.

If /@diffOptions@/ is 'Nothing' then the defaults specified in
'GI.Ggit.Objects.DiffOptions.diffOptionsNew' are used.
-}
diffNewTreeToTree ::
    (B.CallStack.HasCallStack, MonadIO m, Ggit.Repository.IsRepository a, Ggit.Tree.IsTree b, Ggit.Tree.IsTree c, Ggit.DiffOptions.IsDiffOptions d) =>
    a
    {- ^ /@repository@/: a 'GI.Ggit.Objects.Repository.Repository'. -}
    -> Maybe (b)
    {- ^ /@oldTree@/: a 'GI.Ggit.Objects.Tree.Tree' to diff from. -}
    -> Maybe (c)
    {- ^ /@newTree@/: a 'GI.Ggit.Objects.Tree.Tree' to diff to. -}
    -> Maybe (d)
    {- ^ /@diffOptions@/: a 'GI.Ggit.Objects.DiffOptions.DiffOptions', or 'Nothing'. -}
    -> m (Maybe Diff)
    {- ^ __Returns:__ a newly allocated 'GI.Ggit.Objects.Diff.Diff' if
there was no error, 'Nothing' otherwise. /(Can throw 'Data.GI.Base.GError.GError')/ -}
diffNewTreeToTree repository oldTree newTree diffOptions = liftIO $ do
    repository' <- unsafeManagedPtrCastPtr repository
    maybeOldTree <- case oldTree of
        Nothing -> return nullPtr
        Just jOldTree -> do
            jOldTree' <- unsafeManagedPtrCastPtr jOldTree
            return jOldTree'
    maybeNewTree <- case newTree of
        Nothing -> return nullPtr
        Just jNewTree -> do
            jNewTree' <- unsafeManagedPtrCastPtr jNewTree
            return jNewTree'
    maybeDiffOptions <- case diffOptions of
        Nothing -> return nullPtr
        Just jDiffOptions -> do
            jDiffOptions' <- unsafeManagedPtrCastPtr jDiffOptions
            return jDiffOptions'
    onException (do
        result <- propagateGError $ ggit_diff_new_tree_to_tree repository' maybeOldTree maybeNewTree maybeDiffOptions
        maybeResult <- convertIfNonNull result $ \result' -> do
            result'' <- (wrapObject Diff) result'
            return result''
        touchManagedPtr repository
        whenJust oldTree touchManagedPtr
        whenJust newTree touchManagedPtr
        whenJust diffOptions touchManagedPtr
        return maybeResult
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
#endif

-- method Diff::new_tree_to_workdir
-- method type : Constructor
-- Args : [Arg {argCName = "repository", argType = TInterface (Name {namespace = "Ggit", name = "Repository"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRepository.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "old_tree", argType = TInterface (Name {namespace = "Ggit", name = "Tree"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GgitTree to diff from.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "diff_options", argType = TInterface (Name {namespace = "Ggit", name = "DiffOptions"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GgitDiffOptions, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "Diff"}))
-- throws : True
-- Skip return : False

foreign import ccall "ggit_diff_new_tree_to_workdir" ggit_diff_new_tree_to_workdir ::
    Ptr Ggit.Repository.Repository ->       -- repository : TInterface (Name {namespace = "Ggit", name = "Repository"})
    Ptr Ggit.Tree.Tree ->                   -- old_tree : TInterface (Name {namespace = "Ggit", name = "Tree"})
    Ptr Ggit.DiffOptions.DiffOptions ->     -- diff_options : TInterface (Name {namespace = "Ggit", name = "DiffOptions"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Diff)

{- |
Creates a 'GI.Ggit.Objects.Diff.Diff' which compares the working directory and /@oldTree@/.

If /@diffOptions@/ is 'Nothing' then the defaults specified in
'GI.Ggit.Objects.DiffOptions.diffOptionsNew' are used.
-}
diffNewTreeToWorkdir ::
    (B.CallStack.HasCallStack, MonadIO m, Ggit.Repository.IsRepository a, Ggit.Tree.IsTree b, Ggit.DiffOptions.IsDiffOptions c) =>
    a
    {- ^ /@repository@/: a 'GI.Ggit.Objects.Repository.Repository'. -}
    -> Maybe (b)
    {- ^ /@oldTree@/: a 'GI.Ggit.Objects.Tree.Tree' to diff from. -}
    -> Maybe (c)
    {- ^ /@diffOptions@/: a 'GI.Ggit.Objects.DiffOptions.DiffOptions', or 'Nothing'. -}
    -> m (Maybe Diff)
    {- ^ __Returns:__ a newly allocated 'GI.Ggit.Objects.Diff.Diff' if
there was no error, 'Nothing' otherwise. /(Can throw 'Data.GI.Base.GError.GError')/ -}
diffNewTreeToWorkdir repository oldTree diffOptions = liftIO $ do
    repository' <- unsafeManagedPtrCastPtr repository
    maybeOldTree <- case oldTree of
        Nothing -> return nullPtr
        Just jOldTree -> do
            jOldTree' <- unsafeManagedPtrCastPtr jOldTree
            return jOldTree'
    maybeDiffOptions <- case diffOptions of
        Nothing -> return nullPtr
        Just jDiffOptions -> do
            jDiffOptions' <- unsafeManagedPtrCastPtr jDiffOptions
            return jDiffOptions'
    onException (do
        result <- propagateGError $ ggit_diff_new_tree_to_workdir repository' maybeOldTree maybeDiffOptions
        maybeResult <- convertIfNonNull result $ \result' -> do
            result'' <- (wrapObject Diff) result'
            return result''
        touchManagedPtr repository
        whenJust oldTree touchManagedPtr
        whenJust diffOptions touchManagedPtr
        return maybeResult
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
#endif

-- method Diff::find_similar
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "diff", argType = TInterface (Name {namespace = "Ggit", name = "Diff"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiff.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "options", argType = TInterface (Name {namespace = "Ggit", name = "DiffFindOptions"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GgitDiffFindOptions or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ggit_diff_find_similar" ggit_diff_find_similar ::
    Ptr Diff ->                             -- diff : TInterface (Name {namespace = "Ggit", name = "Diff"})
    Ptr Ggit.DiffFindOptions.DiffFindOptions -> -- options : TInterface (Name {namespace = "Ggit", name = "DiffFindOptions"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Transform /@diff@/ marking file renames, copies, etc.. If /@options@/ is set to
'Nothing', then the default options will be used.
-}
diffFindSimilar ::
    (B.CallStack.HasCallStack, MonadIO m, IsDiff a, Ggit.DiffFindOptions.IsDiffFindOptions b) =>
    a
    {- ^ /@diff@/: a 'GI.Ggit.Objects.Diff.Diff'. -}
    -> Maybe (b)
    {- ^ /@options@/: a 'GI.Ggit.Objects.DiffFindOptions.DiffFindOptions' or 'Nothing'. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
diffFindSimilar diff options = liftIO $ do
    diff' <- unsafeManagedPtrCastPtr diff
    maybeOptions <- case options of
        Nothing -> return nullPtr
        Just jOptions -> do
            jOptions' <- unsafeManagedPtrCastPtr jOptions
            return jOptions'
    onException (do
        _ <- propagateGError $ ggit_diff_find_similar diff' maybeOptions
        touchManagedPtr diff
        whenJust options touchManagedPtr
        return ()
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data DiffFindSimilarMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsDiff a, Ggit.DiffFindOptions.IsDiffFindOptions b) => O.MethodInfo DiffFindSimilarMethodInfo a signature where
    overloadedMethod _ = diffFindSimilar

#endif

-- XXX Could not generate method Diff::foreach
-- Error was : Not implemented: "Closure for multiple callbacks unsupportedArg\n  { argCName = \"binary_cb\"\n  , argType =\n      TInterface\n        Name { namespace = \"Ggit\" , name = \"DiffBinaryCallback\" }\n  , direction = DirectionIn\n  , mayBeNull = True\n  , argDoc =\n      Documentation\n        { rawDocText = Just \"\\n a #GgitDiffBinaryCallback.\"\n        , sinceVersion = Nothing\n        }\n  , argScope = ScopeTypeCall\n  , argClosure = 5\n  , argDestroy = -1\n  , argCallerAllocates = False\n  , transfer = TransferNothing\n  }\nCallable\n  { returnType = Nothing\n  , returnMayBeNull = False\n  , returnTransfer = TransferNothing\n  , returnDocumentation =\n      Documentation { rawDocText = Nothing , sinceVersion = Nothing }\n  , args =\n      [ Arg\n          { argCName = \"diff\"\n          , argType = TInterface Name { namespace = \"Ggit\" , name = \"Diff\" }\n          , direction = DirectionIn\n          , mayBeNull = False\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"a #GgitDiff.\" , sinceVersion = Nothing }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"file_cb\"\n          , argType =\n              TInterface Name { namespace = \"Ggit\" , name = \"DiffFileCallback\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"\\n a #GgitDiffFileCallback.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeCall\n          , argClosure = 5\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"binary_cb\"\n          , argType =\n              TInterface\n                Name { namespace = \"Ggit\" , name = \"DiffBinaryCallback\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"\\n a #GgitDiffBinaryCallback.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeCall\n          , argClosure = 5\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"hunk_cb\"\n          , argType =\n              TInterface Name { namespace = \"Ggit\" , name = \"DiffHunkCallback\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"\\n a #GgitDiffHunkCallback.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeCall\n          , argClosure = 5\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"line_cb\"\n          , argType =\n              TInterface Name { namespace = \"Ggit\" , name = \"DiffLineCallback\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"\\n a #GgitDiffLineCallback.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeCall\n          , argClosure = 5\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"user_data\"\n          , argType = TBasicType TPtr\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"callback user data.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      ]\n  , skipReturn = False\n  , callableThrows = True\n  , callableDeprecated = Nothing\n  , callableDocumentation =\n      Documentation\n        { rawDocText =\n            Just\n              \"Iterates over the diff calling @file_cb, @binary_cb, @hunk_cb and @line_cb.\"\n        , sinceVersion = Nothing\n        }\n  }"
#if ENABLE_OVERLOADING
-- XXX: Dummy instance, since code generation failed.
-- Please file a bug at http://github.com/haskell-gi/haskell-gi.
data DiffForeachMethodInfo
instance (p ~ (), o ~ O.MethodResolutionFailed "foreach" Diff) => O.MethodInfo DiffForeachMethodInfo o p where
    overloadedMethod _ = undefined
#endif

-- method Diff::format_email
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "diff", argType = TInterface (Name {namespace = "Ggit", name = "Diff"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiff.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "options", argType = TInterface (Name {namespace = "Ggit", name = "DiffFormatEmailOptions"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffFormatEmailOptions.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "ggit_diff_format_email" ggit_diff_format_email ::
    Ptr Diff ->                             -- diff : TInterface (Name {namespace = "Ggit", name = "Diff"})
    Ptr Ggit.DiffFormatEmailOptions.DiffFormatEmailOptions -> -- options : TInterface (Name {namespace = "Ggit", name = "DiffFormatEmailOptions"})
    Ptr (Ptr GError) ->                     -- error
    IO CString

{- |
Create an e-mail ready patch from a diff.
-}
diffFormatEmail ::
    (B.CallStack.HasCallStack, MonadIO m, IsDiff a, Ggit.DiffFormatEmailOptions.IsDiffFormatEmailOptions b) =>
    a
    {- ^ /@diff@/: a 'GI.Ggit.Objects.Diff.Diff'. -}
    -> b
    {- ^ /@options@/: a 'GI.Ggit.Objects.DiffFormatEmailOptions.DiffFormatEmailOptions'. -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ the patch or 'Nothing' if an error occurred. /(Can throw 'Data.GI.Base.GError.GError')/ -}
diffFormatEmail diff options = liftIO $ do
    diff' <- unsafeManagedPtrCastPtr diff
    options' <- unsafeManagedPtrCastPtr options
    onException (do
        result <- propagateGError $ ggit_diff_format_email diff' options'
        maybeResult <- convertIfNonNull result $ \result' -> do
            result'' <- cstringToText result'
            freeMem result'
            return result''
        touchManagedPtr diff
        touchManagedPtr options
        return maybeResult
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data DiffFormatEmailMethodInfo
instance (signature ~ (b -> m (Maybe T.Text)), MonadIO m, IsDiff a, Ggit.DiffFormatEmailOptions.IsDiffFormatEmailOptions b) => O.MethodInfo DiffFormatEmailMethodInfo a signature where
    overloadedMethod _ = diffFormatEmail

#endif

-- method Diff::get_delta
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "diff", argType = TInterface (Name {namespace = "Ggit", name = "Diff"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiff.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "index", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the index.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "DiffDelta"}))
-- throws : False
-- Skip return : False

foreign import ccall "ggit_diff_get_delta" ggit_diff_get_delta ::
    Ptr Diff ->                             -- diff : TInterface (Name {namespace = "Ggit", name = "Diff"})
    Word64 ->                               -- index : TBasicType TUInt64
    IO (Ptr Ggit.DiffDelta.DiffDelta)

{- |
Get the delta at the specified index.
-}
diffGetDelta ::
    (B.CallStack.HasCallStack, MonadIO m, IsDiff a) =>
    a
    {- ^ /@diff@/: a 'GI.Ggit.Objects.Diff.Diff'. -}
    -> Word64
    {- ^ /@index@/: the index. -}
    -> m (Maybe Ggit.DiffDelta.DiffDelta)
    {- ^ __Returns:__ a 'GI.Ggit.Structs.DiffDelta.DiffDelta' or 'Nothing'. -}
diffGetDelta diff index = liftIO $ do
    diff' <- unsafeManagedPtrCastPtr diff
    result <- ggit_diff_get_delta diff' index
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Ggit.DiffDelta.DiffDelta) result'
        return result''
    touchManagedPtr diff
    return maybeResult

#if ENABLE_OVERLOADING
data DiffGetDeltaMethodInfo
instance (signature ~ (Word64 -> m (Maybe Ggit.DiffDelta.DiffDelta)), MonadIO m, IsDiff a) => O.MethodInfo DiffGetDeltaMethodInfo a signature where
    overloadedMethod _ = diffGetDelta

#endif

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

foreign import ccall "ggit_diff_get_num_deltas" ggit_diff_get_num_deltas ::
    Ptr Diff ->                             -- diff : TInterface (Name {namespace = "Ggit", name = "Diff"})
    IO Word64

{- |
Get the number of deltas in the diff.
-}
diffGetNumDeltas ::
    (B.CallStack.HasCallStack, MonadIO m, IsDiff a) =>
    a
    {- ^ /@diff@/: a 'GI.Ggit.Objects.Diff.Diff'. -}
    -> m Word64
    {- ^ __Returns:__ the number of deltas. -}
diffGetNumDeltas diff = liftIO $ do
    diff' <- unsafeManagedPtrCastPtr diff
    result <- ggit_diff_get_num_deltas diff'
    touchManagedPtr diff
    return result

#if ENABLE_OVERLOADING
data DiffGetNumDeltasMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsDiff a) => O.MethodInfo DiffGetNumDeltasMethodInfo a signature where
    overloadedMethod _ = diffGetNumDeltas

#endif

-- method Diff::merge
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "onto", argType = TInterface (Name {namespace = "Ggit", name = "Diff"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GgitDiff to merge into.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "from", argType = TInterface (Name {namespace = "Ggit", name = "Diff"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GgitDiff to merge.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ggit_diff_merge" ggit_diff_merge ::
    Ptr Diff ->                             -- onto : TInterface (Name {namespace = "Ggit", name = "Diff"})
    Ptr Diff ->                             -- from : TInterface (Name {namespace = "Ggit", name = "Diff"})
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
Merges /@from@/ into /@onto@/ unless /@error@/ is set.
-}
diffMerge ::
    (B.CallStack.HasCallStack, MonadIO m, IsDiff a, IsDiff b) =>
    a
    {- ^ /@onto@/: the 'GI.Ggit.Objects.Diff.Diff' to merge into. -}
    -> b
    {- ^ /@from@/: the 'GI.Ggit.Objects.Diff.Diff' to merge. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
diffMerge onto from = liftIO $ do
    onto' <- unsafeManagedPtrCastPtr onto
    from' <- unsafeManagedPtrCastPtr from
    onException (do
        propagateGError $ ggit_diff_merge onto' from'
        touchManagedPtr onto
        touchManagedPtr from
        return ()
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data DiffMergeMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsDiff a, IsDiff b) => O.MethodInfo DiffMergeMethodInfo a signature where
    overloadedMethod _ = diffMerge

#endif

-- method Diff::print
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "diff", argType = TInterface (Name {namespace = "Ggit", name = "Diff"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiff.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "type", argType = TInterface (Name {namespace = "Ggit", name = "DiffFormatType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffFormatType.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "print_cb", argType = TInterface (Name {namespace = "Ggit", name = "DiffLineCallback"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffLineCallback.", sinceVersion = Nothing}, argScope = ScopeTypeCall, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "callback user data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ggit_diff_print" ggit_diff_print ::
    Ptr Diff ->                             -- diff : TInterface (Name {namespace = "Ggit", name = "Diff"})
    CUInt ->                                -- type : TInterface (Name {namespace = "Ggit", name = "DiffFormatType"})
    FunPtr Ggit.Callbacks.C_DiffLineCallback -> -- print_cb : TInterface (Name {namespace = "Ggit", name = "DiffLineCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
Iterates over /@diff@/ generating text output like \"git diff\".
-}
diffPrint ::
    (B.CallStack.HasCallStack, MonadIO m, IsDiff a) =>
    a
    {- ^ /@diff@/: a 'GI.Ggit.Objects.Diff.Diff'. -}
    -> Ggit.Enums.DiffFormatType
    {- ^ /@type@/: a 'GI.Ggit.Enums.DiffFormatType'. -}
    -> Ggit.Callbacks.DiffLineCallback
    {- ^ /@printCb@/: a 'GI.Ggit.Callbacks.DiffLineCallback'. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
diffPrint diff type_ printCb = liftIO $ do
    diff' <- unsafeManagedPtrCastPtr diff
    let type_' = (fromIntegral . fromEnum) type_
    printCb' <- Ggit.Callbacks.mk_DiffLineCallback (Ggit.Callbacks.wrap_DiffLineCallback Nothing (Ggit.Callbacks.drop_closures_DiffLineCallback printCb))
    let userData = nullPtr
    onException (do
        propagateGError $ ggit_diff_print diff' type_' printCb' userData
        safeFreeFunPtr $ castFunPtrToPtr printCb'
        touchManagedPtr diff
        return ()
     ) (do
        safeFreeFunPtr $ castFunPtrToPtr printCb'
        return ()
     )

#if ENABLE_OVERLOADING
data DiffPrintMethodInfo
instance (signature ~ (Ggit.Enums.DiffFormatType -> Ggit.Callbacks.DiffLineCallback -> m ()), MonadIO m, IsDiff a) => O.MethodInfo DiffPrintMethodInfo a signature where
    overloadedMethod _ = diffPrint

#endif

-- XXX Could not generate method Diff::blob_to_buffer
-- Error was : Not implemented: "Closure for multiple callbacks unsupportedArg\n  { argCName = \"binary_cb\"\n  , argType =\n      TInterface\n        Name { namespace = \"Ggit\" , name = \"DiffBinaryCallback\" }\n  , direction = DirectionIn\n  , mayBeNull = True\n  , argDoc =\n      Documentation\n        { rawDocText = Just \"\\n a #GgitDiffBinaryCallback.\"\n        , sinceVersion = Nothing\n        }\n  , argScope = ScopeTypeCall\n  , argClosure = 10\n  , argDestroy = -1\n  , argCallerAllocates = False\n  , transfer = TransferNothing\n  }\nCallable\n  { returnType = Nothing\n  , returnMayBeNull = False\n  , returnTransfer = TransferNothing\n  , returnDocumentation =\n      Documentation { rawDocText = Nothing , sinceVersion = Nothing }\n  , args =\n      [ Arg\n          { argCName = \"old_blob\"\n          , argType = TInterface Name { namespace = \"Ggit\" , name = \"Blob\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"a #GgitBlob to diff from.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"old_as_path\"\n          , argType = TBasicType TUTF8\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText =\n                    Just \"treat @old_blob as if it had this filename, or %NULL,\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"buffer\"\n          , argType = TCArray False (-1) 3 (TBasicType TUInt8)\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"a buffer to diff to.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"buffer_len\"\n          , argType = TBasicType TInt64\n          , direction = DirectionIn\n          , mayBeNull = False\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"length of @buffer.\" , sinceVersion = Nothing }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"buffer_as_path\"\n          , argType = TBasicType TUTF8\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText =\n                    Just \"treat @buffer as if it had this filename, or %NULL,\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"diff_options\"\n          , argType =\n              TInterface Name { namespace = \"Ggit\" , name = \"DiffOptions\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"a #GgitDiffOptions, or %NULL.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"file_cb\"\n          , argType =\n              TInterface Name { namespace = \"Ggit\" , name = \"DiffFileCallback\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"\\n a #GgitDiffFileCallback.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeCall\n          , argClosure = 10\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"binary_cb\"\n          , argType =\n              TInterface\n                Name { namespace = \"Ggit\" , name = \"DiffBinaryCallback\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"\\n a #GgitDiffBinaryCallback.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeCall\n          , argClosure = 10\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"hunk_cb\"\n          , argType =\n              TInterface Name { namespace = \"Ggit\" , name = \"DiffHunkCallback\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"\\n a #GgitDiffHunkCallback.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeCall\n          , argClosure = 10\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"line_cb\"\n          , argType =\n              TInterface Name { namespace = \"Ggit\" , name = \"DiffLineCallback\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"\\n a #GgitDiffLineCallback.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeCall\n          , argClosure = 10\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"user_data\"\n          , argType = TBasicType TPtr\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"callback user data.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      ]\n  , skipReturn = False\n  , callableThrows = True\n  , callableDeprecated = Nothing\n  , callableDocumentation =\n      Documentation\n        { rawDocText = Just \"Same as ggit_diff_blobs() but using a buffer.\"\n        , sinceVersion = Nothing\n        }\n  }"
#if ENABLE_OVERLOADING
-- XXX: Dummy instance, since code generation failed.
-- Please file a bug at http://github.com/haskell-gi/haskell-gi.
data DiffBlobToBufferMethodInfo
instance (p ~ (), o ~ O.MethodResolutionFailed "blobToBuffer" Diff) => O.MethodInfo DiffBlobToBufferMethodInfo o p where
    overloadedMethod _ = undefined
#endif

-- XXX Could not generate method Diff::blobs
-- Error was : Not implemented: "Closure for multiple callbacks unsupportedArg\n  { argCName = \"binary_cb\"\n  , argType =\n      TInterface\n        Name { namespace = \"Ggit\" , name = \"DiffBinaryCallback\" }\n  , direction = DirectionIn\n  , mayBeNull = True\n  , argDoc =\n      Documentation\n        { rawDocText = Just \"\\n a #GgitDiffBinaryCallback.\"\n        , sinceVersion = Nothing\n        }\n  , argScope = ScopeTypeCall\n  , argClosure = 9\n  , argDestroy = -1\n  , argCallerAllocates = False\n  , transfer = TransferNothing\n  }\nCallable\n  { returnType = Nothing\n  , returnMayBeNull = False\n  , returnTransfer = TransferNothing\n  , returnDocumentation =\n      Documentation { rawDocText = Nothing , sinceVersion = Nothing }\n  , args =\n      [ Arg\n          { argCName = \"old_blob\"\n          , argType = TInterface Name { namespace = \"Ggit\" , name = \"Blob\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"a #GgitBlob to diff from.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"old_as_path\"\n          , argType = TBasicType TUTF8\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText =\n                    Just \"treat @old_blob as if it had this filename, or %NULL,\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"new_blob\"\n          , argType = TInterface Name { namespace = \"Ggit\" , name = \"Blob\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"a #GgitBlob to diff to.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"new_as_path\"\n          , argType = TBasicType TUTF8\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText =\n                    Just \"treat @new_blob as if it had this filename, or %NULL,\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"diff_options\"\n          , argType =\n              TInterface Name { namespace = \"Ggit\" , name = \"DiffOptions\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"a #GgitDiffOptions, or %NULL.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"file_cb\"\n          , argType =\n              TInterface Name { namespace = \"Ggit\" , name = \"DiffFileCallback\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"\\n a #GgitDiffFileCallback.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeCall\n          , argClosure = 9\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"binary_cb\"\n          , argType =\n              TInterface\n                Name { namespace = \"Ggit\" , name = \"DiffBinaryCallback\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"\\n a #GgitDiffBinaryCallback.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeCall\n          , argClosure = 9\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"hunk_cb\"\n          , argType =\n              TInterface Name { namespace = \"Ggit\" , name = \"DiffHunkCallback\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"\\n a #GgitDiffHunkCallback.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeCall\n          , argClosure = 9\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"line_cb\"\n          , argType =\n              TInterface Name { namespace = \"Ggit\" , name = \"DiffLineCallback\" }\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"\\n a #GgitDiffLineCallback.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeCall\n          , argClosure = 9\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      , Arg\n          { argCName = \"user_data\"\n          , argType = TBasicType TPtr\n          , direction = DirectionIn\n          , mayBeNull = True\n          , argDoc =\n              Documentation\n                { rawDocText = Just \"callback user data.\"\n                , sinceVersion = Nothing\n                }\n          , argScope = ScopeTypeInvalid\n          , argClosure = -1\n          , argDestroy = -1\n          , argCallerAllocates = False\n          , transfer = TransferNothing\n          }\n      ]\n  , skipReturn = False\n  , callableThrows = True\n  , callableDeprecated = Nothing\n  , callableDocumentation =\n      Documentation\n        { rawDocText =\n            Just\n              \"Iterates over the diff calling @file_cb, @binary_cb, @hunk_cb and @line_cb.\\n\\nThe #GgitDiffFile mode always be 0, path will be %NULL and when a blob is\\n%NULL the oid will be 0.\\n\\nIf @diff_options is %NULL then the defaults specified in\\nggit_diff_options_new() are used.\"\n        , sinceVersion = Nothing\n        }\n  }"
#if ENABLE_OVERLOADING
-- XXX: Dummy instance, since code generation failed.
-- Please file a bug at http://github.com/haskell-gi/haskell-gi.
data DiffBlobsMethodInfo
instance (p ~ (), o ~ O.MethodResolutionFailed "blobs" Diff) => O.MethodInfo DiffBlobsMethodInfo o p where
    overloadedMethod _ = undefined
#endif