From: Junio C Hamano Date: Wed, 3 Apr 2013 16:24:51 +0000 (-0700) Subject: Merge branch 'ph/tag-force-no-warn-on-creation' into maint X-Git-Tag: v1.8.2.1~15 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/9e72a566995ae84862a341e3a149a4bcaf96385d?ds=inline;hp=-c Merge branch 'ph/tag-force-no-warn-on-creation' into maint "git tag -f " always said "Updated tag ''" even when creating a new tag (i.e. not overwriting nor updating). * ph/tag-force-no-warn-on-creation: tag: --force does not have to warn when creating tags --- 9e72a566995ae84862a341e3a149a4bcaf96385d diff --combined builtin/tag.c index f8266888cc,d4824800b7..af3af3f649 --- a/builtin/tag.c +++ b/builtin/tag.c @@@ -246,13 -246,19 +246,13 @@@ static int do_sign(struct strbuf *buffe } static const char tag_template[] = - N_("\n" - "#\n" - "# Write a tag message\n" - "# Lines starting with '#' will be ignored.\n" - "#\n"); + N_("\nWrite a tag message\n" + "Lines starting with '%c' will be ignored.\n"); static const char tag_template_nocleanup[] = - N_("\n" - "#\n" - "# Write a tag message\n" - "# Lines starting with '#' will be kept; you may remove them" - " yourself if you want to.\n" - "#\n"); + N_("\nWrite a tag message\n" + "Lines starting with '%c' will be kept; you may remove them" + " yourself if you want to.\n"); static int git_tag_config(const char *var, const char *value, void *cb) { @@@ -340,18 -346,14 +340,18 @@@ static void create_tag(const unsigned c if (fd < 0) die_errno(_("could not create file '%s'"), path); - if (!is_null_sha1(prev)) + if (!is_null_sha1(prev)) { write_tag_body(fd, prev); - else if (opt->cleanup_mode == CLEANUP_ALL) - write_or_die(fd, _(tag_template), - strlen(_(tag_template))); - else - write_or_die(fd, _(tag_template_nocleanup), - strlen(_(tag_template_nocleanup))); + } else { + struct strbuf buf = STRBUF_INIT; + strbuf_addch(&buf, '\n'); + if (opt->cleanup_mode == CLEANUP_ALL) + strbuf_commented_addf(&buf, _(tag_template), comment_line_char); + else + strbuf_commented_addf(&buf, _(tag_template_nocleanup), comment_line_char); + write_or_die(fd, buf.buf, buf.len); + strbuf_release(&buf); + } close(fd); if (launch_editor(path, buf, NULL)) { @@@ -582,7 -584,7 +582,7 @@@ int cmd_tag(int argc, const char **argv die(_("%s: cannot lock the ref"), ref.buf); if (write_ref_sha1(lock, object, NULL) < 0) die(_("%s: cannot update the ref"), ref.buf); - if (force && hashcmp(prev, object)) + if (force && !is_null_sha1(prev) && hashcmp(prev, object)) printf(_("Updated tag '%s' (was %s)\n"), tag, find_unique_abbrev(prev, DEFAULT_ABBREV)); strbuf_release(&buf);