advice: remove read uses of most global `advice_` variables

In c4a09cc9ccb (Merge branch 'hw/advise-ng', 2020-03-25), a new API for accessing advice variables was introduced and deprecated `advice_config` in favor of a new array, `advice_setting`. This patch ports all but two uses which read the status of the global `advice_` variables over to the new `advice_enabled` API. We'll deal with advice_add_embedded_repo and advice_graft_file_deprecated separately. Signed-off-by: Ben Boeckel <mathstuf@gmail.com> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ben Boeckel committed Aug 23, 2021 at 12:44 UTC ed9bff0817d5a7500b50a39c1c35b44aa3e72578
22 files changed +50 -137
advice.c
+2 -61
@@ -4,36 +4,8 @@
4 #include "help.h"
5 #include "string-list.h"
6
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;
7 int advice_add_embedded_repo = 1;
30 -int advice_ignored_hook = 1;
31 -int advice_waiting_for_editor = 1;
8 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;
9
10 static int advice_use_color = -1;
11 static char advice_colors[][COLOR_MAXLEN] = {
@@ -66,39 +38,8 @@ static struct {
38 const char *name;
39 int *preference;
40 } advice_config[] = {
69 - { "fetchShowForcedUpdates", &advice_fetch_show_forced_updates },
70 - { "pushUpdateRejected", &advice_push_update_rejected },
71 - { "pushNonFFCurrent", &advice_push_non_ff_current },
72 - { "pushNonFFMatching", &advice_push_non_ff_matching },
73 - { "pushAlreadyExists", &advice_push_already_exists },
74 - { "pushFetchFirst", &advice_push_fetch_first },
75 - { "pushNeedsForce", &advice_push_needs_force },
76 - { "pushUnqualifiedRefName", &advice_push_unqualified_ref_name },
77 - { "pushRefNeedsUpdate", &advice_push_ref_needs_update },
78 - { "statusHints", &advice_status_hints },
79 - { "statusUoption", &advice_status_u_option },
80 - { "statusAheadBehindWarning", &advice_status_ahead_behind_warning },
81 - { "commitBeforeMerge", &advice_commit_before_merge },
82 - { "resetQuiet", &advice_reset_quiet_warning },
83 - { "resolveConflict", &advice_resolve_conflict },
84 - { "sequencerInUse", &advice_sequencer_in_use },
85 - { "implicitIdentity", &advice_implicit_identity },
86 - { "detachedHead", &advice_detached_head },
87 - { "setUpstreamFailure", &advice_set_upstream_failure },
88 - { "objectNameWarning", &advice_object_name_warning },
89 - { "amWorkDir", &advice_amworkdir },
90 - { "rmHints", &advice_rm_hints },
41 { "addEmbeddedRepo", &advice_add_embedded_repo },
92 - { "ignoredHook", &advice_ignored_hook },
93 - { "waitingForEditor", &advice_waiting_for_editor },
42 { "graftFileDeprecated", &advice_graft_file_deprecated },
95 - { "checkoutAmbiguousRemoteBranchName", &advice_checkout_ambiguous_remote_branch_name },
96 - { "submoduleAlternateErrorStrategyDie", &advice_submodule_alternate_error_strategy_die },
97 - { "addIgnoredFile", &advice_add_ignored_file },
98 - { "addEmptyPathspec", &advice_add_empty_pathspec },
99 -
100 - /* make this an alias for backward compatibility */
101 - { "pushNonFastForward", &advice_push_update_rejected }
43 };
44
45 static struct {
@@ -264,7 +205,7 @@ int error_resolve_conflict(const char *me)
205 error(_("It is not possible to %s because you have unmerged files."),
206 me);
207
267 - if (advice_resolve_conflict)
208 + if (advice_enabled(ADVICE_RESOLVE_CONFLICT))
209 /*
210 * Message used both when 'git commit' fails and when
211 * other commands doing a merge do.
@@ -283,7 +224,7 @@ void NORETURN die_resolve_conflict(const char *me)
224 void NORETURN die_conclude_merge(void)
225 {
226 error(_("You have not concluded your merge (MERGE_HEAD exists)."));
286 - if (advice_resolve_conflict)
227 + if (advice_enabled(ADVICE_RESOLVE_CONFLICT))
228 advise(_("Please, commit your changes before merging."));
229 die(_("Exiting because of unfinished merge."));
230 }
advice.h
-28
@@ -5,36 +5,8 @@
5
6 struct string_list;
7
8 -extern int advice_fetch_show_forced_updates;
9 -extern int advice_push_update_rejected;
10 -extern int advice_push_non_ff_current;
11 -extern int advice_push_non_ff_matching;
12 -extern int advice_push_already_exists;
13 -extern int advice_push_fetch_first;
14 -extern int advice_push_needs_force;
15 -extern int advice_push_unqualified_ref_name;
16 -extern int advice_push_ref_needs_update;
17 -extern int advice_status_hints;
18 -extern int advice_status_u_option;
19 -extern int advice_status_ahead_behind_warning;
20 -extern int advice_commit_before_merge;
21 -extern int advice_reset_quiet_warning;
22 -extern int advice_resolve_conflict;
23 -extern int advice_sequencer_in_use;
24 -extern int advice_implicit_identity;
25 -extern int advice_detached_head;
26 -extern int advice_set_upstream_failure;
27 -extern int advice_object_name_warning;
28 -extern int advice_amworkdir;
29 -extern int advice_rm_hints;
8 extern int advice_add_embedded_repo;
31 -extern int advice_ignored_hook;
32 -extern int advice_waiting_for_editor;
9 extern int advice_graft_file_deprecated;
34 -extern int advice_checkout_ambiguous_remote_branch_name;
35 -extern int advice_submodule_alternate_error_strategy_die;
36 -extern int advice_add_ignored_file;
37 -extern int advice_add_empty_pathspec;
10
11 /*
12 * To add a new advice, you need to:
branch.c
+1 -1
@@ -271,7 +271,7 @@ void create_branch(struct repository *r,
271 real_ref = NULL;
272 if (get_oid_mb(start_name, &oid)) {
273 if (explicit_tracking) {
274 - if (advice_set_upstream_failure) {
274 + if (advice_enabled(ADVICE_SET_UPSTREAM_FAILURE)) {
275 error(_(upstream_missing), start_name);
276 advise(_(upstream_advice));
277 exit(1);
builtin/add.c
+2 -2
@@ -447,7 +447,7 @@ static int add_files(struct dir_struct *dir, int flags)
447 fprintf(stderr, _(ignore_error));
448 for (i = 0; i < dir->ignored_nr; i++)
449 fprintf(stderr, "%s\n", dir->ignored[i]->name);
450 - if (advice_add_ignored_file)
450 + if (advice_enabled(ADVICE_ADD_IGNORED_FILE))
451 advise(_("Use -f if you really want to add them.\n"
452 "Turn this message off by running\n"
453 "\"git config advice.addIgnoredFile false\""));
@@ -553,7 +553,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
553
554 if (require_pathspec && pathspec.nr == 0) {
555 fprintf(stderr, _("Nothing specified, nothing added.\n"));
556 - if (advice_add_empty_pathspec)
556 + if (advice_enabled(ADVICE_ADD_EMPTY_PATHSPEC))
557 advise( _("Maybe you wanted to say 'git add .'?\n"
558 "Turn this message off by running\n"
559 "\"git config advice.addEmptyPathspec false\""));
builtin/am.c
+1 -1
@@ -1820,7 +1820,7 @@ static void am_run(struct am_state *state, int resume)
1820 printf_ln(_("Patch failed at %s %.*s"), msgnum(state),
1821 linelen(state->msg), state->msg);
1822
1823 - if (advice_amworkdir)
1823 + if (advice_enabled(ADVICE_AM_WORK_DIR))
1824 advise(_("Use 'git am --show-current-patch=diff' to see the failed patch"));
1825
1826 die_user_resolve(state);
builtin/checkout.c
+3 -3
@@ -918,7 +918,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
918 REF_NO_DEREF, UPDATE_REFS_DIE_ON_ERR);
919 if (!opts->quiet) {
920 if (old_branch_info->path &&
921 - advice_detached_head && !opts->force_detach)
921 + advice_enabled(ADVICE_DETACHED_HEAD) && !opts->force_detach)
922 detach_advice(new_branch_info->name);
923 describe_detached_head(_("HEAD is now at"), new_branch_info->commit);
924 }
@@ -1011,7 +1011,7 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
1011 sb.buf);
1012 strbuf_release(&sb);
1013
1014 - if (advice_detached_head)
1014 + if (advice_enabled(ADVICE_DETACHED_HEAD))
1015 fprintf(stderr,
1016 Q_(
1017 /* The singular version */
@@ -1182,7 +1182,7 @@ static const char *parse_remote_branch(const char *arg,
1182 }
1183
1184 if (!remote && num_matches > 1) {
1185 - if (advice_checkout_ambiguous_remote_branch_name) {
1185 + if (advice_enabled(ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME)) {
1186 advise(_("If you meant to check out a remote tracking branch on, e.g. 'origin',\n"
1187 "you can do so by fully qualifying the name with the --track option:\n"
1188 "\n"
builtin/clone.c
+1 -1
@@ -786,7 +786,7 @@ static int checkout(int submodule_progress)
786 return 0;
787 }
788 if (!strcmp(head, "HEAD")) {
789 - if (advice_detached_head)
789 + if (advice_enabled(ADVICE_DETACHED_HEAD))
790 detach_advice(oid_to_hex(&oid));
791 FREE_AND_NULL(head);
792 } else {
builtin/commit.c
+2 -2
@@ -203,7 +203,7 @@ static void status_init_config(struct wt_status *s, config_fn_t fn)
203 init_diff_ui_defaults();
204 git_config(fn, s);
205 determine_whence(s);
206 - s->hints = advice_status_hints; /* must come after git_config() */
206 + s->hints = advice_enabled(ADVICE_STATUS_HINTS); /* must come after git_config() */
207 }
208
209 static void rollback_index_files(void)
@@ -1033,7 +1033,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
1033 */
1034 if (!committable && whence != FROM_MERGE && !allow_empty &&
1035 !(amend && is_a_merge(current_head))) {
1036 - s->hints = advice_status_hints;
1036 + s->hints = advice_enabled(ADVICE_STATUS_HINTS);
1037 s->display_comment_prefix = old_display_comment_prefix;
1038 run_status(stdout, index_file, prefix, 0, s);
1039 if (amend)
builtin/fetch.c
+1 -1
@@ -1229,7 +1229,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
1229 " 'git remote prune %s' to remove any old, conflicting "
1230 "branches"), remote_name);
1231
1232 - if (advice_fetch_show_forced_updates) {
1232 + if (advice_enabled(ADVICE_FETCH_SHOW_FORCED_UPDATES)) {
1233 if (!fetch_show_forced_updates) {
1234 warning(_(warn_show_forced_updates));
1235 } else if (forced_updates_ms > FORCED_UPDATES_DELAY_WARNING_IN_MS) {
builtin/merge.c
+2 -2
@@ -1368,14 +1368,14 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1368 * There is no unmerged entry, don't advise 'git
1369 * add/rm <file>', just 'git commit'.
1370 */
1371 - if (advice_resolve_conflict)
1371 + if (advice_enabled(ADVICE_RESOLVE_CONFLICT))
1372 die(_("You have not concluded your merge (MERGE_HEAD exists).\n"
1373 "Please, commit your changes before you merge."));
1374 else
1375 die(_("You have not concluded your merge (MERGE_HEAD exists)."));
1376 }
1377 if (ref_exists("CHERRY_PICK_HEAD")) {
1378 - if (advice_resolve_conflict)
1378 + if (advice_enabled(ADVICE_RESOLVE_CONFLICT))
1379 die(_("You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\n"
1380 "Please, commit your changes before you merge."));
1381 else
builtin/push.c
+6 -6
@@ -289,42 +289,42 @@ static const char message_advice_ref_needs_update[] =
289
290 static void advise_pull_before_push(void)
291 {
292 - if (!advice_push_non_ff_current || !advice_push_update_rejected)
292 + if (!advice_enabled(ADVICE_PUSH_NON_FF_CURRENT) || !advice_enabled(ADVICE_PUSH_UPDATE_REJECTED))
293 return;
294 advise(_(message_advice_pull_before_push));
295 }
296
297 static void advise_checkout_pull_push(void)
298 {
299 - if (!advice_push_non_ff_matching || !advice_push_update_rejected)
299 + if (!advice_enabled(ADVICE_PUSH_NON_FF_MATCHING) || !advice_enabled(ADVICE_PUSH_UPDATE_REJECTED))
300 return;
301 advise(_(message_advice_checkout_pull_push));
302 }
303
304 static void advise_ref_already_exists(void)
305 {
306 - if (!advice_push_already_exists || !advice_push_update_rejected)
306 + if (!advice_enabled(ADVICE_PUSH_ALREADY_EXISTS) || !advice_enabled(ADVICE_PUSH_UPDATE_REJECTED))
307 return;
308 advise(_(message_advice_ref_already_exists));
309 }
310
311 static void advise_ref_fetch_first(void)
312 {
313 - if (!advice_push_fetch_first || !advice_push_update_rejected)
313 + if (!advice_enabled(ADVICE_PUSH_FETCH_FIRST) || !advice_enabled(ADVICE_PUSH_UPDATE_REJECTED))
314 return;
315 advise(_(message_advice_ref_fetch_first));
316 }
317
318 static void advise_ref_needs_force(void)
319 {
320 - if (!advice_push_needs_force || !advice_push_update_rejected)
320 + if (!advice_enabled(ADVICE_PUSH_NEEDS_FORCE) || !advice_enabled(ADVICE_PUSH_UPDATE_REJECTED))
321 return;
322 advise(_(message_advice_ref_needs_force));
323 }
324
325 static void advise_ref_needs_update(void)
326 {
327 - if (!advice_push_ref_needs_update || !advice_push_update_rejected)
327 + if (!advice_enabled(ADVICE_PUSH_REF_NEEDS_UPDATE) || !advice_enabled(ADVICE_PUSH_UPDATE_REJECTED))
328 return;
329 advise(_(message_advice_ref_needs_update));
330 }
builtin/reset.c
+1 -1
@@ -412,7 +412,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
412 refresh_index(&the_index, flags, NULL, NULL,
413 _("Unstaged changes after reset:"));
414 t_delta_in_ms = (getnanotime() - t_begin) / 1000000;
415 - if (advice_reset_quiet_warning && t_delta_in_ms > REFRESH_INDEX_DELAY_WARNING_IN_MS) {
415 + if (advice_enabled(ADVICE_RESET_QUIET_WARNING) && t_delta_in_ms > REFRESH_INDEX_DELAY_WARNING_IN_MS) {
416 printf(_("\nIt took %.2f seconds to enumerate unstaged changes after reset. You can\n"
417 "use '--quiet' to avoid this. Set the config setting reset.quiet to true\n"
418 "to make this the default.\n"), t_delta_in_ms / 1000.0);
builtin/rm.c
+1 -1
@@ -55,7 +55,7 @@ static void print_error_files(struct string_list *files_list,
55 strbuf_addf(&err_msg,
56 "\n %s",
57 files_list->items[i].string);
58 - if (advice_rm_hints)
58 + if (advice_enabled(ADVICE_RM_HINTS))
59 strbuf_addstr(&err_msg, hints_msg);
60 *errs = error("%s", err_msg.buf);
61 strbuf_release(&err_msg);
builtin/submodule--helper.c
+1 -1
@@ -1724,7 +1724,7 @@ static int add_possible_reference_from_superproject(
1724 } else {
1725 switch (sas->error_mode) {
1726 case SUBMODULE_ALTERNATE_ERROR_DIE:
1727 - if (advice_submodule_alternate_error_strategy_die)
1727 + if (advice_enabled(ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE))
1728 advise(_(alternate_error_advice));
1729 die(_("submodule '%s' cannot add alternate: %s"),
1730 sas->submodule_name, err.buf);
editor.c
+1 -1
@@ -58,7 +58,7 @@ static int launch_specified_editor(const char *editor, const char *path,
58 const char *args[] = { editor, NULL, NULL };
59 struct child_process p = CHILD_PROCESS_INIT;
60 int ret, sig;
61 - int print_waiting_for_editor = advice_waiting_for_editor && isatty(2);
61 + int print_waiting_for_editor = advice_enabled(ADVICE_WAITING_FOR_EDITOR) && isatty(2);
62
63 if (print_waiting_for_editor) {
64 /*
notes-merge.c
+1 -1
@@ -273,7 +273,7 @@ static void check_notes_merge_worktree(struct notes_merge_options *o)
273 */
274 if (file_exists(git_path(NOTES_MERGE_WORKTREE)) &&
275 !is_empty_dir(git_path(NOTES_MERGE_WORKTREE))) {
276 - if (advice_resolve_conflict)
276 + if (advice_enabled(ADVICE_RESOLVE_CONFLICT))
277 die(_("You have not concluded your previous "
278 "notes merge (%s exists).\nPlease, use "
279 "'git notes merge --commit' or 'git notes "
object-name.c
+1 -1
@@ -806,7 +806,7 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
806 refs_found = repo_dwim_ref(r, str, len, &tmp_oid, &real_ref, 0);
807 if (refs_found > 0) {
808 warning(warn_msg, len, str);
809 - if (advice_object_name_warning)
809 + if (advice_enabled(ADVICE_OBJECT_NAME_WARNING))
810 fprintf(stderr, "%s\n", _(object_name_msg));
811 }
812 free(real_ref);
remote.c
+6 -6
@@ -1111,7 +1111,7 @@ static void show_push_unqualified_ref_name_error(const char *dst_value,
1111 "Neither worked, so we gave up. You must fully qualify the ref."),
1112 dst_value, matched_src_name);
1113
1114 - if (!advice_push_unqualified_ref_name)
1114 + if (!advice_enabled(ADVICE_PUSH_UNQUALIFIED_REF_NAME))
1115 return;
1116
1117 if (get_oid(matched_src_name, &oid))
@@ -2118,7 +2118,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
2118 strbuf_addf(sb,
2119 _("Your branch is based on '%s', but the upstream is gone.\n"),
2120 base);
2121 - if (advice_status_hints)
2121 + if (advice_enabled(ADVICE_STATUS_HINTS))
2122 strbuf_addstr(sb,
2123 _(" (use \"git branch --unset-upstream\" to fixup)\n"));
2124 } else if (!sti) {
@@ -2129,7 +2129,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
2129 strbuf_addf(sb,
2130 _("Your branch and '%s' refer to different commits.\n"),
2131 base);
2132 - if (advice_status_hints)
2132 + if (advice_enabled(ADVICE_STATUS_HINTS))
2133 strbuf_addf(sb, _(" (use \"%s\" for details)\n"),
2134 "git status --ahead-behind");
2135 } else if (!theirs) {
@@ -2138,7 +2138,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
2138 "Your branch is ahead of '%s' by %d commits.\n",
2139 ours),
2140 base, ours);
2141 - if (advice_status_hints)
2141 + if (advice_enabled(ADVICE_STATUS_HINTS))
2142 strbuf_addstr(sb,
2143 _(" (use \"git push\" to publish your local commits)\n"));
2144 } else if (!ours) {
@@ -2149,7 +2149,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
2149 "and can be fast-forwarded.\n",
2150 theirs),
2151 base, theirs);
2152 - if (advice_status_hints)
2152 + if (advice_enabled(ADVICE_STATUS_HINTS))
2153 strbuf_addstr(sb,
2154 _(" (use \"git pull\" to update your local branch)\n"));
2155 } else {
@@ -2162,7 +2162,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
2162 "respectively.\n",
2163 ours + theirs),
2164 base, ours, theirs);
2165 - if (advice_status_hints)
2165 + if (advice_enabled(ADVICE_STATUS_HINTS))
2166 strbuf_addstr(sb,
2167 _(" (use \"git pull\" to merge the remote branch into yours)\n"));
2168 }
run-command.c
+1 -1
@@ -1336,7 +1336,7 @@ const char *find_hook(const char *name)
1336 err = errno;
1337 #endif
1338
1339 - if (err == EACCES && advice_ignored_hook) {
1339 + if (err == EACCES && advice_enabled(ADVICE_IGNORED_HOOK)) {
1340 static struct string_list advise_given = STRING_LIST_INIT_DUP;
1341
1342 if (!string_list_lookup(&advise_given, name)) {
sequencer.c
+4 -4
@@ -486,7 +486,7 @@ static int error_dirty_index(struct repository *repo, struct replay_opts *opts)
486 error(_("your local changes would be overwritten by %s."),
487 _(action_name(opts)));
488
489 - if (advice_commit_before_merge)
489 + if (advice_enabled(ADVICE_COMMIT_BEFORE_MERGE))
490 advise(_("commit your changes or stash them to proceed."));
491 return -1;
492 }
@@ -1293,7 +1293,7 @@ void print_commit_summary(struct repository *r,
1293 if (!committer_ident_sufficiently_given()) {
1294 strbuf_addstr(&format, "\n Committer: ");
1295 strbuf_addbuf_percentquote(&format, &committer_ident);
1296 - if (advice_implicit_identity) {
1296 + if (advice_enabled(ADVICE_IMPLICIT_IDENTITY)) {
1297 strbuf_addch(&format, '\n');
1298 strbuf_addstr(&format, implicit_ident_advice());
1299 }
@@ -3041,7 +3041,7 @@ static int create_seq_dir(struct repository *r)
3041 }
3042 if (in_progress_error) {
3043 error("%s", in_progress_error);
3044 - if (advice_sequencer_in_use)
3044 + if (advice_enabled(ADVICE_SEQUENCER_IN_USE))
3045 advise(in_progress_advice,
3046 advise_skip ? "--skip | " : "");
3047 return -1;
@@ -3245,7 +3245,7 @@ int sequencer_skip(struct repository *r, struct replay_opts *opts)
3245 give_advice:
3246 error(_("there is nothing to skip"));
3247
3248 - if (advice_resolve_conflict) {
3248 + if (advice_enabled(ADVICE_RESOLVE_CONFLICT)) {
3249 advise(_("have you committed already?\n"
3250 "try \"git %s --continue\""),
3251 action == REPLAY_REVERT ? "revert" : "cherry-pick");
unpack-trees.c
+9 -9
@@ -111,17 +111,17 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
111 strvec_init(&opts->msgs_to_free);
112
113 if (!strcmp(cmd, "checkout"))
114 - msg = advice_commit_before_merge
114 + msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)
115 ? _("Your local changes to the following files would be overwritten by checkout:\n%%s"
116 "Please commit your changes or stash them before you switch branches.")
117 : _("Your local changes to the following files would be overwritten by checkout:\n%%s");
118 else if (!strcmp(cmd, "merge"))
119 - msg = advice_commit_before_merge
119 + msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)
120 ? _("Your local changes to the following files would be overwritten by merge:\n%%s"
121 "Please commit your changes or stash them before you merge.")
122 : _("Your local changes to the following files would be overwritten by merge:\n%%s");
123 else
124 - msg = advice_commit_before_merge
124 + msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)
125 ? _("Your local changes to the following files would be overwritten by %s:\n%%s"
126 "Please commit your changes or stash them before you %s.")
127 : _("Your local changes to the following files would be overwritten by %s:\n%%s");
@@ -132,17 +132,17 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
132 _("Updating the following directories would lose untracked files in them:\n%s");
133
134 if (!strcmp(cmd, "checkout"))
135 - msg = advice_commit_before_merge
135 + msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)
136 ? _("The following untracked working tree files would be removed by checkout:\n%%s"
137 "Please move or remove them before you switch branches.")
138 : _("The following untracked working tree files would be removed by checkout:\n%%s");
139 else if (!strcmp(cmd, "merge"))
140 - msg = advice_commit_before_merge
140 + msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)
141 ? _("The following untracked working tree files would be removed by merge:\n%%s"
142 "Please move or remove them before you merge.")
143 : _("The following untracked working tree files would be removed by merge:\n%%s");
144 else
145 - msg = advice_commit_before_merge
145 + msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)
146 ? _("The following untracked working tree files would be removed by %s:\n%%s"
147 "Please move or remove them before you %s.")
148 : _("The following untracked working tree files would be removed by %s:\n%%s");
@@ -150,17 +150,17 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
150 strvec_pushf(&opts->msgs_to_free, msg, cmd, cmd);
151
152 if (!strcmp(cmd, "checkout"))
153 - msg = advice_commit_before_merge
153 + msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)
154 ? _("The following untracked working tree files would be overwritten by checkout:\n%%s"
155 "Please move or remove them before you switch branches.")
156 : _("The following untracked working tree files would be overwritten by checkout:\n%%s");
157 else if (!strcmp(cmd, "merge"))
158 - msg = advice_commit_before_merge
158 + msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)
159 ? _("The following untracked working tree files would be overwritten by merge:\n%%s"
160 "Please move or remove them before you merge.")
161 : _("The following untracked working tree files would be overwritten by merge:\n%%s");
162 else
163 - msg = advice_commit_before_merge
163 + msg = advice_enabled(ADVICE_COMMIT_BEFORE_MERGE)
164 ? _("The following untracked working tree files would be overwritten by %s:\n%%s"
165 "Please move or remove them before you %s.")
166 : _("The following untracked working tree files would be overwritten by %s:\n%%s");
wt-status.c
+3 -3
@@ -787,7 +787,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
787
788 dir_clear(&dir);
789
790 - if (advice_status_u_option)
790 + if (advice_enabled(ADVICE_STATUS_U_OPTION))
791 s->untracked_in_ms = (getnanotime() - t_begin) / 1000000;
792 }
793
@@ -1158,7 +1158,7 @@ static void wt_longstatus_print_tracking(struct wt_status *s)
1158 if (!format_tracking_info(branch, &sb, s->ahead_behind_flags))
1159 return;
1160
1161 - if (advice_status_ahead_behind_warning &&
1161 + if (advice_enabled(ADVICE_STATUS_AHEAD_BEHIND_WARNING) &&
1162 s->ahead_behind_flags == AHEAD_BEHIND_FULL) {
1163 uint64_t t_delta_in_ms = (getnanotime() - t_begin) / 1000000;
1164 if (t_delta_in_ms > AB_DELAY_WARNING_IN_MS) {
@@ -1845,7 +1845,7 @@ static void wt_longstatus_print(struct wt_status *s)
1845 wt_longstatus_print_other(s, &s->untracked, _("Untracked files"), "add");
1846 if (s->show_ignored_mode)
1847 wt_longstatus_print_other(s, &s->ignored, _("Ignored files"), "add -f");
1848 - if (advice_status_u_option && 2000 < s->untracked_in_ms) {
1848 + if (advice_enabled(ADVICE_STATUS_U_OPTION) && 2000 < s->untracked_in_ms) {
1849 status_printf_ln(s, GIT_COLOR_NORMAL, "%s", "");
1850 status_printf_ln(s, GIT_COLOR_NORMAL,
1851 _("It took %.2f seconds to enumerate untracked files. 'status -uno'\n"