Skip to content

getByPath

Get one of the entries in the index by its path.

Signature

ts
class Index {
  getByPath(path: string, stage?: IndexStage): IndexEntry | null;
}

Parameters

  • pathrequired · string

    Path to lookup entry.

  • stagenull | IndexStage

    Git index stage states.

    - Any : Match any index stage.
    - Normal : A normal staged file in the index.
    - Ancestor : The ancestor side of a conflict.
    - Ours : The "ours" side of a conflict.
    - Theirs : The "theirs" side of a conflict.

Returns

  • null | IndexEntry

    Index entry for the path.

    • ctimerequired · Date
    • devrequired · number
    • fileSizerequired · number
    • flagsrequired · number
    • flagsExtendedrequired · number
    • gidrequired · number
    • idrequired · string
    • inorequired · number
    • moderequired · number
    • mtimerequired · Date
    • pathrequired · Buffer

      The path of this index entry as a byte vector. Regardless of the current platform, the directory separator is an ASCII forward slash (0x2F). There are no terminating or internal NUL characters, and no trailing slashes. Most of the time, paths will be valid utf-8 — but not always. For more information on the path storage format, see [these git docs](https://github.com/git/git/blob/a08a83db2bf27f015bec9a435f6d73e223c21c5e/Documentation/technical/index-format.txt#L107-L124). Note that libgit2 will take care of handling the prefix compression mentioned there.

    • uidrequired · number

Released under the MIT License.