git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC 03/14] dir: convert directory_exists_in_index to take index

From
BWBrandon Williams <bmwill@google.com>
Date
May 5, 2017, 19:53 UTC
Message-ID
<20170505195334.121856-4-bmwill@google.com>
In-Reply-To
<20170505195334.121856-1-bmwill@google.com>
Signed-off-by: Brandon Williams <bmwill@google.com>
---
 dir.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/dir.c b/dir.c
index 44307b963..5c635198d 100644
--- a/dir.c
+++ b/dir.c
@@ -1264,14 +1264,15 @@ enum exist_status {
  * the directory name; instead, use the case insensitive
  * directory hash.
  */
-static enum exist_status directory_exists_in_index_icase(const char *dirname, int len)
+static enum exist_status directory_exists_in_index_icase(struct index_state *istate,
+							 const char *dirname, int len)
 {
 	struct cache_entry *ce;
 
-	if (index_dir_exists(&the_index, dirname, len))
+	if (index_dir_exists(istate, dirname, len))
 		return index_directory;
 
-	ce = index_file_exists(&the_index, dirname, len, ignore_case);
+	ce = index_file_exists(istate, dirname, len, ignore_case);
 	if (ce && S_ISGITLINK(ce->ce_mode))
 		return index_gitdir;
 
@@ -1285,18 +1286,19 @@ static enum exist_status directory_exists_in_index_icase(const char *dirname, in
  * the files it contains) will sort with the '/' at the
  * end.
  */
-static enum exist_status directory_exists_in_index(const char *dirname, int len)
+static enum exist_status directory_exists_in_index(struct index_state *istate,
+						   const char *dirname, int len)
 {
 	int pos;
 
 	if (ignore_case)
-		return directory_exists_in_index_icase(dirname, len);
+		return directory_exists_in_index_icase(istate, dirname, len);
 
-	pos = index_name_pos(&the_index, dirname, len);
+	pos = index_name_pos(istate, dirname, len);
 	if (pos < 0)
 		pos = -pos-1;
-	while (pos < the_index.cache_nr) {
-		const struct cache_entry *ce = the_index.cache[pos++];
+	while (pos < istate->cache_nr) {
+		const struct cache_entry *ce = istate->cache[pos++];
 		unsigned char endchar;
 
 		if (strncmp(ce->name, dirname, len))
@@ -1351,7 +1353,7 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
 	const struct pathspec *pathspec)
 {
 	/* The "len-1" is to strip the final '/' */
-	switch (directory_exists_in_index(dirname, len-1)) {
+	switch (directory_exists_in_index(&the_index, dirname, len-1)) {
 	case index_directory:
 		return path_recurse;
 
@@ -1554,7 +1556,7 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
 	if ((dir->flags & DIR_COLLECT_KILLED_ONLY) &&
 	    (dtype == DT_DIR) &&
 	    !has_path_in_index &&
-	    (directory_exists_in_index(path->buf, path->len) == index_nonexistent))
+	    (directory_exists_in_index(&the_index, path->buf, path->len) == index_nonexistent))
 		return path_none;
 
 	exclude = is_excluded(dir, path->buf, &dtype);
-- 
2.13.0.rc1.294.g07d810a77f-goog
Previous: Brandon WilliamsNext: Brandon Williams
Message 14 of 18 in “[RFC 00/14] convert dir.c to take an index parameter”
  1. Brandon WilliamsMay 5, 2017
  2. 01/14 dir: stop using the index compatibility macrosBrandon Williams, May 5, 2017
  3. 02/14 dir: convert read_skip_worktree_file_from_index to take an indexBrandon Williams, May 5, 2017
  4. 04/14 dir: convert get_dtype to take indexBrandon Williams, May 5, 2017
  5. 05/14 dir: convert dir_add* to take an indexBrandon Williams, May 5, 2017
  6. 06/14 dir: convert last_exclude_matching_from_list to take an indexBrandon Williams, May 5, 2017
  7. 07/14 dir: convert is_excluded_from_list to take an indexBrandon Williams, May 5, 2017
  8. 12/14 dir: convert read_directory_recursive to take an indexBrandon Williams, May 5, 2017
  9. 14/14 dir: convert fill_directory to take an indexBrandon Williams, May 5, 2017
  10. 13/14 dir: convert read_directory to take an indexBrandon Williams, May 5, 2017
  11. 10/14 dir: convert is_excluded to take an indexBrandon Williams, May 5, 2017
  12. 11/14 dir: convert open_cached_dir to take an indexBrandon Williams, May 5, 2017
  13. 08/14 dir: convert add_excludes to take an indexBrandon Williams, May 5, 2017
  14. 03/14 dir: convert directory_exists_in_index to take indexBrandon Williams, May 5, 2017
  15. 09/14 dir: convert prep_exclude to take an indexBrandon Williams, May 5, 2017
  16. Junio C HamanoMay 6, 2017
  17. Brandon WilliamsMay 8, 2017
  18. Jeff HostetlerMay 8, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.