@@ -575,7 +575,26 @@ extern int verify_path(const char *path);
575
575
extern int index_dir_exists (struct index_state * istate , const char * name , int namelen );
576
576
extern void adjust_dirname_case (struct index_state * istate , char * name );
577
577
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
+ */
578
596
extern int index_name_pos (const struct index_state * , const char * name , int namelen );
597
+
579
598
#define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */
580
599
#define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */
581
600
#define ADD_CACHE_SKIP_DFCHECK 4 /* Ok to skip DF conflict checks */
0 commit comments