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

[WIP/RFC 07/23] ls-files: convert overlay_tree_on_cache to take an index

From
BWBrandon Williams <bmwill@google.com>
Date
May 18, 2017, 23:21 UTC
Message-ID
<20170518232134.163059-8-bmwill@google.com>
In-Reply-To
<20170518232134.163059-1-bmwill@google.com>
Signed-off-by: Brandon Williams <bmwill@google.com>
---
 builtin/commit.c   |  3 ++-
 builtin/ls-files.c | 15 ++++++++-------
 cache.h            |  3 ++-
 3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index 1d805f5da..38993bd24 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -253,7 +253,8 @@ static int list_paths(struct string_list *list, const char *with_tree,
 
 	if (with_tree) {
 		char *max_prefix = common_prefix(pattern);
-		overlay_tree_on_cache(with_tree, max_prefix ? max_prefix : prefix);
+		overlay_tree_on_index(&the_index, with_tree,
+				      max_prefix ? max_prefix : prefix);
 		free(max_prefix);
 	}
 
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index a4ced5a9c..7d306f418 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -431,7 +431,8 @@ static int get_common_prefix_len(const char *common_prefix)
  * that were given from the command line.  We are not
  * going to write this index out.
  */
-void overlay_tree_on_cache(const char *tree_name, const char *prefix)
+void overlay_tree_on_index(struct index_state *istate,
+			   const char *tree_name, const char *prefix)
 {
 	struct tree *tree;
 	unsigned char sha1[20];
@@ -446,8 +447,8 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
 		die("bad tree-ish %s", tree_name);
 
 	/* Hoist the unmerged entries up to stage #3 to make room */
-	for (i = 0; i < active_nr; i++) {
-		struct cache_entry *ce = active_cache[i];
+	for (i = 0; i < istate->cache_nr; i++) {
+		struct cache_entry *ce = istate->cache[i];
 		if (!ce_stage(ce))
 			continue;
 		ce->ce_flags |= CE_STAGEMASK;
@@ -460,11 +461,11 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
 			       PATHSPEC_PREFER_CWD, prefix, matchbuf);
 	} else
 		memset(&pathspec, 0, sizeof(pathspec));
-	if (read_tree(tree, 1, &pathspec, &the_index))
+	if (read_tree(tree, 1, &pathspec, istate))
 		die("unable to read tree entries %s", tree_name);
 
-	for (i = 0; i < active_nr; i++) {
-		struct cache_entry *ce = active_cache[i];
+	for (i = 0; i < istate->cache_nr; i++) {
+		struct cache_entry *ce = istate->cache[i];
 		switch (ce_stage(ce)) {
 		case 0:
 			last_stage0 = ce;
@@ -679,7 +680,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
 		 */
 		if (show_stage || show_unmerged)
 			die("ls-files --with-tree is incompatible with -s or -u");
-		overlay_tree_on_cache(with_tree, max_prefix);
+		overlay_tree_on_index(&the_index, with_tree, max_prefix);
 	}
 	show_files(&dir);
 	if (show_resolve_undo)
diff --git a/cache.h b/cache.h
index e1f0e182a..175e58f01 100644
--- a/cache.h
+++ b/cache.h
@@ -2179,7 +2179,8 @@ extern int ws_blank_line(const char *line, int len, unsigned ws_rule);
 #define ws_tab_width(rule)     ((rule) & WS_TAB_WIDTH_MASK)
 
 /* ls-files */
-void overlay_tree_on_cache(const char *tree_name, const char *prefix);
+void overlay_tree_on_index(struct index_state *istate,
+			   const char *tree_name, const char *prefix);
 
 char *alias_lookup(const char *alias);
 int split_cmdline(char *cmdline, const char ***argv);
-- 
2.13.0.303.g4ebf302169-goog
Previous: Brandon WilliamsNext: Brandon Williams
Message 14 of 41 in “[WIP/RFC 00/23] repository object”
  1. Brandon WilliamsMay 18, 2017
  2. 02/23 convert: convert crlf_to_git to take an indexBrandon Williams, May 18, 2017
  3. 03/23 convert: convert convert_to_git_filter_fd to take an indexBrandon Williams, May 18, 2017
  4. 01/23 convert: convert get_cached_convert_stats_ascii to take an indexBrandon Williams, May 18, 2017
  5. 04/23 convert: convert convert_to_git to take an indexBrandon Williams, May 18, 2017
  6. 10/23 ls-files: convert show_other_files to take an indexBrandon Williams, May 18, 2017
  7. 11/23 ls-files: convert show_ru_info to take an indexBrandon Williams, May 18, 2017
  8. 06/23 tree: convert read_tree to take an index parameterBrandon Williams, May 18, 2017
  9. 14/23 ls-files: convert show_files to take an indexBrandon Williams, May 18, 2017
  10. 05/23 convert: convert renormalize_buffer to take an indexBrandon Williams, May 18, 2017
  11. 12/23 ls-files: convert ce_excluded to take an indexBrandon Williams, May 18, 2017
  12. 15/23 ls-files: factor out debug info into a functionBrandon Williams, May 18, 2017
  13. 08/23 ls-files: convert write_eolinfo to take an indexBrandon Williams, May 18, 2017
  14. 07/23 ls-files: convert overlay_tree_on_cache to take an indexBrandon Williams, May 18, 2017
  15. 09/23 ls-files: convert show_killed_files to take an indexBrandon Williams, May 18, 2017
  16. 16/23 ls-files: factor out tag calculationBrandon Williams, May 18, 2017
  17. 20/23 submodule-config: refactor to allow for multiple submodule_cache'sBrandon Williams, May 18, 2017
  18. 19/23 repo: add per repo configBrandon Williams, May 18, 2017
  19. 22/23 submodule: add is_submodule_activeBrandon Williams, May 18, 2017
  20. 21/23 repo: add repo_read_gitmodulesBrandon Williams, May 18, 2017
  21. 18/23 repo: add index_state to struct repoBrandon Williams, May 18, 2017
  22. Stefan BellerMay 20, 2017
  23. 17/23 repo: introduce new repository objectBrandon Williams, May 18, 2017
  24. Stefan BellerMay 20, 2017
  25. Brandon WilliamsMay 23, 2017
  26. 13/23 ls-files: convert prune_cache to take an indexBrandon Williams, May 18, 2017
  27. 23/23 ls-files: use repository objectBrandon Williams, May 18, 2017
  28. Jeff HostetlerMay 19, 2017
  29. Ben PeartMay 19, 2017
  30. Brandon WilliamsMay 23, 2017
  31. Stefan BellerMay 20, 2017
  32. Johannes SchindelinMay 22, 2017
  33. Jacob KellerMay 21, 2017
  34. brian m. carlsonMay 21, 2017
  35. Jeff KingMay 22, 2017
  36. Brandon WilliamsMay 23, 2017
  37. Junio C HamanoMay 24, 2017
  38. Duy NguyenMay 29, 2017
  39. Ævar Arnfjörð BjarmasonMay 29, 2017
  40. Duy NguyenMay 29, 2017
  41. Brandon WilliamsMay 30, 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.