diff options
author | Jakob Pfender <jpfender@elegosoft.com> | 2011-05-17 15:31:05 +0200 |
---|---|---|
committer | Jakob Pfender <jpfender@elegosoft.com> | 2011-05-17 15:31:05 +0200 |
commit | 050e8877dda969b62f47a180b865a4447785e9c7 (patch) | |
tree | 42ba240edc5f0c0f49e7effe7f8881df2fdca775 /include/git2/index.h | |
parent | e3c7786b22b385d7ec5049c5315c74bd37182e8c (diff) | |
parent | c9662061f25ea51f39018a278b98c9a9b4410e84 (diff) | |
download | libgit2-050e8877dda969b62f47a180b865a4447785e9c7.tar.gz |
Merge branch 'development' into unmerged
Diffstat (limited to 'include/git2/index.h')
-rw-r--r-- | include/git2/index.h | 95 |
1 files changed, 63 insertions, 32 deletions
diff --git a/include/git2/index.h b/include/git2/index.h index 09993a15..2e5c17bc 100644 --- a/include/git2/index.h +++ b/include/git2/index.h @@ -51,39 +51,29 @@ GIT_BEGIN_DECL * * In-memory only flags: */ -#define GIT_IDXENTRY_UPDATE (1 << 16) -#define GIT_IDXENTRY_REMOVE (1 << 17) -#define GIT_IDXENTRY_UPTODATE (1 << 18) -#define GIT_IDXENTRY_ADDED (1 << 19) +#define GIT_IDXENTRY_UPDATE (1 << 0) +#define GIT_IDXENTRY_REMOVE (1 << 1) +#define GIT_IDXENTRY_UPTODATE (1 << 2) +#define GIT_IDXENTRY_ADDED (1 << 3) -#define GIT_IDXENTRY_HASHED (1 << 20) -#define GIT_IDXENTRY_UNHASHED (1 << 21) -#define GIT_IDXENTRY_WT_REMOVE (1 << 22) /* remove in work directory */ -#define GIT_IDXENTRY_CONFLICTED (1 << 23) +#define GIT_IDXENTRY_HASHED (1 << 4) +#define GIT_IDXENTRY_UNHASHED (1 << 5) +#define GIT_IDXENTRY_WT_REMOVE (1 << 6) /* remove in work directory */ +#define GIT_IDXENTRY_CONFLICTED (1 << 7) -#define GIT_IDXENTRY_UNPACKED (1 << 24) -#define GIT_IDXENTRY_NEW_SKIP_WORKTREE (1 << 25) +#define GIT_IDXENTRY_UNPACKED (1 << 8) +#define GIT_IDXENTRY_NEW_SKIP_WORKTREE (1 << 9) /* * Extended on-disk flags: */ -#define GIT_IDXENTRY_INTENT_TO_ADD (1 << 29) -#define GIT_IDXENTRY_SKIP_WORKTREE (1 << 30) +#define GIT_IDXENTRY_INTENT_TO_ADD (1 << 13) +#define GIT_IDXENTRY_SKIP_WORKTREE (1 << 14) /* GIT_IDXENTRY_EXTENDED2 is for future extension */ -#define GIT_IDXENTRY_EXTENDED2 (1 << 31) +#define GIT_IDXENTRY_EXTENDED2 (1 << 15) #define GIT_IDXENTRY_EXTENDED_FLAGS (GIT_IDXENTRY_INTENT_TO_ADD | GIT_IDXENTRY_SKIP_WORKTREE) -/* - * Safeguard to avoid saving wrong flags: - * - GIT_IDXENTRY_EXTENDED2 won't get saved until its semantic is known - * - Bits in 0x0000FFFF have been saved in flags already - * - Bits in 0x003F0000 are currently in-memory flags - */ -#if GIT_IDXENTRY_EXTENDED_FLAGS & 0x803FFFFF -#error "GIT_IDXENTRY_EXTENDED_FLAGS out of range" -#endif - /** Time used in a git index entry */ typedef struct { git_time_t seconds; @@ -188,7 +178,12 @@ GIT_EXTERN(int) git_index_write(git_index *index); GIT_EXTERN(int) git_index_find(git_index *index, const char *path); /** - * Add or update an index entry from a file in disk. + * Add or update an index entry from a file in disk + * + * The file `path` must be relative to the repository's + * working folder and must be readable. + * + * This method will fail in bare index instances. * * @param index an existing index object * @param path filename to add @@ -198,26 +193,62 @@ GIT_EXTERN(int) git_index_find(git_index *index, const char *path); GIT_EXTERN(int) git_index_add(git_index *index, const char *path, int stage); /** - * Remove an entry from the index + * Add or update an index entry from an in-memory struct + * + * A full copy (including the 'path' string) of the given + * 'source_entry' will be inserted on the index. * * @param index an existing index object - * @param position position of the entry to remove + * @param source_entry new entry object * @return 0 on success, otherwise an error code */ -GIT_EXTERN(int) git_index_remove(git_index *index, int position); +GIT_EXTERN(int) git_index_add2(git_index *index, const git_index_entry *source_entry); /** - * Insert an entry into the index. + * Add (append) an index entry from a file in disk + * + * A new entry will always be inserted into the index; + * if the index already contains an entry for such + * path, the old entry will **not** be replaced. + * + * The file `path` must be relative to the repository's + * working folder and must be readable. + * + * This method will fail in bare index instances. + * + * @param index an existing index object + * @param path filename to add + * @param stage stage for the entry + * @return 0 on success, otherwise an error code + */ +GIT_EXTERN(int) git_index_append(git_index *index, const char *path, int stage); + +/** + * Add (append) an index entry from an in-memory struct + * + * A new entry will always be inserted into the index; + * if the index already contains an entry for the path + * in the `entry` struct, the old entry will **not** be + * replaced. + * * A full copy (including the 'path' string) of the given - * 'source_entry' will be inserted on the index; if the index - * already contains an entry for the same path, the entry - * will be updated. + * 'source_entry' will be inserted on the index. * * @param index an existing index object * @param source_entry new entry object * @return 0 on success, otherwise an error code */ -GIT_EXTERN(int) git_index_insert(git_index *index, const git_index_entry *source_entry); +GIT_EXTERN(int) git_index_append2(git_index *index, const git_index_entry *source_entry); + +/** + * Remove an entry from the index + * + * @param index an existing index object + * @param position position of the entry to remove + * @return 0 on success, otherwise an error code + */ +GIT_EXTERN(int) git_index_remove(git_index *index, int position); + /** * Get a pointer to one of the entries in the index |