libgit2

git_status_file

Version:

Get file status for a single file.

This tries to get status for the filename that you give. If no files match that name (in either the HEAD, index, or working directory), this returns GIT_ENOTFOUND.

If the name matches multiple files (for example, if the path names a directory or if running on a case- insensitive filesystem and yet the HEAD has two entries that both match the path), then this returns GIT_EAMBIGUOUS because it cannot give correct results.

This does not do any sort of rename detection. Renames require a set of targets and because of the path filtering, there is not enough information to check renames correctly. To check file status with rename detection, there is no choice but to do a full git_status_list_new and scan through looking for the path that you are interested in.

Signature

int git_status_file(unsigned int *status_flags, git_repository *repo, const char *path);

Parameters

unsigned int *
In
status_flags

Output combination of git_status_t values for file

In
repo

A repository object

const char *
In
path

The file to retrieve status for relative to the repo workdir

Returns

int

0 on success, GIT_ENOTFOUND if the file is not found in the HEAD, index, and work tree, GIT_EAMBIGUOUS if path matches multiple files or if it refers to a folder, and -1 on other errors.

Versions