Skip to content

Commit fcc7c12

Browse files
avargitster
authored andcommitted
ls-files: don't needlessly pass around stage variable
Now that read_tree() has been moved to ls-files.c we can get rid of the stage != 1 case that'll never happen. Let's not use read_tree_recursive() as a pass-through to pass "stage = 1" either. For now we'll pass an unused "stage = 0" for consistency with other read_tree_recursive() callers, that argument will be removed in a follow-up commit. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eefadd1 commit fcc7c12

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

builtin/ls-files.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ static int read_one_entry_opt(struct index_state *istate,
425425
const struct object_id *oid,
426426
const char *base, int baselen,
427427
const char *pathname,
428-
unsigned mode, int stage, int opt)
428+
unsigned mode, int opt)
429429
{
430430
int len;
431431
struct cache_entry *ce;
@@ -437,7 +437,7 @@ static int read_one_entry_opt(struct index_state *istate,
437437
ce = make_empty_cache_entry(istate, baselen + len);
438438

439439
ce->ce_mode = create_ce_mode(mode);
440-
ce->ce_flags = create_ce_flags(stage);
440+
ce->ce_flags = create_ce_flags(1);
441441
ce->ce_namelen = baselen + len;
442442
memcpy(ce->name, base, baselen);
443443
memcpy(ce->name + baselen, pathname, len+1);
@@ -451,7 +451,7 @@ static int read_one_entry(const struct object_id *oid, struct strbuf *base,
451451
{
452452
struct index_state *istate = context;
453453
return read_one_entry_opt(istate, oid, base->buf, base->len, pathname,
454-
mode, stage,
454+
mode,
455455
ADD_CACHE_OK_TO_ADD|ADD_CACHE_SKIP_DFCHECK);
456456
}
457457

@@ -465,26 +465,17 @@ static int read_one_entry_quick(const struct object_id *oid, struct strbuf *base
465465
{
466466
struct index_state *istate = context;
467467
return read_one_entry_opt(istate, oid, base->buf, base->len, pathname,
468-
mode, stage,
468+
mode,
469469
ADD_CACHE_JUST_APPEND);
470470
}
471471

472472

473-
static int read_tree(struct repository *r, struct tree *tree, int stage,
473+
static int read_tree(struct repository *r, struct tree *tree,
474474
struct pathspec *match, struct index_state *istate)
475475
{
476476
read_tree_fn_t fn = NULL;
477477
int i, err;
478478

479-
/*
480-
* Currently the only existing callers of this function all
481-
* call it with stage=1 and after making sure there is nothing
482-
* at that stage; we could always use read_one_entry_quick().
483-
*
484-
* But when we decide to straighten out git-read-tree not to
485-
* use unpack_trees() in some cases, this will probably start
486-
* to matter.
487-
*/
488479

489480
/*
490481
* See if we have cache entry at the stage. If so,
@@ -493,13 +484,13 @@ static int read_tree(struct repository *r, struct tree *tree, int stage,
493484
*/
494485
for (i = 0; !fn && i < istate->cache_nr; i++) {
495486
const struct cache_entry *ce = istate->cache[i];
496-
if (ce_stage(ce) == stage)
487+
if (ce_stage(ce) == 1)
497488
fn = read_one_entry;
498489
}
499490

500491
if (!fn)
501492
fn = read_one_entry_quick;
502-
err = read_tree_recursive(r, tree, "", 0, stage, match, fn, istate);
493+
err = read_tree_recursive(r, tree, "", 0, 0, match, fn, istate);
503494
if (fn == read_one_entry || err)
504495
return err;
505496

@@ -549,7 +540,7 @@ void overlay_tree_on_index(struct index_state *istate,
549540
PATHSPEC_PREFER_CWD, prefix, matchbuf);
550541
} else
551542
memset(&pathspec, 0, sizeof(pathspec));
552-
if (read_tree(the_repository, tree, 1, &pathspec, istate))
543+
if (read_tree(the_repository, tree, &pathspec, istate))
553544
die("unable to read tree entries %s", tree_name);
554545

555546
for (i = 0; i < istate->cache_nr; i++) {

0 commit comments

Comments
 (0)