---
name: "Git::Raw::Index"
section: "3pm"
platform: "linux"
package: "libgit-raw-perl"
version: "0.90+ds-3+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Git::Raw::Index"
---

# Git::Raw::Index(3pm)

Git index class

## NAME

Git::Raw::Index - Git index class

## VERSION

version 0.90

## DESCRIPTION

A Git::Raw::Index represents an index in a Git repository.

**WARNING**: The API of this module is unstable and may change without warning (any change will be appropriately documented in the changelog).

## METHODS

### new( )

Create a new in-memory index. This is currently of little use.

### owner( )

Retrieve the Git::Raw::Repository owning the index.

### add( $entry )

Add `$entry` to the index. `$entry` should either be the path of a file or alternatively a Git::Raw::Index::Entry.

### add\_frombuffer( $path, $buffer, \[$mode\] )

Add or update an entry from an in-memory file. The entry will be placed at `$path` with the contents of `$buffer`. `$buffer` may either be string or a reference to a string. `$mode` is the file mode; it defaults to `0100644`. Returns a Git::Raw::Index::Entry object.

### add\_all( \\%opts )

Add or update all index entries to match the working directory. Valid fields for the `%opts` hash are:

- •

  "paths"

  List of path patterns to add.

- •

  "flags"

  Valid fields for the `%flags` member:

  - •

    "force"

    Forced addition of files (even if they are ignored).

  - •

    "disable\_pathspec\_match"

    Disable pathspec pattern matching against entries in `$paths`.

  - •

    "check\_pathspec"

    Enable pathspec pattern matching against entries in `$paths` (default).

- •

  "notification"

  The callback to be called for each added or updated item. Receives the `$path` and matching `$pathspec`. This callback should return `0` if the file should be added to the index, `">0"` if it should be skipped or `"<0"` to abort.

### find( $path )

Find the first Git::Raw::Index::Entry which points to a given `$path`. If an entry cannot be found, this function will return `"undef"`.

### remove( $path )

Remove `$path` from the index.

### remove\_all( \\%opts )

Remove all matching index entries. See `"Git::Raw::Index->update_all()"` for valid `%opts` values.

### path( )

Retrieve the full path to the index file on disk.

### checksum( )

Retrieve the SHA-1 checksum over the index file, except for the last 20 bytes which is the checksum content itself. If the index does not exist on-disk an empty OID will be returned.

### clear( )

Clear the index.

### read( \[$force\] )

Update the index, reading it from disk.

### write( )

Write the index to disk.

### read\_tree( $tree )

Replace the index content with `$tree`.

### write\_tree( \[$repo\] )

Create a new tree from the index and write it to disk. `$repo` optionally indicates which Git::Raw::Repository the tree should be written to. Returns a Git::Raw::Tree object.

### checkout( \[\\%checkout\_opts\] )

Update files in the working tree to match the contents of the index. See `"Git::Raw::Repository->checkout()"` for valid `%checkout_opts` values.

### entry\_count( )

Retrieve the number of entries in the index.

### entries( )

Retrieve index entries. Returns a list of Git::Raw::Index::Entry objects.

### add\_conflict( $ancestor, $theirs, $ours)

Add a new conflict entry. `$ancestor`, `$theirs` and `$ours` should be Git::Raw::Index::Entry objects.

### get\_conflict( $path )

Get the conflict entry for `$path`. If `$path` has no conflict entry, this function will return `"undef"`.

### remove\_conflict( $path )

Remove `$path` from the index.

### has\_conflicts( )

Determine if the index contains entries representing file conflicts.

### conflict\_cleanup( )

Remove all conflicts in the index (entries with a stage greater than 0).

### conflicts( )

Retrieve index entries that represent a conflict. Returns a list of Git::Raw::Index::Conflict objects.

### merge( $ancestor, $theirs, $ours, \[\\%merge\_opts\] )

Merge two files as they exist in the index. `$ancestor`, `$theirs` and `$ours` should be Git::Raw::Index::Entry objects. Returns a Git::Raw::Merge::File::Result object. Valid fields for the `%merge_opts` hash are:

- •

  "our\_label"

  The name of the "our" side of conflicts.

- •

  "their\_label"

  The name of the "their" side of conflicts.

- •

  "ancestor\_label"

  The name of the common ancestor side of conflicts.

- •

  "favor"

  Specify content automerging behaviour. Valid values are `"ours"`, `"theirs"`, and `"union"`.

- •

  "marker\_size"

  The size of conflict markers.

- •

  "flags"

  Merge file flags. Valid values include:

  - •

    "merge"

    Create standard conflicted merge file.

  - •

    "diff3"

    Create diff3-style files.

  - •

    "simplify\_alnum"

    Condense non-alphanumeric regions for simplified diff file.

  - •

    "ignore\_whitespace"

    Ignore all whitespace.

  - •

    "ignore\_whitespace\_change"

    Ignore changes in amount of whitespace.

  - •

    "ignore\_whitespace\_eol"

    Ignore whitespace at end of line.

  - •

    "patience"

    Use the `"patience diff"` algorithm.

  - •

    "minimal"

    Take extra time to find minimal diff.

### update\_all( \\%opts )

Update all index entries to match the working directory. Valid fields for the `%opts` hash are:

- •

  "paths"

  List of path patterns to add.

- •

  "notification"

  The callback to be called for each updated item. Receives the `$path` and matching `$pathspec`. This callback should return `0` if the file should be added to the index, `">0"` if it should be skipped, or `"<0"` to abort.

### capabilities( )

Retrieve the index's capabilities. Returns a hash with members `"ignore_case"`, `"no_filemode"` and `"no_symlinks"`, each indicating if the Git::Raw::Index supports the capability.

### version( \[$version\] )

Retrieve or set the index version.

## AUTHOR

Alessandro Ghedini \<alexbio@cpan.org\>

Jacques Germishuys \<jacquesg@cpan.org\>

## LICENSE AND COPYRIGHT

Copyright 2012 Alessandro Ghedini.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.
