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.*::
3737 we can still suggest that the user push to either
3838 refs/heads/* or refs/tags/* based on the type of the
3939 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.
4046 statusHints::
4147 Show directions on how to proceed from the current
4248 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;
1212int advice_push_unqualified_ref_name = 1 ;
1313int advice_status_hints = 1 ;
1414int advice_status_u_option = 1 ;
15+ int advice_status_ahead_behind_warning = 1 ;
1516int advice_commit_before_merge = 1 ;
1617int advice_reset_quiet_warning = 1 ;
1718int advice_resolve_conflict = 1 ;
@@ -68,6 +69,7 @@ static struct {
6869 { "pushUnqualifiedRefName" , & advice_push_unqualified_ref_name },
6970 { "statusHints" , & advice_status_hints },
7071 { "statusUoption" , & advice_status_u_option },
72+ { "statusAheadBehindWarning" , & advice_status_ahead_behind_warning },
7173 { "commitBeforeMerge" , & advice_commit_before_merge },
7274 { "resetQuiet" , & advice_reset_quiet_warning },
7375 { "resolveConflict" , & advice_resolve_conflict },
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ extern int advice_push_needs_force;
1212extern int advice_push_unqualified_ref_name ;
1313extern int advice_status_hints ;
1414extern int advice_status_u_option ;
15+ extern int advice_status_ahead_behind_warning ;
1516extern int advice_commit_before_merge ;
1617extern int advice_reset_quiet_warning ;
1718extern int advice_resolve_conflict ;
Original file line number Diff line number Diff line change 1919#include "lockfile.h"
2020#include "sequencer.h"
2121
22+ #define AB_DELAY_WARNING_IN_MS (2 * 1000)
23+
2224static const char cut_line [] =
2325"------------------------ >8 ------------------------\n" ;
2426
@@ -1085,14 +1087,29 @@ static void wt_longstatus_print_tracking(struct wt_status *s)
10851087 struct branch * branch ;
10861088 char comment_line_string [3 ];
10871089 int i ;
1090+ uint64_t t_begin = 0 ;
10881091
10891092 assert (s -> branch && !s -> is_initial );
10901093 if (!skip_prefix (s -> branch , "refs/heads/" , & branch_name ))
10911094 return ;
10921095 branch = branch_get (branch_name );
1096+
1097+ t_begin = getnanotime ();
1098+
10931099 if (!format_tracking_info (branch , & sb , s -> ahead_behind_flags ))
10941100 return ;
10951101
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+
10961113 i = 0 ;
10971114 if (s -> display_comment_prefix ) {
10981115 comment_line_string [i ++ ] = comment_line_char ;
You can’t perform that action at this time.
0 commit comments