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

[PATCH 09/17] ls-files: convert show_killed_files to take an index

From
BWBrandon Williams <bmwill@google.com>
Date
Jun 12, 2017, 22:14 UTC
Message-ID
<20170612221408.173876-10-bmwill@google.com>
In-Reply-To
<20170612221408.173876-1-bmwill@google.com>
Signed-off-by: Brandon Williams <bmwill@google.com>
---
 builtin/ls-files.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 8c3f3d8ca..b82b78036 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -120,7 +120,8 @@ static void show_other_files(struct dir_struct *dir)
 	}
 }
 
-static void show_killed_files(struct dir_struct *dir)
+static void show_killed_files(const struct index_state *istate,
+			      const struct dir_struct *dir)
 {
 	int i;
 	for (i = 0; i < dir->nr; i++) {
@@ -134,29 +135,29 @@ static void show_killed_files(struct dir_struct *dir)
 				/* If ent->name is prefix of an entry in the
 				 * cache, it will be killed.
 				 */
-				pos = cache_name_pos(ent->name, ent->len);
+				pos = index_name_pos(istate, ent->name, ent->len);
 				if (0 <= pos)
 					die("BUG: killed-file %.*s not found",
 						ent->len, ent->name);
 				pos = -pos - 1;
-				while (pos < active_nr &&
-				       ce_stage(active_cache[pos]))
+				while (pos < istate->cache_nr &&
+				       ce_stage(istate->cache[pos]))
 					pos++; /* skip unmerged */
-				if (active_nr <= pos)
+				if (istate->cache_nr <= pos)
 					break;
 				/* pos points at a name immediately after
 				 * ent->name in the cache.  Does it expect
 				 * ent->name to be a directory?
 				 */
-				len = ce_namelen(active_cache[pos]);
+				len = ce_namelen(istate->cache[pos]);
 				if ((ent->len < len) &&
-				    !strncmp(active_cache[pos]->name,
+				    !strncmp(istate->cache[pos]->name,
 					     ent->name, ent->len) &&
-				    active_cache[pos]->name[ent->len] == '/')
+				    istate->cache[pos]->name[ent->len] == '/')
 					killed = 1;
 				break;
 			}
-			if (0 <= cache_name_pos(ent->name, sp - ent->name)) {
+			if (0 <= index_name_pos(istate, ent->name, sp - ent->name)) {
 				/* If any of the leading directories in
 				 * ent->name is registered in the cache,
 				 * ent->name will be killed.
@@ -337,7 +338,7 @@ static void show_files(struct dir_struct *dir)
 		if (show_others)
 			show_other_files(dir);
 		if (show_killed)
-			show_killed_files(dir);
+			show_killed_files(&the_index, dir);
 	}
 	if (show_cached || show_stage) {
 		for (i = 0; i < active_nr; i++) {
-- 
2.13.1.518.g3df882009-goog
Previous: Brandon WilliamsNext: Brandon Williams
Message 12 of 18 in “convert ls-files internals to pass around an index”
  1. 00/17 convert ls-files internals to pass around an indexBrandon Williams, Jun 12, 2017
  2. 01/17 convert: convert get_cached_convert_stats_ascii to take an indexBrandon Williams, Jun 12, 2017
  3. 02/17 convert: convert crlf_to_git to take an indexBrandon Williams, Jun 12, 2017
  4. 03/17 convert: convert convert_to_git_filter_fd to take an indexBrandon Williams, Jun 12, 2017
  5. 04/17 convert: convert convert_to_git to take an indexBrandon Williams, Jun 12, 2017
  6. 07/17 ls-files: convert overlay_tree_on_cache to take an indexBrandon Williams, Jun 12, 2017
  7. 14/17 ls-files: convert show_ce_entry to take an indexBrandon Williams, Jun 12, 2017
  8. 13/17 ls-files: convert prune_cache to take an indexBrandon Williams, Jun 12, 2017
  9. 17/17 ls-files: factor out tag calculationBrandon Williams, Jun 12, 2017
  10. 12/17 ls-files: convert ce_excluded to take an indexBrandon Williams, Jun 12, 2017
  11. 15/17 ls-files: convert show_files to take an indexBrandon Williams, Jun 12, 2017
  12. 09/17 ls-files: convert show_killed_files to take an indexBrandon Williams, Jun 12, 2017
  13. 16/17 ls-files: factor out debug info into a functionBrandon Williams, Jun 12, 2017
  14. 10/17 ls-files: convert show_other_files to take an indexBrandon Williams, Jun 12, 2017
  15. 05/17 convert: convert renormalize_buffer to take an indexBrandon Williams, Jun 12, 2017
  16. 08/17 ls-files: convert write_eolinfo to take an indexBrandon Williams, Jun 12, 2017
  17. 06/17 tree: convert read_tree to take an index parameterBrandon Williams, Jun 12, 2017
  18. 11/17 ls-files: convert show_ru_info to take an indexBrandon Williams, Jun 12, 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.