Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions builtin/read-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
opts.head_idx = -1;
opts.src_index = &the_index;
opts.dst_index = &the_index;
opts.verbose_update = isatty(2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should opts.verbose_update be false if --quiet is specified?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that quiet means something other than "not verbose". This is non-obvious.

The quiet member in struct unpack_trees_options only toggles the output of error messages. This is different than the verbose_update member which toggles the existing progress indicators during the checkout.

Today, if you say git read-tree --verbose --quiet -mu HEAD, then you will still get progress indicators during the "Checking out files" step.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the details here, I couldn't quite figure out what --quiet was controlling.


git_config(git_read_tree_config, NULL);

Expand Down
2 changes: 2 additions & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ static inline unsigned int canon_mode(unsigned int mode)

struct split_index;
struct untracked_cache;
struct progress;

struct index_state {
struct cache_entry **cache;
Expand All @@ -326,6 +327,7 @@ struct index_state {
uint64_t fsmonitor_last_update;
struct ewah_bitmap *fsmonitor_dirty;
struct mem_pool *ce_mem_pool;
struct progress *progress;
};

/* Name hashing */
Expand Down
56 changes: 41 additions & 15 deletions unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,8 @@ static int clear_ce_flags_1(struct index_state *istate,
struct strbuf *prefix,
int select_mask, int clear_mask,
struct pattern_list *pl,
enum pattern_match_result default_match);
enum pattern_match_result default_match,
int progress_nr);

/* Whole directory matching */
static int clear_ce_flags_dir(struct index_state *istate,
Expand All @@ -1296,7 +1297,8 @@ static int clear_ce_flags_dir(struct index_state *istate,
char *basename,
int select_mask, int clear_mask,
struct pattern_list *pl,
enum pattern_match_result default_match)
enum pattern_match_result default_match,
int progress_nr)
{
struct cache_entry **cache_end;
int dtype = DT_DIR;
Expand Down Expand Up @@ -1333,7 +1335,8 @@ static int clear_ce_flags_dir(struct index_state *istate,
rc = clear_ce_flags_1(istate, cache, cache_end - cache,
prefix,
select_mask, clear_mask,
pl, ret);
pl, ret,
progress_nr);
}

strbuf_setlen(prefix, prefix->len - 1);
Expand All @@ -1360,7 +1363,8 @@ static int clear_ce_flags_1(struct index_state *istate,
struct strbuf *prefix,
int select_mask, int clear_mask,
struct pattern_list *pl,
enum pattern_match_result default_match)
enum pattern_match_result default_match,
int progress_nr)
{
struct cache_entry **cache_end = cache + nr;

Expand All @@ -1374,8 +1378,11 @@ static int clear_ce_flags_1(struct index_state *istate,
int len, dtype;
enum pattern_match_result ret;

display_progress(istate->progress, progress_nr);

if (select_mask && !(ce->ce_flags & select_mask)) {
cache++;
progress_nr++;
continue;
}

Expand Down Expand Up @@ -1404,20 +1411,26 @@ static int clear_ce_flags_1(struct index_state *istate,
prefix,
prefix->buf + prefix->len - len,
select_mask, clear_mask,
pl, default_match);
pl, default_match,
progress_nr);

/* clear_c_f_dir eats a whole dir already? */
if (processed) {
cache += processed;
progress_nr += processed;
strbuf_setlen(prefix, prefix->len - len);
continue;
}

strbuf_addch(prefix, '/');
cache += clear_ce_flags_1(istate, cache, cache_end - cache,
prefix,
select_mask, clear_mask, pl,
default_match);
processed = clear_ce_flags_1(istate, cache, cache_end - cache,
prefix,
select_mask, clear_mask, pl,
default_match, progress_nr);

cache += processed;
progress_nr += processed;

strbuf_setlen(prefix, prefix->len - len - 1);
continue;
}
Expand All @@ -1432,19 +1445,27 @@ static int clear_ce_flags_1(struct index_state *istate,
if (ret == MATCHED)
ce->ce_flags &= ~clear_mask;
cache++;
progress_nr++;
}

display_progress(istate->progress, progress_nr);
return nr - (cache_end - cache);
}

static int clear_ce_flags(struct index_state *istate,
int select_mask, int clear_mask,
struct pattern_list *pl)
struct pattern_list *pl,
int show_progress)
{
static struct strbuf prefix = STRBUF_INIT;
char label[100];
int rval;

strbuf_reset(&prefix);
if (show_progress)
istate->progress = start_delayed_progress(
_("Updating index flags"),
istate->cache_nr);

xsnprintf(label, sizeof(label), "clear_ce_flags(0x%08lx,0x%08lx)",
(unsigned long)select_mask, (unsigned long)clear_mask);
Expand All @@ -1454,9 +1475,10 @@ static int clear_ce_flags(struct index_state *istate,
istate->cache_nr,
&prefix,
select_mask, clear_mask,
pl, 0);
pl, 0, 0);
trace2_region_leave("unpack_trees", label, the_repository);

stop_progress(&istate->progress);
return rval;
}

Expand All @@ -1465,7 +1487,8 @@ static int clear_ce_flags(struct index_state *istate,
*/
static void mark_new_skip_worktree(struct pattern_list *pl,
struct index_state *istate,
int select_flag, int skip_wt_flag)
int select_flag, int skip_wt_flag,
int show_progress)
{
int i;

Expand All @@ -1490,7 +1513,7 @@ static void mark_new_skip_worktree(struct pattern_list *pl,
* Matched entries will have skip_wt_flag cleared (i.e. "in")
*/
enable_fscache(istate->cache_nr);
clear_ce_flags(istate, select_flag, skip_wt_flag, pl);
clear_ce_flags(istate, select_flag, skip_wt_flag, pl, show_progress);
disable_fscache();
}

Expand Down Expand Up @@ -1561,7 +1584,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
* Sparse checkout loop #1: set NEW_SKIP_WORKTREE on existing entries
*/
if (!o->skip_sparse_checkout)
mark_new_skip_worktree(o->pl, o->src_index, 0, CE_NEW_SKIP_WORKTREE);
mark_new_skip_worktree(o->pl, o->src_index, 0,
CE_NEW_SKIP_WORKTREE, o->verbose_update);

if (!dfc)
dfc = xcalloc(1, cache_entry_size(0));
Expand Down Expand Up @@ -1628,7 +1652,9 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
* If they will have NEW_SKIP_WORKTREE, also set CE_SKIP_WORKTREE
* so apply_sparse_checkout() won't attempt to remove it from worktree
*/
mark_new_skip_worktree(o->pl, &o->result, CE_ADDED, CE_SKIP_WORKTREE | CE_NEW_SKIP_WORKTREE);
mark_new_skip_worktree(o->pl, &o->result,
CE_ADDED, CE_SKIP_WORKTREE | CE_NEW_SKIP_WORKTREE,
o->verbose_update);

ret = 0;
for (i = 0; i < o->result.cache_nr; i++) {
Expand Down