]> git.ipfire.org Git - thirdparty/git.git/commitdiff
add: change advice config variables used by the add API
authorHeba Waly <heba.waly@gmail.com>
Thu, 6 Feb 2020 10:57:30 +0000 (23:57 +1300)
committerJunio C Hamano <gitster@pobox.com>
Thu, 6 Feb 2020 19:08:00 +0000 (11:08 -0800)
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>
Documentation/config/advice.txt
advice.c
advice.h
builtin/add.c
t/t3700-add.sh

index 4be93f8ad9c677e45c1dab652e28dab40bd36691..bdd37c3eaa3203f504fdc07eeac358ad58887965 100644 (file)
@@ -110,4 +110,10 @@ advice.*::
        submoduleAlternateErrorStrategyDie::
                Advice shown when a submodule.alternateErrorStrategy option
                configured to "die" causes a fatal error.
+       addIgnoredFile::
+               Advice shown if a user attempts to add an ignored file to
+               the index.
+       addEmptyPathspec::
+               Advice shown if a user runs the add command without providing
+               the pathspec parameter.
 --
index 098ac0abeafc3c88b0d3602510e6ef8a7bf0c700..97f3f981b4b484a9edfed7cedadc3c01e51ff47e 100644 (file)
--- a/advice.c
+++ b/advice.c
@@ -31,7 +31,8 @@ int advice_graft_file_deprecated = 1;
 int advice_checkout_ambiguous_remote_branch_name = 1;
 int advice_nested_tag = 1;
 int advice_submodule_alternate_error_strategy_die = 1;
-int advice_add_nothing = 1;
+int advice_add_ignored_file = 1;
+int advice_add_empty_pathspec = 1;
 
 static int advice_use_color = -1;
 static char advice_colors[][COLOR_MAXLEN] = {
@@ -92,7 +93,8 @@ static struct {
        { "checkoutAmbiguousRemoteBranchName", &advice_checkout_ambiguous_remote_branch_name },
        { "nestedTag", &advice_nested_tag },
        { "submoduleAlternateErrorStrategyDie", &advice_submodule_alternate_error_strategy_die },
-       { "addNothing", &advice_add_nothing },
+       { "addIgnoredFile", &advice_add_ignored_file },
+       { "addEmptyPathspec", &advice_add_empty_pathspec },
 
        /* make this an alias for backward compatibility */
        { "pushNonFastForward", &advice_push_update_rejected }
index 83287b0594ac405533c1972e180e289a2d758810..0e6e58d9f8f79df4b4f6ae242cf1fb0a7d179d1b 100644 (file)
--- a/advice.h
+++ b/advice.h
@@ -31,7 +31,8 @@ extern int advice_graft_file_deprecated;
 extern int advice_checkout_ambiguous_remote_branch_name;
 extern int advice_nested_tag;
 extern int advice_submodule_alternate_error_strategy_die;
-extern int advice_add_nothing;
+extern int advice_add_ignored_file;
+extern int advice_add_empty_pathspec;
 
 int git_default_advice_config(const char *var, const char *value);
 __attribute__((format (printf, 1, 2)))
index 57b3186f69d5df4b9481badfa057d0fe39587ad6..0e66934f3a4585909934033e06eddd47e3276682 100644 (file)
@@ -390,8 +390,10 @@ static int add_files(struct dir_struct *dir, int flags)
                fprintf(stderr, _(ignore_error));
                for (i = 0; i < dir->ignored_nr; i++)
                        fprintf(stderr, "%s\n", dir->ignored[i]->name);
-               if (advice_add_nothing)
-                       advise(_("Use -f if you really want to add them.\n"));
+               if (advice_add_ignored_file)
+                       advise(_("Use -f if you really want to add them.\n"
+                               "Turn this message off by running\n"
+                               "\"git config advice.addIgnoredFile false\""));
                exit_status = 1;
        }
 
@@ -481,8 +483,10 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 
        if (require_pathspec && pathspec.nr == 0) {
                fprintf(stderr, _("Nothing specified, nothing added.\n"));
-               if (advice_add_nothing)
-                       advise( _("Maybe you wanted to say 'git add .'?\n"));
+               if (advice_add_empty_pathspec)
+                       advise( _("Maybe you wanted to say 'git add .'?\n"
+                               "Turn this message off by running\n"
+                               "\"git config advice.addEmptyPathspec false\""));
                return 0;
        }
 
index a649805369dbf09685233206e86717e75e6a7c14..88bc799807f7dd99ba98cda2b698ef83e027f7b7 100755 (executable)
@@ -327,6 +327,8 @@ cat >expect.err <<\EOF
 The following paths are ignored by one of your .gitignore files:
 ignored-file
 hint: Use -f if you really want to add them.
+hint: Turn this message off by running
+hint: "git config advice.addIgnoredFile false"
 EOF
 cat >expect.out <<\EOF
 add 'track-this'