@matheusbsbs / matheus-bagliano / commits / f665d63a91
Fork 0

tag: use new advice API to check visibility

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>

Heba Waly committed Mar 2, 2020 at 20:02 UTC f665d63a912748bc1397940a0dc1de80c6f693e3
4 files changed +4 -5
advice.c
-2
@@ -29,7 +29,6 @@ int advice_ignored_hook = 1;
29 int advice_waiting_for_editor = 1;
30 int advice_graft_file_deprecated = 1;
31 int advice_checkout_ambiguous_remote_branch_name = 1;
32 -int advice_nested_tag = 1;
32 int advice_submodule_alternate_error_strategy_die = 1;
33
34 static int advice_use_color = -1;
@@ -89,7 +88,6 @@ static struct {
88 { "waitingForEditor", &advice_waiting_for_editor },
89 { "graftFileDeprecated", &advice_graft_file_deprecated },
90 { "checkoutAmbiguousRemoteBranchName", &advice_checkout_ambiguous_remote_branch_name },
92 - { "nestedTag", &advice_nested_tag },
91 { "submoduleAlternateErrorStrategyDie", &advice_submodule_alternate_error_strategy_die },
92
93 /* make this an alias for backward compatibility */
advice.h
-1
@@ -29,7 +29,6 @@ extern int advice_ignored_hook;
29 extern int advice_waiting_for_editor;
30 extern int advice_graft_file_deprecated;
31 extern int advice_checkout_ambiguous_remote_branch_name;
32 -extern int advice_nested_tag;
32 extern int advice_submodule_alternate_error_strategy_die;
33
34 /*
builtin/tag.c
+3 -2
@@ -231,8 +231,9 @@ static void create_tag(const struct object_id *object, const char *object_ref,
231 if (type <= OBJ_NONE)
232 die(_("bad object type."));
233
234 - if (type == OBJ_TAG && advice_nested_tag)
235 - advise(_(message_advice_nested_tag), tag, object_ref);
234 + if (type == OBJ_TAG)
235 + advise_if_enabled(ADVICE_NESTED_TAG, _(message_advice_nested_tag),
236 + tag, object_ref);
237
238 strbuf_addf(&header,
239 "object %s\n"
t/t7004-tag.sh
+1
@@ -1726,6 +1726,7 @@ test_expect_success 'recursive tagging should give advice' '
1726 hint: already a tag. If you meant to tag the object that it points to, use:
1727 hint: |
1728 hint: git tag -f nested annotated-v4.0^{}
1729 + hint: Disable this message with "git config advice.nestedTag false"
1730 EOF
1731 git tag -m nested nested annotated-v4.0 2>actual &&
1732 test_i18ncmp expect actual