diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-07-10 01:25:46 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-07-10 01:25:46 +0300 |
commit | 34186225b3ca3109586fd63ee83aeea342dc668e (patch) | |
tree | 826261c151c2a760c2aebaa7a681eff170c32352 /wt-status.c | |
parent | 2fff5094426c783ddedb79de588eb85647baa8f0 (diff) | |
parent | fb4db1a298b75536a861485bda27e3f1e098d6f6 (diff) |
Merge branch 'jh/status-aheadbehind'
"git status" can be told a non-standard default value for the
"--[no-]ahead-behind" option with a new configuration variable
status.aheadBehind.
* jh/status-aheadbehind:
status: ignore status.aheadbehind in porcelain formats
status: warn when a/b calculation takes too long
status: add status.aheadbehind setting
Diffstat (limited to 'wt-status.c')
-rw-r--r-- | wt-status.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/wt-status.c b/wt-status.c index dd5270647e..7d776f8a97 100644 --- a/wt-status.c +++ b/wt-status.c @@ -19,6 +19,8 @@ #include "lockfile.h" #include "sequencer.h" +#define AB_DELAY_WARNING_IN_MS (2 * 1000) + static const char cut_line[] = "------------------------ >8 ------------------------\n"; @@ -1097,14 +1099,29 @@ static void wt_longstatus_print_tracking(struct wt_status *s) struct branch *branch; char comment_line_string[3]; int i; + uint64_t t_begin = 0; assert(s->branch && !s->is_initial); if (!skip_prefix(s->branch, "refs/heads/", &branch_name)) return; branch = branch_get(branch_name); + + t_begin = getnanotime(); + if (!format_tracking_info(branch, &sb, s->ahead_behind_flags)) return; + if (advice_status_ahead_behind_warning && + s->ahead_behind_flags == AHEAD_BEHIND_FULL) { + uint64_t t_delta_in_ms = (getnanotime() - t_begin) / 1000000; + if (t_delta_in_ms > AB_DELAY_WARNING_IN_MS) { + strbuf_addf(&sb, _("\n" + "It took %.2f seconds to compute the branch ahead/behind values.\n" + "You can use '--no-ahead-behind' to avoid this.\n"), + t_delta_in_ms / 1000.0); + } + } + i = 0; if (s->display_comment_prefix) { comment_line_string[i++] = comment_line_char; |