X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=wt-status.c;h=7d776f8a9756e9defa3d2b7a2c15217524204e07;hb=be5d88e11280eeeeae5c35711f4a8053b9f862ba;hp=0bccef542fccee5deaa6ee3c740f60879aa97fb3;hpb=7df94cd1f691dd6ccb3038e1b77544030aab3fed;p=thirdparty%2Fgit.git diff --git a/wt-status.c b/wt-status.c index 0bccef542f..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"; @@ -179,9 +181,15 @@ static void wt_longstatus_print_unmerged_header(struct wt_status *s) return; if (s->whence != FROM_COMMIT) ; - else if (!s->is_initial) - status_printf_ln(s, c, _(" (use \"git reset %s ...\" to unstage)"), s->reference); - else + else if (!s->is_initial) { + if (!strcmp(s->reference, "HEAD")) + status_printf_ln(s, c, + _(" (use \"git restore --staged ...\" to unstage)")); + else + status_printf_ln(s, c, + _(" (use \"git restore --source=%s --staged ...\" to unstage)"), + s->reference); + } else status_printf_ln(s, c, _(" (use \"git rm --cached ...\" to unstage)")); if (!both_deleted) { @@ -206,9 +214,15 @@ static void wt_longstatus_print_cached_header(struct wt_status *s) return; if (s->whence != FROM_COMMIT) ; /* NEEDSWORK: use "git reset --unresolve"??? */ - else if (!s->is_initial) - status_printf_ln(s, c, _(" (use \"git reset %s ...\" to unstage)"), s->reference); - else + else if (!s->is_initial) { + if (!strcmp(s->reference, "HEAD")) + status_printf_ln(s, c + , _(" (use \"git restore --staged ...\" to unstage)")); + else + status_printf_ln(s, c, + _(" (use \"git restore --source=%s --staged ...\" to unstage)"), + s->reference); + } else status_printf_ln(s, c, _(" (use \"git rm --cached ...\" to unstage)")); status_printf_ln(s, c, "%s", ""); } @@ -226,7 +240,7 @@ static void wt_longstatus_print_dirty_header(struct wt_status *s, status_printf_ln(s, c, _(" (use \"git add ...\" to update what will be committed)")); else status_printf_ln(s, c, _(" (use \"git add/rm ...\" to update what will be committed)")); - status_printf_ln(s, c, _(" (use \"git checkout -- ...\" to discard changes in working directory)")); + status_printf_ln(s, c, _(" (use \"git restore ...\" to discard changes in working directory)")); if (has_dirty_submodules) status_printf_ln(s, c, _(" (commit or discard the untracked or modified content in submodules)")); status_printf_ln(s, c, "%s", ""); @@ -1085,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; @@ -1676,9 +1705,9 @@ static void wt_longstatus_print(struct wt_status *s) } else if (s->state.detached_from) { branch_name = s->state.detached_from; if (s->state.detached_at) - on_what = _("HEAD detached at "); + on_what = HEAD_DETACHED_AT; else - on_what = _("HEAD detached from "); + on_what = HEAD_DETACHED_FROM; } else { branch_name = ""; on_what = _("Not currently on any branch.");