diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-03-21 14:02:10 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-03-21 14:02:10 -0700 |
commit | 5d04924e1914a0c63b6467b8cb7194bf68c003cb (patch) | |
tree | 8b25ce5850f7ec792c6c69972584eec2f9062174 /wt-status.c | |
parent | 03da85b954507749af01545888a20b7643761d58 (diff) | |
parent | 6a38ef2ced55f0a8a7967581934e40f79e1d8733 (diff) | |
download | git-5d04924e1914a0c63b6467b8cb7194bf68c003cb.tar.gz |
Merge branch 'tb/document-status-u-tradeoff'
Suggest users to look into using--untracked=no option when "git
status" takes too long.
* tb/document-status-u-tradeoff:
status: advise to consider use of -u when read_directory takes too long
git status: document trade-offs in choosing parameters to the -u option
Diffstat (limited to 'wt-status.c')
-rw-r--r-- | wt-status.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/wt-status.c b/wt-status.c index ef405d03d9..7bb3f63f06 100644 --- a/wt-status.c +++ b/wt-status.c @@ -496,9 +496,14 @@ static void wt_status_collect_untracked(struct wt_status *s) { int i; struct dir_struct dir; + struct timeval t_begin; if (!s->show_untracked_files) return; + + if (advice_status_u_option) + gettimeofday(&t_begin, NULL); + memset(&dir, 0, sizeof(dir)); if (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES) dir.flags |= @@ -530,6 +535,14 @@ static void wt_status_collect_untracked(struct wt_status *s) } free(dir.entries); + + if (advice_status_u_option) { + struct timeval t_end; + gettimeofday(&t_end, NULL); + s->untracked_in_ms = + (uint64_t)t_end.tv_sec * 1000 + t_end.tv_usec / 1000 - + ((uint64_t)t_begin.tv_sec * 1000 + t_begin.tv_usec / 1000); + } } void wt_status_collect(struct wt_status *s) @@ -1097,6 +1110,18 @@ void wt_status_print(struct wt_status *s) wt_status_print_other(s, &s->untracked, _("Untracked files"), "add"); if (s->show_ignored_files) wt_status_print_other(s, &s->ignored, _("Ignored files"), "add -f"); + if (advice_status_u_option && 2000 < s->untracked_in_ms) { + status_printf_ln(s, GIT_COLOR_NORMAL, ""); + status_printf_ln(s, GIT_COLOR_NORMAL, + _("It took %.2f seconds to enumerate untracked files." + " 'status -uno'"), + s->untracked_in_ms / 1000.0); + status_printf_ln(s, GIT_COLOR_NORMAL, + _("may speed it up, but you have to be careful not" + " to forget to add")); + status_printf_ln(s, GIT_COLOR_NORMAL, + _("new files yourself (see 'git help status').")); + } } else if (s->commitable) status_printf_ln(s, GIT_COLOR_NORMAL, _("Untracked files not listed%s"), advice_status_hints |