## GgitTree GgitTree |

## Synopsis

                        GgitTree;
    struct              GgitTreeClass;
    gint                (*GgitTreeWalkCallback)             (const gchar *root,
                                                             const GgitTreeEntry *entry,
                                                             gpointer user_data);
    enum                GgitTreeWalkMode;
    GgitOId *           ggit_tree_get_id                    (GgitTree *tree);
    GgitTreeEntry *     ggit_tree_get                       (GgitTree *tree,
                                                             guint i);
    guint               ggit_tree_size                      (GgitTree *tree);
    GgitTreeEntry *     ggit_tree_get_by_name               (GgitTree *tree,
                                                             const gchar *name);
    GgitTreeEntry *     ggit_tree_get_by_path               (GgitTree *tree,
                                                             const gchar *path,
                                                             GError **error);
    void                ggit_tree_walk                      (GgitTree *tree,
                                                             GgitTreeWalkMode mode,
                                                             GgitTreeWalkCallback callback,
                                                             gpointer user_data,
                                                             GError **error);

## Object Hierarchy

      GObject
       +----GgitObjectFactoryBase
             +----GgitNative
                   +----GgitObject
                         +----GgitTree

      GEnum
       +----GgitTreeWalkMode

## Description

## Details

### GgitTree

    typedef struct _GgitTree GgitTree;

Represents a tree object.

### struct GgitTreeClass

    struct GgitTreeClass {
    };

The class structure for GgitTreeClass.

### GgitTreeWalkCallback ()

    gint                (*GgitTreeWalkCallback)             (const gchar *root,
                                                             const GgitTreeEntry *entry,
                                                             gpointer user_data);

The type of the callback functions for walking a tree. See `ggit_tree_walk()`.

`root` : | the current (relative) root of the entry
`entry` : | the tree entry
`user_data` : | user-supplied data. [closure]
Returns : | 0 to go for the next entry or a GgitError in case there was an error.

### enum GgitTreeWalkMode

    typedef enum {
    	GGIT_TREE_WALK_MODE_PRE = 0,
    	GGIT_TREE_WALK_MODE_POST = 1,
    } GgitTreeWalkMode;

Describes in which order a tree walk should be performed.

`GGIT_TREE_WALK_MODE_PRE` | walk tree in pre-order
`GGIT_TREE_WALK_MODE_POST` | walk tree in post-order

### ggit_tree_get_id ()

    GgitOId *           ggit_tree_get_id                    (GgitTree *tree);

Get the GgitOId of the tree.

`tree` : | a GgitTree.
Returns : | a GgitOId. [transfer full]

### ggit_tree_get ()

    GgitTreeEntry *     ggit_tree_get                       (GgitTree *tree,
                                                             guint i);

Get a tree entry by index.

`tree` : | a GgitTree.
`i` : | the index of the entry.
Returns : | a GgitTreeEntry. [transfer full]

### ggit_tree_size ()

    guint               ggit_tree_size                      (GgitTree *tree);

Get the number of entries in the tree.

`tree` : | a GgitTree.
Returns : | the number of entries in the tree.

### ggit_tree_get_by_name ()

    GgitTreeEntry *     ggit_tree_get_by_name               (GgitTree *tree,
                                                             const gchar *name);

Get a tree entry by name.

`tree` : | a GgitTree.
`name` : | a filename.
Returns : | a GgitTreeEntry. [transfer full]

### ggit_tree_get_by_path ()

    GgitTreeEntry *     ggit_tree_get_by_path               (GgitTree *tree,
                                                             const gchar *path,
                                                             GError **error);

Retrieves a tree entry contained in a tree or in any of its subtrees, given its relative path.

`tree` : | a GgitTree.
`path` : | a path.
`error` : | a GError for error reporting, or `NULL`.
Returns : | a GgitTreeEntry. [transfer full]

### ggit_tree_walk ()

    void                ggit_tree_walk                      (GgitTree *tree,
                                                             GgitTreeWalkMode mode,
                                                             GgitTreeWalkCallback callback,
                                                             gpointer user_data,
                                                             GError **error);

Walk all the entries of a tree object recursively (resolving and walking subtrees of the tree as needed). The `error` will be set to the error returned by `callback` (if any).

`tree` : | a GgitTree.
`mode` : | the walking order.
`callback` : | the callback to call for each entry. [scope call]
`user_data` : | user data for the callback. [closure]
`error` : | a GError for error reporting, or `NULL`.