diff options
author | Stefan Beller <sbeller@google.com> | 2017-01-18 19:18:51 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-19 12:13:46 -0800 |
commit | 12733e9dd39411be4cd6a9a437faa7d86df159c2 (patch) | |
tree | aec841affc50f4cd71f83aa1f102d260e827683b | |
parent | Almost ready for 2.11.1 (diff) | |
download | tgif-12733e9dd39411be4cd6a9a437faa7d86df159c2.tar.xz |
cache.h: document index_name_pos
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | cache.h | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -575,7 +575,26 @@ extern int verify_path(const char *path); extern int index_dir_exists(struct index_state *istate, const char *name, int namelen); extern void adjust_dirname_case(struct index_state *istate, char *name); extern struct cache_entry *index_file_exists(struct index_state *istate, const char *name, int namelen, int igncase); + +/* + * Searches for an entry defined by name and namelen in the given index. + * If the return value is positive (including 0) it is the position of an + * exact match. If the return value is negative, the negated value minus 1 + * is the position where the entry would be inserted. + * Example: The current index consists of these files and its stages: + * + * b#0, d#0, f#1, f#3 + * + * index_name_pos(&index, "a", 1) -> -1 + * index_name_pos(&index, "b", 1) -> 0 + * index_name_pos(&index, "c", 1) -> -2 + * index_name_pos(&index, "d", 1) -> 1 + * index_name_pos(&index, "e", 1) -> -3 + * index_name_pos(&index, "f", 1) -> -3 + * index_name_pos(&index, "g", 1) -> -5 + */ extern int index_name_pos(const struct index_state *, const char *name, int namelen); + #define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */ #define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */ #define ADD_CACHE_SKIP_DFCHECK 4 /* Ok to skip DF conflict checks */ |