Merge branch 'kn/ref-transaction-symref'
[git.git] / builtin / tag.c
blob6e2c0cf3420156f37d927ab1cd162edf1a2813a1
1 /*
2 * Builtin "git tag"
4 * Copyright (c) 2007 Kristian Høgsberg <krh@redhat.com>,
5 * Carlos Rica <jasampler@gmail.com>
6 * Based on git-tag.sh and mktag.c by Linus Torvalds.
7 */
9 #include "builtin.h"
10 #include "advice.h"
11 #include "config.h"
12 #include "editor.h"
13 #include "environment.h"
14 #include "gettext.h"
15 #include "hex.h"
16 #include "refs.h"
17 #include "object-name.h"
18 #include "object-store-ll.h"
19 #include "path.h"
20 #include "tag.h"
21 #include "parse-options.h"
22 #include "diff.h"
23 #include "revision.h"
24 #include "gpg-interface.h"
25 #include "oid-array.h"
26 #include "column.h"
27 #include "ref-filter.h"
28 #include "date.h"
29 #include "write-or-die.h"
30 #include "object-file-convert.h"
31 #include "trailer.h"
33 static const char * const git_tag_usage[] = {
34 N_("git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] [-e]\n"
35 " [(--trailer <token>[(=|:)<value>])...]\n"
36 " <tagname> [<commit> | <object>]"),
37 N_("git tag -d <tagname>..."),
38 N_("git tag [-n[<num>]] -l [--contains <commit>] [--no-contains <commit>]\n"
39 " [--points-at <object>] [--column[=<options>] | --no-column]\n"
40 " [--create-reflog] [--sort=<key>] [--format=<format>]\n"
41 " [--merged <commit>] [--no-merged <commit>] [<pattern>...]"),
42 N_("git tag -v [--format=<format>] <tagname>..."),
43 NULL
46 static unsigned int colopts;
47 static int force_sign_annotate;
48 static int config_sign_tag = -1; /* unspecified */
50 static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting,
51 struct ref_format *format)
53 char *to_free = NULL;
55 if (filter->lines == -1)
56 filter->lines = 0;
58 if (!format->format) {
59 if (filter->lines) {
60 to_free = xstrfmt("%s %%(contents:lines=%d)",
61 "%(align:15)%(refname:lstrip=2)%(end)",
62 filter->lines);
63 format->format = to_free;
64 } else
65 format->format = "%(refname:lstrip=2)";
68 if (verify_ref_format(format))
69 die(_("unable to parse format string"));
70 filter->with_commit_tag_algo = 1;
71 filter_and_format_refs(filter, FILTER_REFS_TAGS, sorting, format);
73 free(to_free);
75 return 0;
78 typedef int (*each_tag_name_fn)(const char *name, const char *ref,
79 const struct object_id *oid, void *cb_data);
81 static int for_each_tag_name(const char **argv, each_tag_name_fn fn,
82 void *cb_data)
84 const char **p;
85 struct strbuf ref = STRBUF_INIT;
86 int had_error = 0;
87 struct object_id oid;
89 for (p = argv; *p; p++) {
90 strbuf_reset(&ref);
91 strbuf_addf(&ref, "refs/tags/%s", *p);
92 if (refs_read_ref(get_main_ref_store(the_repository), ref.buf, &oid)) {
93 error(_("tag '%s' not found."), *p);
94 had_error = 1;
95 continue;
97 if (fn(*p, ref.buf, &oid, cb_data))
98 had_error = 1;
100 strbuf_release(&ref);
101 return had_error;
104 static int collect_tags(const char *name UNUSED, const char *ref,
105 const struct object_id *oid, void *cb_data)
107 struct string_list *ref_list = cb_data;
109 string_list_append(ref_list, ref);
110 ref_list->items[ref_list->nr - 1].util = oiddup(oid);
111 return 0;
114 static int delete_tags(const char **argv)
116 int result;
117 struct string_list refs_to_delete = STRING_LIST_INIT_DUP;
118 struct string_list_item *item;
120 result = for_each_tag_name(argv, collect_tags, (void *)&refs_to_delete);
121 if (refs_delete_refs(get_main_ref_store(the_repository), NULL, &refs_to_delete, REF_NO_DEREF))
122 result = 1;
124 for_each_string_list_item(item, &refs_to_delete) {
125 const char *name = item->string;
126 struct object_id *oid = item->util;
127 if (!refs_ref_exists(get_main_ref_store(the_repository), name))
128 printf(_("Deleted tag '%s' (was %s)\n"),
129 item->string + 10,
130 repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
132 free(oid);
134 string_list_clear(&refs_to_delete, 0);
135 return result;
138 static int verify_tag(const char *name, const char *ref UNUSED,
139 const struct object_id *oid, void *cb_data)
141 int flags;
142 struct ref_format *format = cb_data;
143 flags = GPG_VERIFY_VERBOSE;
145 if (format->format)
146 flags = GPG_VERIFY_OMIT_STATUS;
148 if (gpg_verify_tag(oid, name, flags))
149 return -1;
151 if (format->format)
152 pretty_print_ref(name, oid, format);
154 return 0;
157 static int do_sign(struct strbuf *buffer, struct object_id **compat_oid,
158 struct object_id *compat_oid_buf)
160 const struct git_hash_algo *compat = the_repository->compat_hash_algo;
161 struct strbuf sig = STRBUF_INIT, compat_sig = STRBUF_INIT;
162 struct strbuf compat_buf = STRBUF_INIT;
163 const char *keyid = get_signing_key();
164 int ret = -1;
166 if (sign_buffer(buffer, &sig, keyid))
167 return -1;
169 if (compat) {
170 const struct git_hash_algo *algo = the_repository->hash_algo;
172 if (convert_object_file(&compat_buf, algo, compat,
173 buffer->buf, buffer->len, OBJ_TAG, 1))
174 goto out;
175 if (sign_buffer(&compat_buf, &compat_sig, keyid))
176 goto out;
177 add_header_signature(&compat_buf, &sig, algo);
178 strbuf_addbuf(&compat_buf, &compat_sig);
179 hash_object_file(compat, compat_buf.buf, compat_buf.len,
180 OBJ_TAG, compat_oid_buf);
181 *compat_oid = compat_oid_buf;
184 if (compat_sig.len)
185 add_header_signature(buffer, &compat_sig, compat);
187 strbuf_addbuf(buffer, &sig);
188 ret = 0;
189 out:
190 strbuf_release(&sig);
191 strbuf_release(&compat_sig);
192 strbuf_release(&compat_buf);
193 return ret;
196 static const char tag_template[] =
197 N_("\nWrite a message for tag:\n %s\n"
198 "Lines starting with '%s' will be ignored.\n");
200 static const char tag_template_nocleanup[] =
201 N_("\nWrite a message for tag:\n %s\n"
202 "Lines starting with '%s' will be kept; you may remove them"
203 " yourself if you want to.\n");
205 static int git_tag_config(const char *var, const char *value,
206 const struct config_context *ctx, void *cb)
208 if (!strcmp(var, "tag.gpgsign")) {
209 config_sign_tag = git_config_bool(var, value);
210 return 0;
213 if (!strcmp(var, "tag.sort")) {
214 if (!value)
215 return config_error_nonbool(var);
216 string_list_append(cb, value);
217 return 0;
220 if (!strcmp(var, "tag.forcesignannotated")) {
221 force_sign_annotate = git_config_bool(var, value);
222 return 0;
225 if (starts_with(var, "column."))
226 return git_column_config(var, value, "tag", &colopts);
228 if (git_color_config(var, value, cb) < 0)
229 return -1;
231 return git_default_config(var, value, ctx, cb);
234 static void write_tag_body(int fd, const struct object_id *oid)
236 unsigned long size;
237 enum object_type type;
238 char *buf, *sp, *orig;
239 struct strbuf payload = STRBUF_INIT;
240 struct strbuf signature = STRBUF_INIT;
242 orig = buf = repo_read_object_file(the_repository, oid, &type, &size);
243 if (!buf)
244 return;
245 if (parse_signature(buf, size, &payload, &signature)) {
246 buf = payload.buf;
247 size = payload.len;
249 /* skip header */
250 sp = strstr(buf, "\n\n");
252 if (!sp || !size || type != OBJ_TAG) {
253 free(buf);
254 return;
256 sp += 2; /* skip the 2 LFs */
257 write_or_die(fd, sp, buf + size - sp);
259 free(orig);
260 strbuf_release(&payload);
261 strbuf_release(&signature);
264 static int build_tag_object(struct strbuf *buf, int sign, struct object_id *result)
266 struct object_id *compat_oid = NULL, compat_oid_buf;
267 if (sign && do_sign(buf, &compat_oid, &compat_oid_buf) < 0)
268 return error(_("unable to sign the tag"));
269 if (write_object_file_flags(buf->buf, buf->len, OBJ_TAG, result,
270 compat_oid, 0) < 0)
271 return error(_("unable to write tag file"));
272 return 0;
275 struct create_tag_options {
276 unsigned int message_given:1;
277 unsigned int use_editor:1;
278 unsigned int sign;
279 enum {
280 CLEANUP_NONE,
281 CLEANUP_SPACE,
282 CLEANUP_ALL
283 } cleanup_mode;
286 static const char message_advice_nested_tag[] =
287 N_("You have created a nested tag. The object referred to by your new tag is\n"
288 "already a tag. If you meant to tag the object that it points to, use:\n"
289 "\n"
290 "\tgit tag -f %s %s^{}");
292 static void create_tag(const struct object_id *object, const char *object_ref,
293 const char *tag,
294 struct strbuf *buf, struct create_tag_options *opt,
295 struct object_id *prev, struct object_id *result,
296 struct strvec *trailer_args, char *path)
298 enum object_type type;
299 struct strbuf header = STRBUF_INIT;
300 int should_edit;
302 type = oid_object_info(the_repository, object, NULL);
303 if (type <= OBJ_NONE)
304 die(_("bad object type."));
306 if (type == OBJ_TAG)
307 advise_if_enabled(ADVICE_NESTED_TAG, _(message_advice_nested_tag),
308 tag, object_ref);
310 strbuf_addf(&header,
311 "object %s\n"
312 "type %s\n"
313 "tag %s\n"
314 "tagger %s\n\n",
315 oid_to_hex(object),
316 type_name(type),
317 tag,
318 git_committer_info(IDENT_STRICT));
320 should_edit = opt->use_editor || !opt->message_given;
321 if (should_edit || trailer_args->nr) {
322 int fd;
324 /* write the template message before editing: */
325 fd = xopen(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
327 if (opt->message_given && buf->len) {
328 strbuf_complete(buf, '\n');
329 write_or_die(fd, buf->buf, buf->len);
330 strbuf_reset(buf);
331 } else if (!is_null_oid(prev)) {
332 write_tag_body(fd, prev);
333 } else {
334 struct strbuf buf = STRBUF_INIT;
335 strbuf_addch(&buf, '\n');
336 if (opt->cleanup_mode == CLEANUP_ALL)
337 strbuf_commented_addf(&buf, comment_line_str,
338 _(tag_template), tag, comment_line_str);
339 else
340 strbuf_commented_addf(&buf, comment_line_str,
341 _(tag_template_nocleanup), tag, comment_line_str);
342 write_or_die(fd, buf.buf, buf.len);
343 strbuf_release(&buf);
345 close(fd);
347 if (trailer_args->nr && amend_file_with_trailers(path, trailer_args))
348 die(_("unable to pass trailers to --trailers"));
350 if (should_edit) {
351 if (launch_editor(path, buf, NULL)) {
352 fprintf(stderr,
353 _("Please supply the message using either -m or -F option.\n"));
354 exit(1);
356 } else if (trailer_args->nr) {
357 strbuf_reset(buf);
358 if (strbuf_read_file(buf, path, 0) < 0)
359 die_errno(_("failed to read '%s'"), path);
363 if (opt->cleanup_mode != CLEANUP_NONE)
364 strbuf_stripspace(buf,
365 opt->cleanup_mode == CLEANUP_ALL ? comment_line_str : NULL);
367 if (!opt->message_given && !buf->len)
368 die(_("no tag message?"));
370 strbuf_insert(buf, 0, header.buf, header.len);
371 strbuf_release(&header);
373 if (build_tag_object(buf, opt->sign, result) < 0) {
374 if (path)
375 fprintf(stderr, _("The tag message has been left in %s\n"),
376 path);
377 exit(128);
381 static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
383 enum object_type type;
384 struct commit *c;
385 char *buf;
386 unsigned long size;
387 int subject_len = 0;
388 const char *subject_start;
390 char *rla = getenv("GIT_REFLOG_ACTION");
391 if (rla) {
392 strbuf_addstr(sb, rla);
393 } else {
394 strbuf_addstr(sb, "tag: tagging ");
395 strbuf_add_unique_abbrev(sb, oid, DEFAULT_ABBREV);
398 strbuf_addstr(sb, " (");
399 type = oid_object_info(the_repository, oid, NULL);
400 switch (type) {
401 default:
402 strbuf_addstr(sb, "object of unknown type");
403 break;
404 case OBJ_COMMIT:
405 if ((buf = repo_read_object_file(the_repository, oid, &type, &size))) {
406 subject_len = find_commit_subject(buf, &subject_start);
407 strbuf_insert(sb, sb->len, subject_start, subject_len);
408 } else {
409 strbuf_addstr(sb, "commit object");
411 free(buf);
413 if ((c = lookup_commit_reference(the_repository, oid)))
414 strbuf_addf(sb, ", %s", show_date(c->date, 0, DATE_MODE(SHORT)));
415 break;
416 case OBJ_TREE:
417 strbuf_addstr(sb, "tree object");
418 break;
419 case OBJ_BLOB:
420 strbuf_addstr(sb, "blob object");
421 break;
422 case OBJ_TAG:
423 strbuf_addstr(sb, "other tag object");
424 break;
426 strbuf_addch(sb, ')');
429 struct msg_arg {
430 int given;
431 struct strbuf buf;
434 static int parse_msg_arg(const struct option *opt, const char *arg, int unset)
436 struct msg_arg *msg = opt->value;
438 BUG_ON_OPT_NEG(unset);
440 if (!arg)
441 return -1;
442 if (msg->buf.len)
443 strbuf_addstr(&(msg->buf), "\n\n");
444 strbuf_addstr(&(msg->buf), arg);
445 msg->given = 1;
446 return 0;
449 static int strbuf_check_tag_ref(struct strbuf *sb, const char *name)
451 if (name[0] == '-')
452 return -1;
454 strbuf_reset(sb);
455 strbuf_addf(sb, "refs/tags/%s", name);
457 return check_refname_format(sb->buf, 0);
460 int cmd_tag(int argc, const char **argv, const char *prefix)
462 struct strbuf buf = STRBUF_INIT;
463 struct strbuf ref = STRBUF_INIT;
464 struct strbuf reflog_msg = STRBUF_INIT;
465 struct object_id object, prev;
466 const char *object_ref, *tag;
467 struct create_tag_options opt;
468 char *cleanup_arg = NULL;
469 int create_reflog = 0;
470 int annotate = 0, force = 0;
471 int cmdmode = 0, create_tag_object = 0;
472 char *msgfile = NULL;
473 const char *keyid = NULL;
474 struct msg_arg msg = { .buf = STRBUF_INIT };
475 struct ref_transaction *transaction;
476 struct strbuf err = STRBUF_INIT;
477 struct ref_filter filter = REF_FILTER_INIT;
478 struct ref_sorting *sorting;
479 struct string_list sorting_options = STRING_LIST_INIT_DUP;
480 struct ref_format format = REF_FORMAT_INIT;
481 struct strvec trailer_args = STRVEC_INIT;
482 int icase = 0;
483 int edit_flag = 0;
484 struct option options[] = {
485 OPT_CMDMODE('l', "list", &cmdmode, N_("list tag names"), 'l'),
486 { OPTION_INTEGER, 'n', NULL, &filter.lines, N_("n"),
487 N_("print <n> lines of each tag message"),
488 PARSE_OPT_OPTARG, NULL, 1 },
489 OPT_CMDMODE('d', "delete", &cmdmode, N_("delete tags"), 'd'),
490 OPT_CMDMODE('v', "verify", &cmdmode, N_("verify tags"), 'v'),
492 OPT_GROUP(N_("Tag creation options")),
493 OPT_BOOL('a', "annotate", &annotate,
494 N_("annotated tag, needs a message")),
495 OPT_CALLBACK_F('m', "message", &msg, N_("message"),
496 N_("tag message"), PARSE_OPT_NONEG, parse_msg_arg),
497 OPT_FILENAME('F', "file", &msgfile, N_("read message from file")),
498 OPT_PASSTHRU_ARGV(0, "trailer", &trailer_args, N_("trailer"),
499 N_("add custom trailer(s)"), PARSE_OPT_NONEG),
500 OPT_BOOL('e', "edit", &edit_flag, N_("force edit of tag message")),
501 OPT_BOOL('s', "sign", &opt.sign, N_("annotated and GPG-signed tag")),
502 OPT_CLEANUP(&cleanup_arg),
503 OPT_STRING('u', "local-user", &keyid, N_("key-id"),
504 N_("use another key to sign the tag")),
505 OPT__FORCE(&force, N_("replace the tag if exists"), 0),
506 OPT_BOOL(0, "create-reflog", &create_reflog, N_("create a reflog")),
508 OPT_GROUP(N_("Tag listing options")),
509 OPT_COLUMN(0, "column", &colopts, N_("show tag list in columns")),
510 OPT_CONTAINS(&filter.with_commit, N_("print only tags that contain the commit")),
511 OPT_NO_CONTAINS(&filter.no_commit, N_("print only tags that don't contain the commit")),
512 OPT_WITH(&filter.with_commit, N_("print only tags that contain the commit")),
513 OPT_WITHOUT(&filter.no_commit, N_("print only tags that don't contain the commit")),
514 OPT_MERGED(&filter, N_("print only tags that are merged")),
515 OPT_NO_MERGED(&filter, N_("print only tags that are not merged")),
516 OPT_BOOL(0, "omit-empty", &format.array_opts.omit_empty,
517 N_("do not output a newline after empty formatted refs")),
518 OPT_REF_SORT(&sorting_options),
520 OPTION_CALLBACK, 0, "points-at", &filter.points_at, N_("object"),
521 N_("print only tags of the object"), PARSE_OPT_LASTARG_DEFAULT,
522 parse_opt_object_name, (intptr_t) "HEAD"
524 OPT_STRING( 0 , "format", &format.format, N_("format"),
525 N_("format to use for the output")),
526 OPT__COLOR(&format.use_color, N_("respect format colors")),
527 OPT_BOOL('i', "ignore-case", &icase, N_("sorting and filtering are case insensitive")),
528 OPT_END()
530 int ret = 0;
531 const char *only_in_list = NULL;
532 char *path = NULL;
534 setup_ref_filter_porcelain_msg();
537 * Try to set sort keys from config. If config does not set any,
538 * fall back on default (refname) sorting.
540 git_config(git_tag_config, &sorting_options);
541 if (!sorting_options.nr)
542 string_list_append(&sorting_options, "refname");
544 memset(&opt, 0, sizeof(opt));
545 filter.lines = -1;
546 opt.sign = -1;
548 argc = parse_options(argc, argv, prefix, options, git_tag_usage, 0);
550 if (!cmdmode) {
551 if (argc == 0)
552 cmdmode = 'l';
553 else if (filter.with_commit || filter.no_commit ||
554 filter.reachable_from || filter.unreachable_from ||
555 filter.points_at.nr || filter.lines != -1)
556 cmdmode = 'l';
559 if (cmdmode == 'l')
560 setup_auto_pager("tag", 1);
562 if (opt.sign == -1)
563 opt.sign = cmdmode ? 0 : config_sign_tag > 0;
565 if (keyid) {
566 opt.sign = 1;
567 set_signing_key(keyid);
569 create_tag_object = (opt.sign || annotate || msg.given || msgfile ||
570 edit_flag || trailer_args.nr);
572 if ((create_tag_object || force) && (cmdmode != 0))
573 usage_with_options(git_tag_usage, options);
575 finalize_colopts(&colopts, -1);
576 if (cmdmode == 'l' && filter.lines != -1) {
577 if (explicitly_enable_column(colopts))
578 die(_("options '%s' and '%s' cannot be used together"), "--column", "-n");
579 colopts = 0;
581 sorting = ref_sorting_options(&sorting_options);
582 ref_sorting_set_sort_flags_all(sorting, REF_SORTING_ICASE, icase);
583 filter.ignore_case = icase;
584 if (cmdmode == 'l') {
585 if (column_active(colopts)) {
586 struct column_options copts;
587 memset(&copts, 0, sizeof(copts));
588 copts.padding = 2;
589 if (run_column_filter(colopts, &copts))
590 die(_("could not start 'git column'"));
592 filter.name_patterns = argv;
593 ret = list_tags(&filter, sorting, &format);
594 if (column_active(colopts))
595 stop_column_filter();
596 goto cleanup;
598 if (filter.lines != -1)
599 only_in_list = "-n";
600 else if (filter.with_commit)
601 only_in_list = "--contains";
602 else if (filter.no_commit)
603 only_in_list = "--no-contains";
604 else if (filter.points_at.nr)
605 only_in_list = "--points-at";
606 else if (filter.reachable_from)
607 only_in_list = "--merged";
608 else if (filter.unreachable_from)
609 only_in_list = "--no-merged";
610 if (only_in_list)
611 die(_("the '%s' option is only allowed in list mode"), only_in_list);
612 if (cmdmode == 'd') {
613 ret = delete_tags(argv);
614 goto cleanup;
616 if (cmdmode == 'v') {
617 if (format.format && verify_ref_format(&format))
618 usage_with_options(git_tag_usage, options);
619 ret = for_each_tag_name(argv, verify_tag, &format);
620 goto cleanup;
623 if (msg.given || msgfile) {
624 if (msg.given && msgfile)
625 die(_("options '%s' and '%s' cannot be used together"), "-F", "-m");
626 if (msg.given)
627 strbuf_addbuf(&buf, &(msg.buf));
628 else {
629 if (!strcmp(msgfile, "-")) {
630 if (strbuf_read(&buf, 0, 1024) < 0)
631 die_errno(_("cannot read '%s'"), msgfile);
632 } else {
633 if (strbuf_read_file(&buf, msgfile, 1024) < 0)
634 die_errno(_("could not open or read '%s'"),
635 msgfile);
640 tag = argv[0];
642 object_ref = argc == 2 ? argv[1] : "HEAD";
643 if (argc > 2)
644 die(_("too many arguments"));
646 if (repo_get_oid(the_repository, object_ref, &object))
647 die(_("Failed to resolve '%s' as a valid ref."), object_ref);
649 if (strbuf_check_tag_ref(&ref, tag))
650 die(_("'%s' is not a valid tag name."), tag);
652 if (refs_read_ref(get_main_ref_store(the_repository), ref.buf, &prev))
653 oidclr(&prev);
654 else if (!force)
655 die(_("tag '%s' already exists"), tag);
657 opt.message_given = msg.given || msgfile;
658 opt.use_editor = edit_flag;
660 if (!cleanup_arg || !strcmp(cleanup_arg, "strip"))
661 opt.cleanup_mode = CLEANUP_ALL;
662 else if (!strcmp(cleanup_arg, "verbatim"))
663 opt.cleanup_mode = CLEANUP_NONE;
664 else if (!strcmp(cleanup_arg, "whitespace"))
665 opt.cleanup_mode = CLEANUP_SPACE;
666 else
667 die(_("Invalid cleanup mode %s"), cleanup_arg);
669 create_reflog_msg(&object, &reflog_msg);
671 if (create_tag_object) {
672 if (force_sign_annotate && !annotate)
673 opt.sign = 1;
674 path = git_pathdup("TAG_EDITMSG");
675 create_tag(&object, object_ref, tag, &buf, &opt, &prev, &object,
676 &trailer_args, path);
679 transaction = ref_store_transaction_begin(get_main_ref_store(the_repository),
680 &err);
681 if (!transaction ||
682 ref_transaction_update(transaction, ref.buf, &object, &prev,
683 NULL, NULL,
684 create_reflog ? REF_FORCE_CREATE_REFLOG : 0,
685 reflog_msg.buf, &err) ||
686 ref_transaction_commit(transaction, &err)) {
687 if (path)
688 fprintf(stderr,
689 _("The tag message has been left in %s\n"),
690 path);
691 die("%s", err.buf);
693 if (path) {
694 unlink_or_warn(path);
695 free(path);
697 ref_transaction_free(transaction);
698 if (force && !is_null_oid(&prev) && !oideq(&prev, &object))
699 printf(_("Updated tag '%s' (was %s)\n"), tag,
700 repo_find_unique_abbrev(the_repository, &prev, DEFAULT_ABBREV));
702 cleanup:
703 ref_sorting_release(sorting);
704 ref_filter_clear(&filter);
705 strbuf_release(&buf);
706 strbuf_release(&ref);
707 strbuf_release(&reflog_msg);
708 strbuf_release(&msg.buf);
709 strbuf_release(&err);
710 strvec_clear(&trailer_args);
711 free(msgfile);
712 return ret;