## GgitDiff GgitDiff |

## Functions

gint | (*GgitDiffFileCallback) ()
gint | (*GgitDiffHunkCallback) ()
gint | (*GgitDiffLineCallback) ()
GgitDiff * | ggit_diff_new_tree_to_tree ()
GgitDiff * | ggit_diff_new_tree_to_index ()
GgitDiff * | ggit_diff_new_index_to_workdir ()
GgitDiff * | ggit_diff_new_tree_to_workdir ()
void | ggit_diff_merge ()
void | ggit_diff_foreach ()
void | ggit_diff_print ()
void | ggit_diff_blobs ()
void | ggit_diff_blob_to_buffer ()

## Properties

GgitRepository * | repository | Read / Write / Construct Only

## Types and Values

| GgitDiff
struct | GgitDiffClass
enum | GgitDiffFlag
enum | GgitDiffLineType
enum | GgitDiffFormatType
enum | GgitDiffOption

## Object Hierarchy

        GEnum
        ├── GgitDiffFormatType
        ╰── GgitDiffLineType
        GFlags
        ├── GgitDiffFlag
        ╰── GgitDiffOption
        GObject
        ╰── GgitObjectFactoryBase
            ╰── GgitNative
                ╰── GgitDiff

## Description

## Functions

### GgitDiffFileCallback ()

    gint
    (*GgitDiffFileCallback) (GgitDiffDelta *delta,
                             gfloat progress,
                             gpointer user_data);

Called for each file.

#### Parameters

delta | a GgitDiffDelta. |
progress | the progress. |
user_data | user-supplied data. | [closure]

#### Returns

0 to go continue or a GgitError in case there was an error.

### GgitDiffHunkCallback ()

    gint
    (*GgitDiffHunkCallback) (GgitDiffDelta *delta,
                             GgitDiffHunk *hunk,
                             gpointer user_data);

Called for each hunk.

#### Parameters

delta | a GgitDiffDelta. |
hunk | a GgitDiffHunk. |
user_data | user-supplied data. | [closure]

#### Returns

0 to go continue or a GgitError in case there was an error.

### GgitDiffLineCallback ()

    gint
    (*GgitDiffLineCallback) (GgitDiffDelta *delta,
                             GgitDiffHunk *hunk,
                             GgitDiffLine *line,
                             gpointer user_data);

Called for each line.

#### Parameters

delta | a GgitDiffDelta. |
hunk | a GgitDiffHunk. |
line | a GgitDiffLine. |
user_data | user-supplied data. | [closure]

#### Returns

0 to go continue or a GgitError in case there was an error.

### ggit_diff_new_tree_to_tree ()

    GgitDiff *
    ggit_diff_new_tree_to_tree (GgitRepository *repository,
                                GgitTree *old_tree,
                                GgitTree *new_tree,
                                GgitDiffOptions *diff_options,
                                GError **error);

Creates a GgitDiff which compares `old_tree` and `new_tree` .

If `diff_options` is `NULL` then the defaults specified in `ggit_diff_options_new()` are used.

#### Parameters

repository | a GgitRepository. |
old_tree | a GgitTree to diff from. | [allow-none]
new_tree | a GgitTree to diff to. | [allow-none]
diff_options | a GgitDiffOptions, or `NULL`. | [allow-none]
error | a GError for error reporting, or `NULL`. |

#### Returns

a newly allocated GgitDiff if there was no error, `NULL` otherwise.

[transfer full][nullable]

### ggit_diff_new_tree_to_index ()

    GgitDiff *
    ggit_diff_new_tree_to_index (GgitRepository *repository,
                                 GgitTree *old_tree,
                                 GgitIndex *index,
                                 GgitDiffOptions *diff_options,
                                 GError **error);

Creates a GgitDiff which compares `old_tree` and the index.

If `index` is `NULL` then `repository` index is used. If `diff_options` is `NULL` then the defaults specified in `ggit_diff_options_new()` are used.

#### Parameters

repository | a GgitRepository. |
old_tree | a GgitTree to diff from. | [allow-none]
index | a GgitIndex, or `NULL`. | [allow-none]
diff_options | a GgitDiffOptions, or `NULL`. | [allow-none]
error | a GError for error reporting, or `NULL`. |

#### Returns

a newly allocated GgitDiff if there was no error, `NULL` otherwise.

[transfer full][nullable]

### ggit_diff_new_index_to_workdir ()

    GgitDiff *
    ggit_diff_new_index_to_workdir (GgitRepository *repository,
                                    GgitIndex *index,
                                    GgitDiffOptions *diff_options,
                                    GError **error);

Creates a GgitDiff which compares the working directory and the index.

If `index` is `NULL` then `repository` index is used. If `diff_options` is `NULL` then the defaults specified in `ggit_diff_options_new()` are used.

#### Parameters

repository | a GgitRepository. |
index | a GgitIndex, or `NULL`. | [allow-none]
diff_options | a GgitDiffOptions, or `NULL`. | [allow-none]
error | a GError for error reporting, or `NULL`. |

#### Returns

a newly allocated GgitDiff if there was no error, `NULL` otherwise.

[transfer full][nullable]

### ggit_diff_new_tree_to_workdir ()

    GgitDiff *
    ggit_diff_new_tree_to_workdir (GgitRepository *repository,
                                   GgitTree *old_tree,
                                   GgitDiffOptions *diff_options,
                                   GError **error);

Creates a GgitDiff which compares the working directory and `old_tree` .

If `diff_options` is `NULL` then the defaults specified in `ggit_diff_options_new()` are used.

#### Parameters

repository | a GgitRepository. |
old_tree | a GgitTree to diff from. | [allow-none]
diff_options | a GgitDiffOptions, or `NULL`. | [allow-none]
error | a GError for error reporting, or `NULL`. |

#### Returns

a newly allocated GgitDiff if there was no error, `NULL` otherwise.

[transfer full][nullable]

### ggit_diff_merge ()

    void
    ggit_diff_merge (GgitDiff *onto,
                     GgitDiff *from,
                     GError **error);

Merges `from` into `onto` unless `error` is set.

#### Parameters

onto | the GgitDiff to merge into. |
from | the GgitDiff to merge. |
error | a GError for error reporting, or `NULL`. |

### ggit_diff_foreach ()

    void
    ggit_diff_foreach (GgitDiff *diff,
                       GgitDiffFileCallback file_cb,
                       GgitDiffBinaryCallback binary_cb,
                       GgitDiffHunkCallback hunk_cb,
                       GgitDiffLineCallback line_cb,
                       gpointer *user_data,
                       GError **error);

Iterates over the diff calling `file_cb` , `binary_cb` , `hunk_cb` and `line_cb` .

#### Parameters

diff | a GgitDiff. |
file_cb | a GgitDiffFileCallback. | [allow-none][scope call][closure user_data]
binary_cb | a GgitDiffBinaryCallback. | [allow-none][scope call][closure user_data]
hunk_cb | a GgitDiffHunkCallback. | [allow-none][scope call][closure user_data]
line_cb | a GgitDiffLineCallback. | [allow-none][scope call][closure user_data]
user_data | callback user data. |
error | a GError for error reporting, or `NULL`. |

### ggit_diff_print ()

    void
    ggit_diff_print (GgitDiff *diff,
                     GgitDiffFormatType type,
                     GgitDiffLineCallback print_cb,
                     gpointer *user_data,
                     GError **error);

Iterates over `diff` generating text output like "git diff".

#### Parameters

diff | a GgitDiff. |
type | a GgitDiffFormatType. |
print_cb | a GgitDiffLineCallback. | [scope call][closure user_data]
user_data | callback user data. |
error | a GError for error reporting, or `NULL`. |

### ggit_diff_blobs ()

    void
    ggit_diff_blobs (GgitBlob *old_blob,
                     const gchar *old_as_path,
                     GgitBlob *new_blob,
                     const gchar *new_as_path,
                     GgitDiffOptions *diff_options,
                     GgitDiffFileCallback file_cb,
                     GgitDiffBinaryCallback binary_cb,
                     GgitDiffHunkCallback hunk_cb,
                     GgitDiffLineCallback line_cb,
                     gpointer *user_data,
                     GError **error);

Iterates over the diff calling `file_cb` , `binary_cb` , `hunk_cb` and `line_cb` .

The GgitDiffFile mode always be 0, path will be `NULL` and when a blob is `NULL` the oid will be 0.

If `diff_options` is `NULL` then the defaults specified in `ggit_diff_options_new()` are used.

#### Parameters

old_blob | a GgitBlob to diff from. | [allow-none]
old_as_path | treat `old_blob` as if it had this filename, or `NULL`,. | [allow-none]
new_blob | a GgitBlob to diff to. | [allow-none]
new_as_path | treat `new_blob` as if it had this filename, or `NULL`,. | [allow-none]
diff_options | a GgitDiffOptions, or `NULL`. | [allow-none]
file_cb | a GgitDiffFileCallback. | [allow-none][scope call][closure user_data]
binary_cb | a GgitDiffBinaryCallback. | [allow-none][scope call][closure user_data]
hunk_cb | a GgitDiffHunkCallback. | [allow-none][scope call][closure user_data]
line_cb | a GgitDiffLineCallback. | [allow-none][scope call][closure user_data]
user_data | callback user data. |
error | a GError for error reporting, or `NULL`. |

### ggit_diff_blob_to_buffer ()

    void
    ggit_diff_blob_to_buffer (GgitBlob *old_blob,
                              const gchar *old_as_path,
                              const guint8 *buffer,
                              gssize buffer_len,
                              const gchar *buffer_as_path,
                              GgitDiffOptions *diff_options,
                              GgitDiffFileCallback file_cb,
                              GgitDiffBinaryCallback binary_cb,
                              GgitDiffHunkCallback hunk_cb,
                              GgitDiffLineCallback line_cb,
                              gpointer user_data,
                              GError **error);

Same as `ggit_diff_blobs()` but using a buffer.

#### Parameters

old_blob | a GgitBlob to diff from. | [allow-none]
old_as_path | treat `old_blob` as if it had this filename, or `NULL`,. | [allow-none]
buffer | a buffer to diff to. | [allow-none][array length=buffer_len]
buffer_len | length of `buffer` . |
buffer_as_path | treat `buffer` as if it had this filename, or `NULL`,. | [allow-none]
diff_options | a GgitDiffOptions, or `NULL`. | [allow-none]
file_cb | a GgitDiffFileCallback. | [allow-none][scope call][closure user_data]
binary_cb | a GgitDiffBinaryCallback. | [allow-none][scope call][closure user_data]
hunk_cb | a GgitDiffHunkCallback. | [allow-none][scope call][closure user_data]
line_cb | a GgitDiffLineCallback. | [allow-none][scope call][closure user_data]
user_data | callback user data. |
error | a GError for error reporting, or `NULL`. |

## Types and Values

### GgitDiff

    typedef struct _GgitDiff GgitDiff;

Represents a diff list.

### struct GgitDiffClass

    struct GgitDiffClass {
    };

The class structure for GgitDiffClass.

#### Members

### enum GgitDiffFlag

Describes the diff file and/or delta flags

#### Members

GGIT_DIFF_FLAG_BINARY | if the file is binary. |
GGIT_DIFF_FLAG_NOT_BINARY | if the file is not binary. |
GGIT_DIFF_FLAG_VALID_ID | if the ID is valid. |

### enum GgitDiffLineType

These values describe where a line came from and will be passed to the GgitDiffLineCallback when iterating over a diff.

The GGIT_DIFF_LINE_FILE_HDR, GGIT_DIFF_LINE_HUNK_HDR and GGIT_DIFF_LINE_BINARY values are only sent when the diff is being printed.

#### Members

GGIT_DIFF_LINE_CONTEXT | line is part of the context. |
GGIT_DIFF_LINE_ADDITION | line that was added. |
GGIT_DIFF_LINE_DELETION | line that was removed. |
GGIT_DIFF_LINE_CONTEXT_EOFNL | Both files have no LF at end. |
GGIT_DIFF_LINE_ADD_EOFNL | LF was added at end of file. |
GGIT_DIFF_LINE_DEL_EOFNL | LF was removed at end of file. |
GGIT_DIFF_LINE_FILE_HDR | the file header. |
GGIT_DIFF_LINE_HUNK_HDR | the hunk header. |
GGIT_DIFF_LINE_BINARY | is binary. |

### enum GgitDiffFormatType

Possible output formats for diff data.

#### Members

GGIT_DIFF_FORMAT_PATCH | full git diff. |
GGIT_DIFF_FORMAT_PATCH_HEADER | just the file headers of patch. |
GGIT_DIFF_FORMAT_RAW | like git diff --raw. |
GGIT_DIFF_FORMAT_NAME_ONLY | like git diff --name-only. |
GGIT_DIFF_FORMAT_NAME_STATUS | like git diff --name-status. |

### enum GgitDiffOption

How the diff should be generated.

#### Members

GGIT_DIFF_NORMAL | normal. |
GGIT_DIFF_REVERSE | reverse the sides of the diff. |
GGIT_DIFF_INCLUDE_IGNORED | include ignored files. |
GGIT_DIFF_RECURSE_IGNORED_DIRS | also add all files under ignored dirs. |
GGIT_DIFF_INCLUDE_UNTRACKED | include untracked files. |
GGIT_DIFF_RECURSE_UNTRACKED_DIRS | recurse to untracked directories. |
GGIT_DIFF_INCLUDE_UNMODIFIED | include unmodified files. |
GGIT_DIFF_INCLUDE_TYPECHANGE | enable generation of typechange detal records. |
GGIT_DIFF_INCLUDE_TYPECHANGE_TREES | try to label tree transitions as type changes. |
GGIT_DIFF_IGNORE_FILE_MODE | ignore file mode changes. |
GGIT_DIFF_IGNORE_SUBMODULES | ignore submodules. |
GGIT_DIFF_IGNORE_CASE | use case insensitive filename comparison. |
GGIT_DIFF_DISABLE_PATHSPEC_MATCH | use exact path matching. |
GGIT_DIFF_SKIP_BINARY_CHECK | disable updating the binary flag in delta records. |
GGIT_DIFF_ENABLE_FAST_UNTRACKED_DIRS | immediately label untracked directories as untracked, without checking inside. |
GGIT_DIFF_FORCE_TEXT | force text. |
GGIT_DIFF_FORCE_BINARY | treat all files as binary, disabling text diffs. |
GGIT_DIFF_IGNORE_WHITESPACE | ignore whitespace. |
GGIT_DIFF_IGNORE_WHITESPACE_CHANGE | ignore whitespace change. |
GGIT_DIFF_IGNORE_WHITESPACE_EOL | ignore whitespace at end-of-line. |
GGIT_DIFF_SHOW_UNTRACKED_CONTENT | include content of untracked files. this implies GGIT_DIFF_INCLUDE_UNTRACKED but not GGIT_DIFF_RECURSE_UNTRACKED_DIRS. |
GGIT_DIFF_SHOW_UNMODIFIED | show unmodified files. |
GGIT_DIFF_PATIENCE | generate using the "patience diff" algorithm. |
GGIT_DIFF_MINIMAL | take extra time to find minimal diff. |
GGIT_DIFF_SHOW_BINARY | include deflate/delta information for binary files. |

## Property Details

### The `“repository”` property

      “repository”               GgitRepository *

Repository.

Flags: Read / Write / Construct Only