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>
Brandon Williams committed
Jun 12, 2017 at 15:13 UTC
312c984a027f50247501d002fbd228a982f4f096
3 files changed
+12
-9
builtin/commit.c
+2
-1
@@ -253,7 +253,8 @@ static int list_paths(struct string_list *list, const char *with_tree,
253
254
if (with_tree) {
255
char *max_prefix = common_prefix(pattern);
256
- overlay_tree_on_cache(with_tree, max_prefix ? max_prefix : prefix);
256
+ overlay_tree_on_index(&the_index, with_tree,
257
+ max_prefix ? max_prefix : prefix);
258
free(max_prefix);
259
}
260
builtin/ls-files.c
+8
-7
@@ -431,7 +431,8 @@ static int get_common_prefix_len(const char *common_prefix)
431
* that were given from the command line. We are not
432
* going to write this index out.
433
*/
434
-void overlay_tree_on_cache(const char *tree_name, const char *prefix)
434
+void overlay_tree_on_index(struct index_state *istate,
435
+ const char *tree_name, const char *prefix)
436
{
437
struct tree *tree;
438
struct object_id oid;
@@ -446,8 +447,8 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
447
die("bad tree-ish %s", tree_name);
448
449
/* Hoist the unmerged entries up to stage #3 to make room */
449
- for (i = 0; i < active_nr; i++) {
450
- struct cache_entry *ce = active_cache[i];
450
+ for (i = 0; i < istate->cache_nr; i++) {
451
+ struct cache_entry *ce = istate->cache[i];
452
if (!ce_stage(ce))
453
continue;
454
ce->ce_flags |= CE_STAGEMASK;
@@ -460,11 +461,11 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
461
PATHSPEC_PREFER_CWD, prefix, matchbuf);
462
} else
463
memset(&pathspec, 0, sizeof(pathspec));
463
- if (read_tree(tree, 1, &pathspec, &the_index))
464
+ if (read_tree(tree, 1, &pathspec, istate))
465
die("unable to read tree entries %s", tree_name);
466
466
- for (i = 0; i < active_nr; i++) {
467
- struct cache_entry *ce = active_cache[i];
467
+ for (i = 0; i < istate->cache_nr; i++) {
468
+ struct cache_entry *ce = istate->cache[i];
469
switch (ce_stage(ce)) {
470
case 0:
471
last_stage0 = ce;
@@ -679,7 +680,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
680
*/
681
if (show_stage || show_unmerged)
682
die("ls-files --with-tree is incompatible with -s or -u");
682
- overlay_tree_on_cache(with_tree, max_prefix);
683
+ overlay_tree_on_index(&the_index, with_tree, max_prefix);
684
}
685
show_files(&dir);
686
if (show_resolve_undo)
cache.h
+2
-1
@@ -2186,7 +2186,8 @@ extern int ws_blank_line(const char *line, int len, unsigned ws_rule);
2186
#define ws_tab_width(rule) ((rule) & WS_TAB_WIDTH_MASK)
2187
2188
/* ls-files */
2189
-void overlay_tree_on_cache(const char *tree_name, const char *prefix);
2189
+void overlay_tree_on_index(struct index_state *istate,
2190
+ const char *tree_name, const char *prefix);
2191
2192
char *alias_lookup(const char *alias);
2193
int split_cmdline(char *cmdline, const char ***argv);