Blame include/git2/sys/index.h

Packit Service 20376f
/*
Packit Service 20376f
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit Service 20376f
 *
Packit Service 20376f
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit Service 20376f
 * a Linking Exception. For full terms see the included COPYING file.
Packit Service 20376f
 */
Packit Service 20376f
#ifndef INCLUDE_sys_git_index_h__
Packit Service 20376f
#define INCLUDE_sys_git_index_h__
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * @file git2/sys/index.h
Packit Service 20376f
 * @brief Low-level Git index manipulation routines
Packit Service 20376f
 * @defgroup git_backend Git custom backend APIs
Packit Service 20376f
 * @ingroup Git
Packit Service 20376f
 * @{
Packit Service 20376f
 */
Packit Service 20376f
GIT_BEGIN_DECL
Packit Service 20376f
Packit Service 20376f
/** Representation of a rename conflict entry in the index. */
Packit Service 20376f
typedef struct git_index_name_entry {
Packit Service 20376f
	char *ancestor;
Packit Service 20376f
	char *ours;
Packit Service 20376f
	char *theirs;
Packit Service 20376f
} git_index_name_entry;
Packit Service 20376f
Packit Service 20376f
/** Representation of a resolve undo entry in the index. */
Packit Service 20376f
typedef struct git_index_reuc_entry {
Packit Service 20376f
	uint32_t mode[3];
Packit Service 20376f
	git_oid oid[3];
Packit Service 20376f
	char *path;
Packit Service 20376f
} git_index_reuc_entry;
Packit Service 20376f
Packit Service 20376f
/** @name Conflict Name entry functions
Packit Service 20376f
 *
Packit Service 20376f
 * These functions work on rename conflict entries.
Packit Service 20376f
 */
Packit Service 20376f
/**@{*/
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get the count of filename conflict entries currently in the index.
Packit Service 20376f
 *
Packit Service 20376f
 * @param index an existing index object
Packit Service 20376f
 * @return integer of count of current filename conflict entries
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(size_t) git_index_name_entrycount(git_index *index);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get a filename conflict entry from the index.
Packit Service 20376f
 *
Packit Service 20376f
 * The returned entry is read-only and should not be modified
Packit Service 20376f
 * or freed by the caller.
Packit Service 20376f
 *
Packit Service 20376f
 * @param index an existing index object
Packit Service 20376f
 * @param n the position of the entry
Packit Service 20376f
 * @return a pointer to the filename conflict entry; NULL if out of bounds
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(const git_index_name_entry *) git_index_name_get_byindex(
Packit Service 20376f
	git_index *index, size_t n);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Record the filenames involved in a rename conflict.
Packit Service 20376f
 *
Packit Service 20376f
 * @param index an existing index object
Packit Service 20376f
 * @param ancestor the path of the file as it existed in the ancestor
Packit Service 20376f
 * @param ours the path of the file as it existed in our tree
Packit Service 20376f
 * @param theirs the path of the file as it existed in their tree
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_index_name_add(git_index *index,
Packit Service 20376f
	const char *ancestor, const char *ours, const char *theirs);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Remove all filename conflict entries.
Packit Service 20376f
 *
Packit Service 20376f
 * @param index an existing index object
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(void) git_index_name_clear(git_index *index);
Packit Service 20376f
Packit Service 20376f
/**@}*/
Packit Service 20376f
Packit Service 20376f
/** @name Resolve Undo (REUC) index entry manipulation.
Packit Service 20376f
 *
Packit Service 20376f
 * These functions work on the Resolve Undo index extension and contains
Packit Service 20376f
 * data about the original files that led to a merge conflict.
Packit Service 20376f
 */
Packit Service 20376f
/**@{*/
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get the count of resolve undo entries currently in the index.
Packit Service 20376f
 *
Packit Service 20376f
 * @param index an existing index object
Packit Service 20376f
 * @return integer of count of current resolve undo entries
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(size_t) git_index_reuc_entrycount(git_index *index);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Finds the resolve undo entry that points to the given path in the Git
Packit Service 20376f
 * index.
Packit Service 20376f
 *
Packit Service 20376f
 * @param at_pos the address to which the position of the reuc entry is written (optional)
Packit Service 20376f
 * @param index an existing index object
Packit Service 20376f
 * @param path path to search
Packit Service 20376f
 * @return 0 if found, < 0 otherwise (GIT_ENOTFOUND)
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_index_reuc_find(size_t *at_pos, git_index *index, const char *path);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get a resolve undo entry from the index.
Packit Service 20376f
 *
Packit Service 20376f
 * The returned entry is read-only and should not be modified
Packit Service 20376f
 * or freed by the caller.
Packit Service 20376f
 *
Packit Service 20376f
 * @param index an existing index object
Packit Service 20376f
 * @param path path to search
Packit Service 20376f
 * @return the resolve undo entry; NULL if not found
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_bypath(git_index *index, const char *path);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get a resolve undo entry from the index.
Packit Service 20376f
 *
Packit Service 20376f
 * The returned entry is read-only and should not be modified
Packit Service 20376f
 * or freed by the caller.
Packit Service 20376f
 *
Packit Service 20376f
 * @param index an existing index object
Packit Service 20376f
 * @param n the position of the entry
Packit Service 20376f
 * @return a pointer to the resolve undo entry; NULL if out of bounds
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_byindex(git_index *index, size_t n);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Adds a resolve undo entry for a file based on the given parameters.
Packit Service 20376f
 *
Packit Service 20376f
 * The resolve undo entry contains the OIDs of files that were involved
Packit Service 20376f
 * in a merge conflict after the conflict has been resolved.  This allows
Packit Service 20376f
 * conflicts to be re-resolved later.
Packit Service 20376f
 *
Packit Service 20376f
 * If there exists a resolve undo entry for the given path in the index,
Packit Service 20376f
 * it will be removed.
Packit Service 20376f
 *
Packit Service 20376f
 * This method will fail in bare index instances.
Packit Service 20376f
 *
Packit Service 20376f
 * @param index an existing index object
Packit Service 20376f
 * @param path filename to add
Packit Service 20376f
 * @param ancestor_mode mode of the ancestor file
Packit Service 20376f
 * @param ancestor_id oid of the ancestor file
Packit Service 20376f
 * @param our_mode mode of our file
Packit Service 20376f
 * @param our_id oid of our file
Packit Service 20376f
 * @param their_mode mode of their file
Packit Service 20376f
 * @param their_id oid of their file
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_index_reuc_add(git_index *index, const char *path,
Packit Service 20376f
	int ancestor_mode, const git_oid *ancestor_id,
Packit Service 20376f
	int our_mode, const git_oid *our_id,
Packit Service 20376f
	int their_mode, const git_oid *their_id);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Remove an resolve undo entry from the index
Packit Service 20376f
 *
Packit Service 20376f
 * @param index an existing index object
Packit Service 20376f
 * @param n position of the resolve undo entry to remove
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_index_reuc_remove(git_index *index, size_t n);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Remove all resolve undo entries from the index
Packit Service 20376f
 *
Packit Service 20376f
 * @param index an existing index object
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(void) git_index_reuc_clear(git_index *index);
Packit Service 20376f
Packit Service 20376f
/**@}*/
Packit Service 20376f
Packit Service 20376f
/** @} */
Packit Service 20376f
GIT_END_DECL
Packit Service 20376f
#endif