File tree Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,12 @@ advice.*::
37
37
we can still suggest that the user push to either
38
38
refs/heads/* or refs/tags/* based on the type of the
39
39
source object.
40
+ statusAheadBehind::
41
+ Shown when linkgit:git-status[1] computes the ahead/behind
42
+ counts for a local ref compared to its remote tracking ref,
43
+ and that calculation takes longer than expected. Will not
44
+ appear if `status.aheadBehind` is false or the option
45
+ `--no-ahead-behind` is given.
40
46
statusHints::
41
47
Show directions on how to proceed from the current
42
48
state in the output of linkgit:git-status[1], in
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ int advice_push_needs_force = 1;
12
12
int advice_push_unqualified_ref_name = 1 ;
13
13
int advice_status_hints = 1 ;
14
14
int advice_status_u_option = 1 ;
15
+ int advice_status_ahead_behind_warning = 1 ;
15
16
int advice_commit_before_merge = 1 ;
16
17
int advice_reset_quiet_warning = 1 ;
17
18
int advice_resolve_conflict = 1 ;
@@ -68,6 +69,7 @@ static struct {
68
69
{ "pushUnqualifiedRefName" , & advice_push_unqualified_ref_name },
69
70
{ "statusHints" , & advice_status_hints },
70
71
{ "statusUoption" , & advice_status_u_option },
72
+ { "statusAheadBehindWarning" , & advice_status_ahead_behind_warning },
71
73
{ "commitBeforeMerge" , & advice_commit_before_merge },
72
74
{ "resetQuiet" , & advice_reset_quiet_warning },
73
75
{ "resolveConflict" , & advice_resolve_conflict },
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ extern int advice_push_needs_force;
12
12
extern int advice_push_unqualified_ref_name ;
13
13
extern int advice_status_hints ;
14
14
extern int advice_status_u_option ;
15
+ extern int advice_status_ahead_behind_warning ;
15
16
extern int advice_commit_before_merge ;
16
17
extern int advice_reset_quiet_warning ;
17
18
extern int advice_resolve_conflict ;
Original file line number Diff line number Diff line change 19
19
#include "lockfile.h"
20
20
#include "sequencer.h"
21
21
22
+ #define AB_DELAY_WARNING_IN_MS (2 * 1000)
23
+
22
24
static const char cut_line [] =
23
25
"------------------------ >8 ------------------------\n" ;
24
26
@@ -1085,14 +1087,29 @@ static void wt_longstatus_print_tracking(struct wt_status *s)
1085
1087
struct branch * branch ;
1086
1088
char comment_line_string [3 ];
1087
1089
int i ;
1090
+ uint64_t t_begin = 0 ;
1088
1091
1089
1092
assert (s -> branch && !s -> is_initial );
1090
1093
if (!skip_prefix (s -> branch , "refs/heads/" , & branch_name ))
1091
1094
return ;
1092
1095
branch = branch_get (branch_name );
1096
+
1097
+ t_begin = getnanotime ();
1098
+
1093
1099
if (!format_tracking_info (branch , & sb , s -> ahead_behind_flags ))
1094
1100
return ;
1095
1101
1102
+ if (advice_status_ahead_behind_warning &&
1103
+ s -> ahead_behind_flags == AHEAD_BEHIND_FULL ) {
1104
+ uint64_t t_delta_in_ms = (getnanotime () - t_begin ) / 1000000 ;
1105
+ if (t_delta_in_ms > AB_DELAY_WARNING_IN_MS ) {
1106
+ strbuf_addf (& sb , _ ("\n"
1107
+ "It took %.2f seconds to compute the branch ahead/behind values.\n"
1108
+ "You can use '--no-ahead-behind' to avoid this.\n" ),
1109
+ t_delta_in_ms / 1000.0 );
1110
+ }
1111
+ }
1112
+
1096
1113
i = 0 ;
1097
1114
if (s -> display_comment_prefix ) {
1098
1115
comment_line_string [i ++ ] = comment_line_char ;
You can’t perform that action at this time.
0 commit comments