44#include "help.h"
55#include "string-list.h"
66
7- int advice_fetch_show_forced_updates = 1 ;
8- int advice_push_update_rejected = 1 ;
9- int advice_push_non_ff_current = 1 ;
10- int advice_push_non_ff_matching = 1 ;
11- int advice_push_already_exists = 1 ;
12- int advice_push_fetch_first = 1 ;
13- int advice_push_needs_force = 1 ;
14- int advice_push_unqualified_ref_name = 1 ;
15- int advice_push_ref_needs_update = 1 ;
16- int advice_status_hints = 1 ;
17- int advice_status_u_option = 1 ;
18- int advice_status_ahead_behind_warning = 1 ;
19- int advice_commit_before_merge = 1 ;
20- int advice_reset_quiet_warning = 1 ;
21- int advice_resolve_conflict = 1 ;
22- int advice_sequencer_in_use = 1 ;
23- int advice_implicit_identity = 1 ;
24- int advice_detached_head = 1 ;
25- int advice_set_upstream_failure = 1 ;
26- int advice_object_name_warning = 1 ;
27- int advice_amworkdir = 1 ;
28- int advice_rm_hints = 1 ;
29- int advice_add_embedded_repo = 1 ;
30- int advice_ignored_hook = 1 ;
31- int advice_waiting_for_editor = 1 ;
32- int advice_graft_file_deprecated = 1 ;
33- int advice_checkout_ambiguous_remote_branch_name = 1 ;
34- int advice_submodule_alternate_error_strategy_die = 1 ;
35- int advice_add_ignored_file = 1 ;
36- int advice_add_empty_pathspec = 1 ;
37- int advice_skipped_cherry_picks = 1 ;
38-
397static int advice_use_color = -1 ;
408static char advice_colors [][COLOR_MAXLEN ] = {
419 GIT_COLOR_RESET ,
@@ -63,51 +31,13 @@ static const char *advise_get_color(enum color_advice ix)
6331 return "" ;
6432}
6533
66- static struct {
67- const char * name ;
68- int * preference ;
69- } advice_config [] = {
70- { "fetchShowForcedUpdates" , & advice_fetch_show_forced_updates },
71- { "pushUpdateRejected" , & advice_push_update_rejected },
72- { "pushNonFFCurrent" , & advice_push_non_ff_current },
73- { "pushNonFFMatching" , & advice_push_non_ff_matching },
74- { "pushAlreadyExists" , & advice_push_already_exists },
75- { "pushFetchFirst" , & advice_push_fetch_first },
76- { "pushNeedsForce" , & advice_push_needs_force },
77- { "pushUnqualifiedRefName" , & advice_push_unqualified_ref_name },
78- { "pushRefNeedsUpdate" , & advice_push_ref_needs_update },
79- { "statusHints" , & advice_status_hints },
80- { "statusUoption" , & advice_status_u_option },
81- { "statusAheadBehindWarning" , & advice_status_ahead_behind_warning },
82- { "commitBeforeMerge" , & advice_commit_before_merge },
83- { "resetQuiet" , & advice_reset_quiet_warning },
84- { "resolveConflict" , & advice_resolve_conflict },
85- { "sequencerInUse" , & advice_sequencer_in_use },
86- { "implicitIdentity" , & advice_implicit_identity },
87- { "detachedHead" , & advice_detached_head },
88- { "setUpstreamFailure" , & advice_set_upstream_failure },
89- { "objectNameWarning" , & advice_object_name_warning },
90- { "amWorkDir" , & advice_amworkdir },
91- { "rmHints" , & advice_rm_hints },
92- { "addEmbeddedRepo" , & advice_add_embedded_repo },
93- { "ignoredHook" , & advice_ignored_hook },
94- { "waitingForEditor" , & advice_waiting_for_editor },
95- { "graftFileDeprecated" , & advice_graft_file_deprecated },
96- { "checkoutAmbiguousRemoteBranchName" , & advice_checkout_ambiguous_remote_branch_name },
97- { "submoduleAlternateErrorStrategyDie" , & advice_submodule_alternate_error_strategy_die },
98- { "addIgnoredFile" , & advice_add_ignored_file },
99- { "addEmptyPathspec" , & advice_add_empty_pathspec },
100- { "skippedCherryPicks" , & advice_skipped_cherry_picks },
101-
102- /* make this an alias for backward compatibility */
103- { "pushNonFastForward" , & advice_push_update_rejected }
104- };
105-
10634static struct {
10735 const char * key ;
10836 int enabled ;
10937} advice_setting [] = {
11038 [ADVICE_ADD_EMBEDDED_REPO ] = { "addEmbeddedRepo" , 1 },
39+ [ADVICE_ADD_EMPTY_PATHSPEC ] = { "addEmptyPathspec" , 1 },
40+ [ADVICE_ADD_IGNORED_FILE ] = { "addIgnoredFile" , 1 },
11141 [ADVICE_AM_WORK_DIR ] = { "amWorkDir" , 1 },
11242 [ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME ] = { "checkoutAmbiguousRemoteBranchName" , 1 },
11343 [ADVICE_COMMIT_BEFORE_MERGE ] = { "commitBeforeMerge" , 1 },
@@ -224,13 +154,6 @@ int git_default_advice_config(const char *var, const char *value)
224154 if (!skip_prefix (var , "advice." , & k ))
225155 return 0 ;
226156
227- for (i = 0 ; i < ARRAY_SIZE (advice_config ); i ++ ) {
228- if (strcasecmp (k , advice_config [i ].name ))
229- continue ;
230- * advice_config [i ].preference = git_config_bool (var , value );
231- break ;
232- }
233-
234157 for (i = 0 ; i < ARRAY_SIZE (advice_setting ); i ++ ) {
235158 if (strcasecmp (k , advice_setting [i ].key ))
236159 continue ;
@@ -265,7 +188,7 @@ int error_resolve_conflict(const char *me)
265188 error (_ ("It is not possible to %s because you have unmerged files." ),
266189 me );
267190
268- if (advice_resolve_conflict )
191+ if (advice_enabled ( ADVICE_RESOLVE_CONFLICT ) )
269192 /*
270193 * Message used both when 'git commit' fails and when
271194 * other commands doing a merge do.
@@ -284,7 +207,7 @@ void NORETURN die_resolve_conflict(const char *me)
284207void NORETURN die_conclude_merge (void )
285208{
286209 error (_ ("You have not concluded your merge (MERGE_HEAD exists)." ));
287- if (advice_resolve_conflict )
210+ if (advice_enabled ( ADVICE_RESOLVE_CONFLICT ) )
288211 advise (_ ("Please, commit your changes before merging." ));
289212 die (_ ("Exiting because of unfinished merge." ));
290213}
0 commit comments