add: change advice config variables used by the add API
advice.addNothing config variable is used to control the visibility of two advice messages in the add library. This config variable is replaced by two new variables, whose names are more clear and relevant to the two cases. Also add the two new variables to the documentation. Signed-off-by: Heba Waly <heba.waly@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Heba Waly committed
Feb 6, 2020 at 23:57 UTC
887a0fd57336dc5ff3ac28b6de0be91278e9e179
5 files changed
+22
-7
Documentation/config/advice.txt
+6
@@ -110,4 +110,10 @@ advice.*::
110
submoduleAlternateErrorStrategyDie::
111
Advice shown when a submodule.alternateErrorStrategy option
112
configured to "die" causes a fatal error.
113
+ addIgnoredFile::
114
+ Advice shown if a user attempts to add an ignored file to
115
+ the index.
116
+ addEmptyPathspec::
117
+ Advice shown if a user runs the add command without providing
118
+ the pathspec parameter.
119
--
advice.c
+4
-2
@@ -31,7 +31,8 @@ int advice_graft_file_deprecated = 1;
31
int advice_checkout_ambiguous_remote_branch_name = 1;
32
int advice_nested_tag = 1;
33
int advice_submodule_alternate_error_strategy_die = 1;
34
-int advice_add_nothing = 1;
34
+int advice_add_ignored_file = 1;
35
+int advice_add_empty_pathspec = 1;
36
37
static int advice_use_color = -1;
38
static char advice_colors[][COLOR_MAXLEN] = {
@@ -92,7 +93,8 @@ static struct {
93
{ "checkoutAmbiguousRemoteBranchName", &advice_checkout_ambiguous_remote_branch_name },
94
{ "nestedTag", &advice_nested_tag },
95
{ "submoduleAlternateErrorStrategyDie", &advice_submodule_alternate_error_strategy_die },
95
- { "addNothing", &advice_add_nothing },
96
+ { "addIgnoredFile", &advice_add_ignored_file },
97
+ { "addEmptyPathspec", &advice_add_empty_pathspec },
98
99
/* make this an alias for backward compatibility */
100
{ "pushNonFastForward", &advice_push_update_rejected }
advice.h
+2
-1
@@ -31,7 +31,8 @@ extern int advice_graft_file_deprecated;
31
extern int advice_checkout_ambiguous_remote_branch_name;
32
extern int advice_nested_tag;
33
extern int advice_submodule_alternate_error_strategy_die;
34
-extern int advice_add_nothing;
34
+extern int advice_add_ignored_file;
35
+extern int advice_add_empty_pathspec;
36
37
int git_default_advice_config(const char *var, const char *value);
38
__attribute__((format (printf, 1, 2)))
builtin/add.c
+8
-4
@@ -390,8 +390,10 @@ static int add_files(struct dir_struct *dir, int flags)
390
fprintf(stderr, _(ignore_error));
391
for (i = 0; i < dir->ignored_nr; i++)
392
fprintf(stderr, "%s\n", dir->ignored[i]->name);
393
- if (advice_add_nothing)
394
- advise(_("Use -f if you really want to add them.\n"));
393
+ if (advice_add_ignored_file)
394
+ advise(_("Use -f if you really want to add them.\n"
395
+ "Turn this message off by running\n"
396
+ "\"git config advice.addIgnoredFile false\""));
397
exit_status = 1;
398
}
399
@@ -481,8 +483,10 @@ int cmd_add(int argc, const char **argv, const char *prefix)
483
484
if (require_pathspec && pathspec.nr == 0) {
485
fprintf(stderr, _("Nothing specified, nothing added.\n"));
484
- if (advice_add_nothing)
485
- advise( _("Maybe you wanted to say 'git add .'?\n"));
486
+ if (advice_add_empty_pathspec)
487
+ advise( _("Maybe you wanted to say 'git add .'?\n"
488
+ "Turn this message off by running\n"
489
+ "\"git config advice.addEmptyPathspec false\""));
490
return 0;
491
}
492
t/t3700-add.sh
+2
@@ -327,6 +327,8 @@ cat >expect.err <<\EOF
327
The following paths are ignored by one of your .gitignore files:
328
ignored-file
329
hint: Use -f if you really want to add them.
330
+hint: Turn this message off by running
331
+hint: "git config advice.addIgnoredFile false"
332
EOF
333
cat >expect.out <<\EOF
334
add 'track-this'