@ -22,10 +22,11 @@
@@ -22,10 +22,11 @@
#include "ref-filter.h"
static const char * const git_tag_usage[] = {
N_("git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] <tagname> [<head>]"),
N_("git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>]\n"
"\t\t<tagname> [<head>]"),
N_("git tag -d <tagname>..."),
N_("git tag -l [-n[<num>]] [--contains <commit>] [--no-contains <commit>] [--points-at <object>]"
"\n\t\t[--format=<format>] [--[no-]merged [<commit>]] [<pattern>...]"),
N_("git tag -l [-n[<num>]] [--contains <commit>] [--no-contains <commit>] [--points-at <object>]\n"
"\t\t[--format=<format>] [--[no-]merged [<commit>]] [<pattern>...]"),
N_("git tag -v [--format=<format>] <tagname>..."),
NULL
};
@ -205,7 +206,14 @@ struct create_tag_options {
@@ -205,7 +206,14 @@ struct create_tag_options {
} cleanup_mode;
};
static void create_tag(const struct object_id *object, const char *tag,
static const char message_advice_nested_tag[] =
N_("You have created a nested tag. The object referred to by your new is\n"
"already a tag. If you meant to tag the object that it points to, use:\n"
"\n"
"\tgit tag -f %s %s^{}");
static void create_tag(const struct object_id *object, const char *object_ref,
const char *tag,
struct strbuf *buf, struct create_tag_options *opt,
struct object_id *prev, struct object_id *result)
{
@ -215,7 +223,10 @@ static void create_tag(const struct object_id *object, const char *tag,
@@ -215,7 +223,10 @@ static void create_tag(const struct object_id *object, const char *tag,
type = oid_object_info(the_repository, object, NULL);
if (type <= OBJ_NONE)
die(_("bad object type."));
die(_("bad object type."));
if (type == OBJ_TAG && advice_nested_tag)
advise(_(message_advice_nested_tag), tag, object_ref);
strbuf_addf(&header,
"object %s\n"
@ -549,7 +560,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
@@ -549,7 +560,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
if (create_tag_object) {
if (force_sign_annotate && !annotate)
opt.sign = 1;
create_tag(&object, tag, &buf, &opt, &prev, &object);
create_tag(&object, object_ref, tag, &buf, &opt, &prev, &object);
}
transaction = ref_transaction_begin(&err);