### Function

# Ggit Patch new_from_diff

#### Declaration [src]

    GgitPatch*
    ggit_patch_new_from_diff (
      GgitDiff* diff,
      gsize idx,
      GError** error
    )

#### Description [src]

The `GgitPatch` is a newly created object contains the text diffs for the delta. You have to call `ggit_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.

#### Parameters

`diff`

  Type: `GgitDiff`

  A `GgitDiff`.

  The data is owned by the caller of the function.

`idx`

  Type: `gsize`

  Index into diff list.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the function if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `GgitPatch`

A newly created `GgitPatch` or `NULL`.

The caller of the function takes ownership of the data, and is responsible for freeing it.
The return value can be `NULL`.