Merge branch 'jk/tag-h-column-is-a-listing-option'
authorJunio C Hamano <gitster@pobox.com>
Mon, 23 Mar 2015 18:28:02 +0000 (11:28 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Mar 2015 18:28:02 +0000 (11:28 -0700)
"git tag -h" used to show the "--column" and "--sort" options
that are about listing in a wrong section.

* jk/tag-h-column-is-a-listing-option:
tag: fix some mis-organized options in "-h" listing

1  2 
builtin/tag.c
diff --combined builtin/tag.c
index 4194b9a711d88e6d3575cd8896b1a81de74b087f,de1beed2f9fb252b76ef29a6560f0149cf6882f1..6f07ac6b93c3e36a1bc69d43e6e12ca3367b4c34
@@@ -19,9 -19,9 +19,9 @@@
  #include "column.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>] <tagname> [<head>]"),
        N_("git tag -d <tagname>..."),
 -      N_("git tag -l [-n[<num>]] [--contains <commit>] [--points-at <object>] "
 +      N_("git tag -l [-n[<num>]] [--contains <commit>] [--points-at <object>]"
                "\n\t\t[<pattern>...]"),
        N_("git tag -v <tagname>..."),
        NULL
@@@ -85,7 -85,7 +85,7 @@@ static int in_commit_list(const struct 
  enum contains_result {
        CONTAINS_UNKNOWN = -1,
        CONTAINS_NO = 0,
 -      CONTAINS_YES = 1,
 +      CONTAINS_YES = 1
  };
  
  /*
@@@ -576,6 -576,7 +576,6 @@@ int cmd_tag(int argc, const char **argv
        struct strbuf ref = STRBUF_INIT;
        unsigned char object[20], prev[20];
        const char *object_ref, *tag;
 -      struct ref_lock *lock;
        struct create_tag_options opt;
        char *cleanup_arg = NULL;
        int annotate = 0, force = 0, lines = -1;
        const char *msgfile = NULL, *keyid = NULL;
        struct msg_arg msg = { 0, STRBUF_INIT };
        struct commit_list *with_commit = NULL;
 +      struct ref_transaction *transaction;
 +      struct strbuf err = STRBUF_INIT;
        struct option options[] = {
                OPT_CMDMODE('l', "list", &cmdmode, N_("list tag names"), 'l'),
                { OPTION_INTEGER, 'n', NULL, &lines, N_("n"),
                OPT_STRING('u', "local-user", &keyid, N_("key-id"),
                                        N_("use another key to sign the tag")),
                OPT__FORCE(&force, N_("replace the tag if exists")),
+               OPT_GROUP(N_("Tag listing options")),
                OPT_COLUMN(0, "column", &colopts, N_("show tag list in columns")),
                {
                        OPTION_CALLBACK, 0, "sort", &tag_sort, N_("type"), N_("sort tags"),
                        PARSE_OPT_NONEG, parse_opt_sort
                },
-               OPT_GROUP(N_("Tag listing options")),
                {
                        OPTION_CALLBACK, 0, "contains", &with_commit, N_("commit"),
                        N_("print only tags that contain the commit"),
        if (annotate)
                create_tag(object, tag, &buf, &opt, prev, object);
  
 -      lock = lock_any_ref_for_update(ref.buf, prev, 0, NULL);
 -      if (!lock)
 -              die(_("%s: cannot lock the ref"), ref.buf);
 -      if (write_ref_sha1(lock, object, NULL) < 0)
 -              die(_("%s: cannot update the ref"), ref.buf);
 +      transaction = ref_transaction_begin(&err);
 +      if (!transaction ||
 +          ref_transaction_update(transaction, ref.buf, object, prev,
 +                                 0, NULL, &err) ||
 +          ref_transaction_commit(transaction, &err))
 +              die("%s", err.buf);
 +      ref_transaction_free(transaction);
        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(&err);
        strbuf_release(&buf);
        strbuf_release(&ref);
        return 0;