GgitDiff

GgitDiff

Synopsis

                    GgitDiff;
struct              GgitDiffClass;
gint                (*GgitDiffFileCallback)             (GgitDiffDelta *delta,
                                                         gfloat progress,
                                                         gpointer user_data);
enum                GgitDiffFlag;
gint                (*GgitDiffHunkCallback)             (GgitDiffDelta *delta,
                                                         GgitDiffRange *range,
                                                         const gchar *header,
                                                         gsize header_len,
                                                         gpointer user_data);
gint                (*GgitDiffLineCallback)             (GgitDiffDelta *delta,
                                                         GgitDiffRange *range,
                                                         GgitDiffLineType line_type,
                                                         const gchar *content,
                                                         gsize content_len,
                                                         gpointer user_data);
enum                GgitDiffLineType;
enum                GgitDiffOption;
GgitDiff *          ggit_diff_new_tree_to_tree          (GgitRepository *repository,
                                                         GgitTree *old_tree,
                                                         GgitTree *new_tree,
                                                         GgitDiffOptions *diff_options,
                                                         GError **error);
GgitDiff *          ggit_diff_new_tree_to_index         (GgitRepository *repository,
                                                         GgitTree *old_tree,
                                                         GgitIndex *index,
                                                         GgitDiffOptions *diff_options,
                                                         GError **error);
GgitDiff *          ggit_diff_new_index_to_workdir      (GgitRepository *repository,
                                                         GgitIndex *index,
                                                         GgitDiffOptions *diff_options,
                                                         GError **error);
GgitDiff *          ggit_diff_new_tree_to_workdir       (GgitRepository *repository,
                                                         GgitTree *old_tree,
                                                         GgitDiffOptions *diff_options,
                                                         GError **error);
void                ggit_diff_merge                     (GgitDiff *onto,
                                                         GgitDiff *from,
                                                         GError **error);
void                ggit_diff_foreach                   (GgitDiff *diff,
                                                         GgitDiffFileCallback file_cb,
                                                         GgitDiffHunkCallback hunk_cb,
                                                         GgitDiffLineCallback line_cb,
                                                         gpointer *user_data,
                                                         GError **error);
void                ggit_diff_print_compact             (GgitDiff *diff,
                                                         GgitDiffLineCallback print_cb,
                                                         gpointer *user_data,
                                                         GError **error);
void                ggit_diff_print_patch               (GgitDiff *diff,
                                                         GgitDiffLineCallback print_cb,
                                                         gpointer *user_data,
                                                         GError **error);
void                ggit_diff_blobs                     (GgitDiffOptions *diff_options,
                                                         GgitBlob *old_blob,
                                                         GgitBlob *new_blob,
                                                         GgitDiffFileCallback file_cb,
                                                         GgitDiffHunkCallback hunk_cb,
                                                         GgitDiffLineCallback line_cb,
                                                         gpointer *user_data,
                                                         GError **error);
void                ggit_diff_blob_to_buffer            (GgitDiffOptions *diff_options,
                                                         GgitBlob *old_blob,
                                                         const gchar *buffer,
                                                         gsize buffer_len,
                                                         GgitDiffFileCallback file_cb,
                                                         GgitDiffHunkCallback hunk_cb,
                                                         GgitDiffLineCallback line_cb,
                                                         gpointer *user_data,
                                                         GError **error);

Object Hierarchy

  GObject
   +----GgitObjectFactoryBase
         +----GgitNative
               +----GgitDiff
  GFlags
   +----GgitDiffFlag
  GEnum
   +----GgitDiffLineType
  GFlags
   +----GgitDiffOption

Description

Details

GgitDiff

typedef struct _GgitDiff GgitDiff;

Represents a diff.


struct GgitDiffClass

struct GgitDiffClass {
};

The class structure for GgitDiffClass.


GgitDiffFileCallback ()

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

Called for each file.

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.

enum GgitDiffFlag

typedef enum {
	GGIT_DIFF_FLAG_BINARY     = 1 << 0,
	GGIT_DIFF_FLAG_NOT_BINARY = 1 << 1,
	GGIT_DIFF_FLAG_VALID_OID  = 1 << 2
} GgitDiffFlag;

Describes the diff file and/or delta flags

GGIT_DIFF_FLAG_BINARY

if the file is binary.

GGIT_DIFF_FLAG_NOT_BINARY

if the file is not binary.

GGIT_DIFF_FLAG_VALID_OID

if the OID is valid.

GgitDiffHunkCallback ()

gint                (*GgitDiffHunkCallback)             (GgitDiffDelta *delta,
                                                         GgitDiffRange *range,
                                                         const gchar *header,
                                                         gsize header_len,
                                                         gpointer user_data);

Called for each hunk.

delta :

a GgitDiffDelta.

range :

a GgitDiffRange.

header :

the header. [array length=header_len][element-type guint8]

header_len :

the header length.

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,
                                                         GgitDiffRange *range,
                                                         GgitDiffLineType line_type,
                                                         const gchar *content,
                                                         gsize content_len,
                                                         gpointer user_data);

Called for each line.

delta :

a GgitDiffDelta.

range :

a GgitDiffRange.

line_type :

a GgitDiffLineType.

content :

the content. [array length=content_len][element-type guint8]

content_len :

the content length.

user_data :

user-supplied data. [closure]

Returns :

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

enum GgitDiffLineType

typedef enum {
	GGIT_DIFF_LINE_CONTEXT   = ' ',
	GGIT_DIFF_LINE_ADDITION  = '+',
	GGIT_DIFF_LINE_DELETION  = '-',
	GGIT_DIFF_LINE_ADD_EOFNL = '\n',
	GGIT_DIFF_LINE_DEL_EOFNL = '\0',
	GGIT_DIFF_LINE_FILE_HDR  = 'F',
	GGIT_DIFF_LINE_HUNK_HDR  = 'H',
	GGIT_DIFF_LINE_BINARY    = 'B'
} 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.

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_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 GgitDiffOption

typedef enum {
	GGIT_DIFF_NORMAL                   = 0,
	GGIT_DIFF_REVERSE                  = 1 << 0,
	GGIT_DIFF_FORCE_TEXT               = 1 << 1,
	GGIT_DIFF_IGNORE_WHITESPACE        = 1 << 2,
	GGIT_DIFF_IGNORE_WHITESPACE_CHANGE = 1 << 3,
	GGIT_DIFF_IGNORE_WHITESPACE_EOL    = 1 << 4,
	GGIT_DIFF_IGNORE_SUBMODULES        = 1 << 5,
	GGIT_DIFF_PATIENCE                 = 1 << 6,
	GGIT_DIFF_INCLUDE_IGNORED          = 1 << 7,
	GGIT_DIFF_INCLUDE_UNTRACKED        = 1 << 8,
	GGIT_DIFF_INCLUDE_UNMODIFIED       = 1 << 9,
	GGIT_DIFF_RECURSE_UNTRACKED_DIRS   = 1 << 10
} GgitDiffOption;

How the diff should be generated.

GGIT_DIFF_NORMAL

normal.

GGIT_DIFF_REVERSE

reverse.

GGIT_DIFF_FORCE_TEXT

force text.

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_IGNORE_SUBMODULES

ignore submodules.

GGIT_DIFF_PATIENCE

generate using the "patience diff" algorithm.

GGIT_DIFF_INCLUDE_IGNORED

include ignored files.

GGIT_DIFF_INCLUDE_UNTRACKED

include untracked files.

GGIT_DIFF_INCLUDE_UNMODIFIED

include unmodified files.

GGIT_DIFF_RECURSE_UNTRACKED_DIRS

recurse to untracked directories.

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.

repository :

a GgitRepository.

old_tree :

a GgitTree to diff from.

new_tree :

a GgitTree to diff to.

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.

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.

repository :

a GgitRepository.

old_tree :

a GgitTree to diff from.

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.

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.

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.

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.

repository :

a GgitRepository.

old_tree :

a GgitTree to diff from.

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.

ggit_diff_merge ()

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

Merges from into onto unless error is set.

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,
                                                         GgitDiffHunkCallback hunk_cb,
                                                         GgitDiffLineCallback line_cb,
                                                         gpointer *user_data,
                                                         GError **error);

Iterates over the diff calling file_cb, hunk_cb and line_cb.

diff :

a GgitDiff.

file_cb :

a GgitDiffFileCallback. [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_compact ()

void                ggit_diff_print_compact             (GgitDiff *diff,
                                                         GgitDiffLineCallback print_cb,
                                                         gpointer *user_data,
                                                         GError **error);

Iterates over diff generating text output like "git diff --name-status".

diff :

a GgitDiff.

print_cb :

a GgitDiffLineCallback. [scope call][closure user_data]

user_data :

callback user data.

error :

a GError for error reporting, or NULL.

ggit_diff_print_patch ()

void                ggit_diff_print_patch               (GgitDiff *diff,
                                                         GgitDiffLineCallback print_cb,
                                                         gpointer *user_data,
                                                         GError **error);

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

diff :

a GgitDiff.

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                     (GgitDiffOptions *diff_options,
                                                         GgitBlob *old_blob,
                                                         GgitBlob *new_blob,
                                                         GgitDiffFileCallback file_cb,
                                                         GgitDiffHunkCallback hunk_cb,
                                                         GgitDiffLineCallback line_cb,
                                                         gpointer *user_data,
                                                         GError **error);

Iterates over the diff calling file_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.

diff_options :

a GgitDiffOptions, or NULL. [allow-none]

old_blob :

a GgitBlob to diff from. [allow-none]

new_blob :

a GgitBlob to diff to. [allow-none]

file_cb :

a GgitDiffFileCallback. [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            (GgitDiffOptions *diff_options,
                                                         GgitBlob *old_blob,
                                                         const gchar *buffer,
                                                         gsize buffer_len,
                                                         GgitDiffFileCallback file_cb,
                                                         GgitDiffHunkCallback hunk_cb,
                                                         GgitDiffLineCallback line_cb,
                                                         gpointer *user_data,
                                                         GError **error);

Same as ggit_diff_blobs() but using a buffer.

diff_options :

a GgitDiffOptions, or NULL. [allow-none]

old_blob :

a GgitBlob to diff from. [allow-none]

buffer :

a buffer to diff to. [allow-none][array length=buffer_len]

buffer_len :

length of buffer.

file_cb :

a GgitDiffFileCallback. [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.