Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:36

0001 /*
0002  * Copyright (C) the libgit2 contributors. All rights reserved.
0003  *
0004  * This file is part of libgit2, distributed under the GNU GPL v2 with
0005  * a Linking Exception. For full terms see the included COPYING file.
0006  */
0007 #ifndef INCLUDE_sys_git_index_h__
0008 #define INCLUDE_sys_git_index_h__
0009 
0010 #include "git2/common.h"
0011 #include "git2/types.h"
0012 
0013 /**
0014  * @file git2/sys/index.h
0015  * @brief Low-level Git index manipulation routines
0016  * @defgroup git_backend Git custom backend APIs
0017  * @ingroup Git
0018  * @{
0019  */
0020 GIT_BEGIN_DECL
0021 
0022 /** Representation of a rename conflict entry in the index. */
0023 typedef struct git_index_name_entry {
0024     char *ancestor;
0025     char *ours;
0026     char *theirs;
0027 } git_index_name_entry;
0028 
0029 /** Representation of a resolve undo entry in the index. */
0030 typedef struct git_index_reuc_entry {
0031     uint32_t mode[3];
0032     git_oid oid[3];
0033     char *path;
0034 } git_index_reuc_entry;
0035 
0036 /** @name Conflict Name entry functions
0037  *
0038  * These functions work on rename conflict entries.
0039  */
0040 /**@{*/
0041 
0042 /**
0043  * Get the count of filename conflict entries currently in the index.
0044  *
0045  * @param index an existing index object
0046  * @return integer of count of current filename conflict entries
0047  */
0048 GIT_EXTERN(size_t) git_index_name_entrycount(git_index *index);
0049 
0050 /**
0051  * Get a filename conflict entry from the index.
0052  *
0053  * The returned entry is read-only and should not be modified
0054  * or freed by the caller.
0055  *
0056  * @param index an existing index object
0057  * @param n the position of the entry
0058  * @return a pointer to the filename conflict entry; NULL if out of bounds
0059  */
0060 GIT_EXTERN(const git_index_name_entry *) git_index_name_get_byindex(
0061     git_index *index, size_t n);
0062 
0063 /**
0064  * Record the filenames involved in a rename conflict.
0065  *
0066  * @param index an existing index object
0067  * @param ancestor the path of the file as it existed in the ancestor
0068  * @param ours the path of the file as it existed in our tree
0069  * @param theirs the path of the file as it existed in their tree
0070  */
0071 GIT_EXTERN(int) git_index_name_add(git_index *index,
0072     const char *ancestor, const char *ours, const char *theirs);
0073 
0074 /**
0075  * Remove all filename conflict entries.
0076  *
0077  * @param index an existing index object
0078  * @return 0 or an error code
0079  */
0080 GIT_EXTERN(int) git_index_name_clear(git_index *index);
0081 
0082 /**@}*/
0083 
0084 /** @name Resolve Undo (REUC) index entry manipulation.
0085  *
0086  * These functions work on the Resolve Undo index extension and contains
0087  * data about the original files that led to a merge conflict.
0088  */
0089 /**@{*/
0090 
0091 /**
0092  * Get the count of resolve undo entries currently in the index.
0093  *
0094  * @param index an existing index object
0095  * @return integer of count of current resolve undo entries
0096  */
0097 GIT_EXTERN(size_t) git_index_reuc_entrycount(git_index *index);
0098 
0099 /**
0100  * Finds the resolve undo entry that points to the given path in the Git
0101  * index.
0102  *
0103  * @param at_pos the address to which the position of the reuc entry is written (optional)
0104  * @param index an existing index object
0105  * @param path path to search
0106  * @return 0 if found, < 0 otherwise (GIT_ENOTFOUND)
0107  */
0108 GIT_EXTERN(int) git_index_reuc_find(size_t *at_pos, git_index *index, const char *path);
0109 
0110 /**
0111  * Get a resolve undo entry from the index.
0112  *
0113  * The returned entry is read-only and should not be modified
0114  * or freed by the caller.
0115  *
0116  * @param index an existing index object
0117  * @param path path to search
0118  * @return the resolve undo entry; NULL if not found
0119  */
0120 GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_bypath(git_index *index, const char *path);
0121 
0122 /**
0123  * Get a resolve undo entry from the index.
0124  *
0125  * The returned entry is read-only and should not be modified
0126  * or freed by the caller.
0127  *
0128  * @param index an existing index object
0129  * @param n the position of the entry
0130  * @return a pointer to the resolve undo entry; NULL if out of bounds
0131  */
0132 GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_byindex(git_index *index, size_t n);
0133 
0134 /**
0135  * Adds a resolve undo entry for a file based on the given parameters.
0136  *
0137  * The resolve undo entry contains the OIDs of files that were involved
0138  * in a merge conflict after the conflict has been resolved.  This allows
0139  * conflicts to be re-resolved later.
0140  *
0141  * If there exists a resolve undo entry for the given path in the index,
0142  * it will be removed.
0143  *
0144  * This method will fail in bare index instances.
0145  *
0146  * @param index an existing index object
0147  * @param path filename to add
0148  * @param ancestor_mode mode of the ancestor file
0149  * @param ancestor_id oid of the ancestor file
0150  * @param our_mode mode of our file
0151  * @param our_id oid of our file
0152  * @param their_mode mode of their file
0153  * @param their_id oid of their file
0154  * @return 0 or an error code
0155  */
0156 GIT_EXTERN(int) git_index_reuc_add(git_index *index, const char *path,
0157     int ancestor_mode, const git_oid *ancestor_id,
0158     int our_mode, const git_oid *our_id,
0159     int their_mode, const git_oid *their_id);
0160 
0161 /**
0162  * Remove an resolve undo entry from the index
0163  *
0164  * @param index an existing index object
0165  * @param n position of the resolve undo entry to remove
0166  * @return 0 or an error code
0167  */
0168 GIT_EXTERN(int) git_index_reuc_remove(git_index *index, size_t n);
0169 
0170 /**
0171  * Remove all resolve undo entries from the index
0172  *
0173  * @param index an existing index object
0174  * @return 0 or an error code
0175  */
0176 GIT_EXTERN(int) git_index_reuc_clear(git_index *index);
0177 
0178 /**@}*/
0179 
0180 /** @} */
0181 GIT_END_DECL
0182 #endif