summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2017-06-12 15:13:58 -0700
committerJunio C Hamano <gitster@pobox.com>2017-06-13 11:40:51 -0700
commit312c984a027f50247501d002fbd228a982f4f096 (patch)
tree6cbf964ae278ded69605c1813fc94a5b9cb06a24
parent85ab50f938601cf874c841cee4c56f1d1dc8199e (diff)
downloadgit-312c984a027f50247501d002fbd228a982f4f096.tar.gz
ls-files: convert overlay_tree_on_cache to take an index
Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/commit.c3
-rw-r--r--builtin/ls-files.c15
-rw-r--r--cache.h3
3 files changed, 12 insertions, 9 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index da1ba4c862..78ef319a24 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 93e46ab5fb..a78b291abd 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;
struct object_id oid;
@@ -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 4d92aae0e8..5a0e0a9e5d 100644
--- a/cache.h
+++ b/cache.h
@@ -2186,7 +2186,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);