X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=wt-status.c;h=ad6282c7f86884aab0722457844ed391dbe71059;hb=0253e126a271f10dc1f1fc630193a4026ec8a7ee;hp=d2a1bec226ba0dfef9e3ddd96c0b3a83ea6884bb;hpb=7011ce12b895d172562dcaa7d8b240f3594dc981;p=thirdparty%2Fgit.git diff --git a/wt-status.c b/wt-status.c index d2a1bec226..ad6282c7f8 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) { @@ -194,7 +202,6 @@ static void wt_longstatus_print_unmerged_header(struct wt_status *s) } else { status_printf_ln(s, c, _(" (use \"git add/rm ...\" as appropriate to mark resolution)")); } - status_printf_ln(s, c, "%s", ""); } static void wt_longstatus_print_cached_header(struct wt_status *s) @@ -206,11 +213,16 @@ 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", ""); } static void wt_longstatus_print_dirty_header(struct wt_status *s, @@ -226,10 +238,9 @@ 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", ""); } static void wt_longstatus_print_other_header(struct wt_status *s, @@ -241,7 +252,6 @@ static void wt_longstatus_print_other_header(struct wt_status *s, if (!s->hints) return; status_printf_ln(s, c, _(" (use \"git %s ...\" to include in what will be committed)"), how); - status_printf_ln(s, c, "%s", ""); } static void wt_longstatus_print_trailer(struct wt_status *s) @@ -1085,14 +1095,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; @@ -1408,6 +1433,8 @@ static void show_cherry_pick_in_progress(struct wt_status *s, else status_printf_ln(s, color, _(" (all conflicts fixed: run \"git cherry-pick --continue\")")); + status_printf_ln(s, color, + _(" (use \"git cherry-pick --skip\" to skip this patch)")); status_printf_ln(s, color, _(" (use \"git cherry-pick --abort\" to cancel the cherry-pick operation)")); } @@ -1435,6 +1462,8 @@ static void show_revert_in_progress(struct wt_status *s, else status_printf_ln(s, color, _(" (all conflicts fixed: run \"git revert --continue\")")); + status_printf_ln(s, color, + _(" (use \"git revert --skip\" to skip this patch)")); status_printf_ln(s, color, _(" (use \"git revert --abort\" to cancel the revert operation)")); } @@ -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."); @@ -2076,9 +2105,7 @@ static void wt_porcelain_v2_submodule_state( /* * Fix-up changed entries before we print them. */ -static void wt_porcelain_v2_fix_up_changed( - struct string_list_item *it, - struct wt_status *s) +static void wt_porcelain_v2_fix_up_changed(struct string_list_item *it) { struct wt_status_change_data *d = it->util; @@ -2138,7 +2165,7 @@ static void wt_porcelain_v2_print_changed_entry( char submodule_token[5]; char sep_char, eol_char; - wt_porcelain_v2_fix_up_changed(it, s); + wt_porcelain_v2_fix_up_changed(it); wt_porcelain_v2_submodule_state(d, submodule_token); key[0] = d->index_status ? d->index_status : '.';