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>
This commit is contained in:
Heba Waly 2020-03-02 20:02:00 +00:00 committed by Junio C Hamano
parent b3b18d1621
commit f665d63a91
4 changed files with 4 additions and 5 deletions

View File

@ -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 */

View File

@ -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;
/*

View 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"

View File

@ -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