Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c57
1 files changed, 40 insertions, 17 deletions
diff --git a/wt-status.c b/wt-status.c
index d2a1bec226..9f6c65a580 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 <file>...\" to unstage)"), s->reference);
- else
+ else if (!s->is_initial) {
+ if (!strcmp(s->reference, "HEAD"))
+ status_printf_ln(s, c,
+ _(" (use \"git restore --staged <file>...\" to unstage)"));
+ else
+ status_printf_ln(s, c,
+ _(" (use \"git restore --source=%s --staged <file>...\" to unstage)"),
+ s->reference);
+ } else
status_printf_ln(s, c, _(" (use \"git rm --cached <file>...\" 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 <file>...\" 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 <file>...\" to unstage)"), s->reference);
- else
+ else if (!s->is_initial) {
+ if (!strcmp(s->reference, "HEAD"))
+ status_printf_ln(s, c
+ , _(" (use \"git restore --staged <file>...\" to unstage)"));
+ else
+ status_printf_ln(s, c,
+ _(" (use \"git restore --source=%s --staged <file>...\" to unstage)"),
+ s->reference);
+ } else
status_printf_ln(s, c, _(" (use \"git rm --cached <file>...\" 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 <file>...\" to update what will be committed)"));
else
status_printf_ln(s, c, _(" (use \"git add/rm <file>...\" to update what will be committed)"));
- status_printf_ln(s, c, _(" (use \"git checkout -- <file>...\" to discard changes in working directory)"));
+ status_printf_ln(s, c, _(" (use \"git restore <file>...\" 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 <file>...\" 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;
@@ -1676,9 +1701,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 +2101,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 +2161,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 : '.';