From: Junio C Hamano Date: Fri, 19 Oct 2018 04:34:03 +0000 (+0900) Subject: Merge branch 'nd/status-refresh-progress' X-Git-Tag: v2.20.0-rc0~160 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/4d87b38e6c1a73dbe744a30b9b3cdf88e69de7b4 Merge branch 'nd/status-refresh-progress' "git status" learns to show progress bar when refreshing the index takes a long time. * nd/status-refresh-progress: status: show progress bar if refreshing the index takes too long --- 4d87b38e6c1a73dbe744a30b9b3cdf88e69de7b4 diff --cc preload-index.c index 16dc5ad868,2541b307e8..9e7152ab14 --- a/preload-index.c +++ b/preload-index.c @@@ -5,7 -5,7 +5,8 @@@ #include "pathspec.h" #include "dir.h" #include "fsmonitor.h" +#include "config.h" + #include "progress.h" #ifdef NO_PTHREADS static void preload_index(struct index_state *index, @@@ -79,6 -105,8 +106,7 @@@ static void preload_index(struct index_ { int threads, i, work, offset; struct thread_data data[MAX_PARALLEL]; - uint64_t start = getnanotime(); + struct progress_data pd; if (!core_preload_index) return; @@@ -110,7 -146,9 +147,9 @@@ if (pthread_join(p->pthread, NULL)) die("unable to join threaded lstat"); } + stop_progress(&pd.progress); + - trace_performance_since(start, "preload index"); + trace_performance_leave("preload index"); } #endif diff --cc read-cache.c index 4c994e4b65,5969ca93c7..1df5c16dbc --- a/read-cache.c +++ b/read-cache.c @@@ -23,7 -23,7 +23,8 @@@ #include "split-index.h" #include "utf8.h" #include "fsmonitor.h" +#include "thread-utils.h" + #include "progress.h" /* Mask for the name length in ce_flags in the on-disk index */ @@@ -1483,8 -1477,13 +1484,13 @@@ int refresh_index(struct index_state *i const char *typechange_fmt; const char *added_fmt; const char *unmerged_fmt; - uint64_t start = getnanotime(); + struct progress *progress = NULL; + + if (flags & REFRESH_PROGRESS && isatty(2)) + progress = start_delayed_progress(_("Refresh index"), + istate->cache_nr); + trace_performance_enter(); modified_fmt = (in_porcelain ? "M\t%s\n" : "%s: needs update\n"); deleted_fmt = (in_porcelain ? "D\t%s\n" : "%s: needs update\n"); typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n"); @@@ -1554,7 -1555,11 +1562,11 @@@ replace_index_entry(istate, i, new_entry); } + if (progress) { + display_progress(progress, istate->cache_nr); + stop_progress(&progress); + } - trace_performance_since(start, "refresh index"); + trace_performance_leave("refresh index"); return has_errors; }