GgitDiffList

GgitDiffList

Synopsis

                    GgitDiffList;
struct              GgitDiffListClass;
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;
GgitDiffList *      ggit_diff_list_new_tree_to_tree     (GgitRepository *repository,
                                                         GgitTree *old_tree,
                                                         GgitTree *new_tree,
                                                         GgitDiffOptions *diff_options,
                                                         GError **error);
GgitDiffList *      ggit_diff_list_new_tree_to_index    (GgitRepository *repository,
                                                         GgitTree *old_tree,
                                                         GgitIndex *index,
                                                         GgitDiffOptions *diff_options,
                                                         GError **error);
GgitDiffList *      ggit_diff_list_new_index_to_workdir (GgitRepository *repository,
                                                         GgitIndex *index,
                                                         GgitDiffOptions *diff_options,
                                                         GError **error);
GgitDiffList *      ggit_diff_list_new_tree_to_workdir  (GgitRepository *repository,
                                                         GgitTree *old_tree,
                                                         GgitDiffOptions *diff_options,
                                                         GError **error);
void                ggit_diff_list_merge                (GgitDiffList *onto,
                                                         GgitDiffList *from,
                                                         GError **error);
void                ggit_diff_list_foreach              (GgitDiffList *diff,
                                                         GgitDiffFileCallback file_cb,
                                                         GgitDiffHunkCallback hunk_cb,
                                                         GgitDiffLineCallback line_cb,
                                                         gpointer *user_data,
                                                         GError **error);
void                ggit_diff_list_print_compact        (GgitDiffList *diff,
                                                         GgitDiffLineCallback print_cb,
                                                         gpointer *user_data,
                                                         GError **error);
void                ggit_diff_list_print_patch          (GgitDiffList *diff,
                                                         GgitDiffLineCallback print_cb,
                                                         gpointer *user_data,
                                                         GError **error);
void                ggit_diff_list_get_patch            (GgitDiffList *diff,
                                                         gsize idx,
                                                         GgitDiffPatch **patch,
                                                         GgitDiffDelta **delta,
                                                         GError **error);
void                ggit_diff_list_blobs                (GgitBlob *old_blob,
                                                         const gchar *old_as_path,
                                                         GgitBlob *new_blob,
                                                         const gchar *new_as_path,
                                                         GgitDiffOptions *diff_options,
                                                         GgitDiffFileCallback file_cb,
                                                         GgitDiffHunkCallback hunk_cb,
                                                         GgitDiffLineCallback line_cb,
                                                         gpointer *user_data,
                                                         GError **error);
void                ggit_diff_list_blob_to_buffer       (GgitBlob *old_blob,
                                                         const gchar *old_as_path,
                                                         const gchar *buffer,
                                                         gsize buffer_len,
                                                         const gchar *buffer_as_path,
                                                         GgitDiffOptions *diff_options,
                                                         GgitDiffFileCallback file_cb,
                                                         GgitDiffHunkCallback hunk_cb,
                                                         GgitDiffLineCallback line_cb,
                                                         gpointer *user_data,
                                                         GError **error);

Object Hierarchy

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

Description

Details

GgitDiffList

typedef struct _GgitDiffList GgitDiffList;

Represents a diff list.


struct GgitDiffListClass

struct GgitDiffListClass {
};

The class structure for GgitDiffListClass.


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_CONTEXT_EOFNL = '=',
	GGIT_DIFF_LINE_ADD_EOFNL     = '>',
	GGIT_DIFF_LINE_DEL_EOFNL     = '<',
	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_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 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_list_new_tree_to_tree ()

GgitDiffList *      ggit_diff_list_new_tree_to_tree     (GgitRepository *repository,
                                                         GgitTree *old_tree,
                                                         GgitTree *new_tree,
                                                         GgitDiffOptions *diff_options,
                                                         GError **error);

Creates a GgitDiffList 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. [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 GgitDiffList if there was no error, NULL otherwise.

ggit_diff_list_new_tree_to_index ()

GgitDiffList *      ggit_diff_list_new_tree_to_index    (GgitRepository *repository,
                                                         GgitTree *old_tree,
                                                         GgitIndex *index,
                                                         GgitDiffOptions *diff_options,
                                                         GError **error);

Creates a GgitDiffList 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. [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 GgitDiffList if there was no error, NULL otherwise.

ggit_diff_list_new_index_to_workdir ()

GgitDiffList *      ggit_diff_list_new_index_to_workdir (GgitRepository *repository,
                                                         GgitIndex *index,
                                                         GgitDiffOptions *diff_options,
                                                         GError **error);

Creates a GgitDiffList 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 GgitDiffList if there was no error, NULL otherwise.

ggit_diff_list_new_tree_to_workdir ()

GgitDiffList *      ggit_diff_list_new_tree_to_workdir  (GgitRepository *repository,
                                                         GgitTree *old_tree,
                                                         GgitDiffOptions *diff_options,
                                                         GError **error);

Creates a GgitDiffList 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. [allow-none]

diff_options :

a GgitDiffOptions, or NULL. [allow-none]

error :

a GError for error reporting, or NULL.

Returns :

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

ggit_diff_list_merge ()

void                ggit_diff_list_merge                (GgitDiffList *onto,
                                                         GgitDiffList *from,
                                                         GError **error);

Merges from into onto unless error is set.

onto :

the GgitDiffList to merge into.

from :

the GgitDiffList to merge.

error :

a GError for error reporting, or NULL.

ggit_diff_list_foreach ()

void                ggit_diff_list_foreach              (GgitDiffList *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 GgitDiffList.

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_list_print_compact ()

void                ggit_diff_list_print_compact        (GgitDiffList *diff,
                                                         GgitDiffLineCallback print_cb,
                                                         gpointer *user_data,
                                                         GError **error);

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

diff :

a GgitDiffList.

print_cb :

a GgitDiffLineCallback. [scope call][closure user_data]

user_data :

callback user data.

error :

a GError for error reporting, or NULL.

ggit_diff_list_print_patch ()

void                ggit_diff_list_print_patch          (GgitDiffList *diff,
                                                         GgitDiffLineCallback print_cb,
                                                         gpointer *user_data,
                                                         GError **error);

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

diff :

a GgitDiffList.

print_cb :

a GgitDiffLineCallback. [scope call][closure user_data]

user_data :

callback user data.

error :

a GError for error reporting, or NULL.

ggit_diff_list_get_patch ()

void                ggit_diff_list_get_patch            (GgitDiffList *diff,
                                                         gsize idx,
                                                         GgitDiffPatch **patch,
                                                         GgitDiffDelta **delta,
                                                         GError **error);

Gets the diff delta and patch for an entry in diff.

The GgitDiffPatch is a newly created object contains the text diffs for the delta. You have to call git_diff_patch_unref() when you are done with it. You can use the patch object to loop over all the hunks and lines in the diff of the one delta.

For an unchanged file or a binary file, no GgitDiffPatch will be created, the output will be set to NULL, and the `binary` flag will be set true in delta.

It is okay to pass NULL for either of the output parameters; if you pass NULL for patch, then the text diff will not be calculated.

diff :

a GgitDiffList.

idx :

index into diff.

patch :

a GgitDiffPatch or NULL. [allow-none]

delta :

a GgitDiffDelta or NULL. [allow-none]

error :

a GError for error reporting, or NULL.

ggit_diff_list_blobs ()

void                ggit_diff_list_blobs                (GgitBlob *old_blob,
                                                         const gchar *old_as_path,
                                                         GgitBlob *new_blob,
                                                         const gchar *new_as_path,
                                                         GgitDiffOptions *diff_options,
                                                         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.

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]

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_list_blob_to_buffer ()

void                ggit_diff_list_blob_to_buffer       (GgitBlob *old_blob,
                                                         const gchar *old_as_path,
                                                         const gchar *buffer,
                                                         gsize buffer_len,
                                                         const gchar *buffer_as_path,
                                                         GgitDiffOptions *diff_options,
                                                         GgitDiffFileCallback file_cb,
                                                         GgitDiffHunkCallback hunk_cb,
                                                         GgitDiffLineCallback line_cb,
                                                         gpointer *user_data,
                                                         GError **error);

Same as ggit_diff_list_blobs() but using a buffer.

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]

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.