Skip to content

Commit 1ac2ec6

Browse files
committed
Merge branch 'sb/in-core-index-doc' into maint
Documentation and in-code comments updates. * sb/in-core-index-doc: documentation: retire unfinished documentation cache.h: document add_[file_]to_index cache.h: document remove_index_entry_at cache.h: document index_name_pos
2 parents 6a7e25d + 830c912 commit 1ac2ec6

File tree

3 files changed

+32
-22
lines changed

3 files changed

+32
-22
lines changed

Documentation/technical/api-in-core-index.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

cache.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,26 @@ extern int verify_path(const char *path);
575575
extern int index_dir_exists(struct index_state *istate, const char *name, int namelen);
576576
extern void adjust_dirname_case(struct index_state *istate, char *name);
577577
extern struct cache_entry *index_file_exists(struct index_state *istate, const char *name, int namelen, int igncase);
578+
579+
/*
580+
* Searches for an entry defined by name and namelen in the given index.
581+
* If the return value is positive (including 0) it is the position of an
582+
* exact match. If the return value is negative, the negated value minus 1
583+
* is the position where the entry would be inserted.
584+
* Example: The current index consists of these files and its stages:
585+
*
586+
* b#0, d#0, f#1, f#3
587+
*
588+
* index_name_pos(&index, "a", 1) -> -1
589+
* index_name_pos(&index, "b", 1) -> 0
590+
* index_name_pos(&index, "c", 1) -> -2
591+
* index_name_pos(&index, "d", 1) -> 1
592+
* index_name_pos(&index, "e", 1) -> -3
593+
* index_name_pos(&index, "f", 1) -> -3
594+
* index_name_pos(&index, "g", 1) -> -5
595+
*/
578596
extern int index_name_pos(const struct index_state *, const char *name, int namelen);
597+
579598
#define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */
580599
#define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */
581600
#define ADD_CACHE_SKIP_DFCHECK 4 /* Ok to skip DF conflict checks */
@@ -584,16 +603,29 @@ extern int index_name_pos(const struct index_state *, const char *name, int name
584603
#define ADD_CACHE_KEEP_CACHE_TREE 32 /* Do not invalidate cache-tree */
585604
extern int add_index_entry(struct index_state *, struct cache_entry *ce, int option);
586605
extern void rename_index_entry_at(struct index_state *, int pos, const char *new_name);
606+
607+
/* Remove entry, return true if there are more entries to go. */
587608
extern int remove_index_entry_at(struct index_state *, int pos);
609+
588610
extern void remove_marked_cache_entries(struct index_state *istate);
589611
extern int remove_file_from_index(struct index_state *, const char *path);
590612
#define ADD_CACHE_VERBOSE 1
591613
#define ADD_CACHE_PRETEND 2
592614
#define ADD_CACHE_IGNORE_ERRORS 4
593615
#define ADD_CACHE_IGNORE_REMOVAL 8
594616
#define ADD_CACHE_INTENT 16
617+
/*
618+
* These two are used to add the contents of the file at path
619+
* to the index, marking the working tree up-to-date by storing
620+
* the cached stat info in the resulting cache entry. A caller
621+
* that has already run lstat(2) on the path can call
622+
* add_to_index(), and all others can call add_file_to_index();
623+
* the latter will do necessary lstat(2) internally before
624+
* calling the former.
625+
*/
595626
extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags);
596627
extern int add_file_to_index(struct index_state *, const char *path, int flags);
628+
597629
extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, unsigned int refresh_options);
598630
extern int chmod_index_entry(struct index_state *, struct cache_entry *ce, char flip);
599631
extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);

read-cache.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ int index_name_pos(const struct index_state *istate, const char *name, int namel
510510
return index_name_stage_pos(istate, name, namelen, 0);
511511
}
512512

513-
/* Remove entry, return true if there are more entries to go.. */
514513
int remove_index_entry_at(struct index_state *istate, int pos)
515514
{
516515
struct cache_entry *ce = istate->cache[pos];

0 commit comments

Comments
 (0)