]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tag: use new advice API to check visibility
authorHeba Waly <heba.waly@gmail.com>
Mon, 2 Mar 2020 20:02:00 +0000 (20:02 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Mar 2020 14:15:04 +0000 (06:15 -0800)
change the advise call in tag library from advise() to
advise_if_enabled() to construct an example of the usage of
the new API.

Signed-off-by: Heba Waly <heba.waly@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
advice.c
advice.h
builtin/tag.c
t/t7004-tag.sh

index 9814d6cdfd8b24fd157c2c02f8aeb648df6782f6..ef4bef65d8ca8c32d8439026bd748a540f228d49 100644 (file)
--- a/advice.c
+++ b/advice.c
@@ -29,7 +29,6 @@ int advice_ignored_hook = 1;
 int advice_waiting_for_editor = 1;
 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;
 
 static int advice_use_color = -1;
@@ -89,7 +88,6 @@ static struct {
        { "waitingForEditor", &advice_waiting_for_editor },
        { "graftFileDeprecated", &advice_graft_file_deprecated },
        { "checkoutAmbiguousRemoteBranchName", &advice_checkout_ambiguous_remote_branch_name },
-       { "nestedTag", &advice_nested_tag },
        { "submoduleAlternateErrorStrategyDie", &advice_submodule_alternate_error_strategy_die },
 
        /* make this an alias for backward compatibility */
index d72ab4a06c1b946f16a67cfd1e3815fa59b3f3ab..77cbe5c6b362a70fb97999806f83a3ce76b1c484 100644 (file)
--- a/advice.h
+++ b/advice.h
@@ -29,7 +29,6 @@ extern int advice_ignored_hook;
 extern int advice_waiting_for_editor;
 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;
 
 /*
index e0a4c25382846f801c43cd1093ffb0ffa63f975f..cc30d346f5d5baf554965e60350dfb05a4f20b74 100644 (file)
@@ -231,8 +231,9 @@ static void create_tag(const struct object_id *object, const char *object_ref,
        if (type <= OBJ_NONE)
                die(_("bad object type."));
 
-       if (type == OBJ_TAG && advice_nested_tag)
-               advise(_(message_advice_nested_tag), tag, object_ref);
+       if (type == OBJ_TAG)
+               advise_if_enabled(ADVICE_NESTED_TAG, _(message_advice_nested_tag),
+                                 tag, object_ref);
 
        strbuf_addf(&header,
                    "object %s\n"
index 6db92bd3ba62db4bb4e653480faf90f20d2b0bcb..74b637deb259a9c65e9abcac5ded9bcf5bf76b67 100755 (executable)
@@ -1726,6 +1726,7 @@ test_expect_success 'recursive tagging should give advice' '
        hint: already a tag. If you meant to tag the object that it points to, use:
        hint: |
        hint:   git tag -f nested annotated-v4.0^{}
+       hint: Disable this message with "git config advice.nestedTag false"
        EOF
        git tag -m nested nested annotated-v4.0 2>actual &&
        test_i18ncmp expect actual