Merge branch 'st/verify-tag'
authorJunio C Hamano <gitster@pobox.com>
Fri, 29 Apr 2016 19:59:09 +0000 (12:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Apr 2016 19:59:09 +0000 (12:59 -0700)
Unify internal logic between "git tag -v" and "git verify-tag"
commands by making one directly call into the other.

* st/verify-tag:
tag -v: verify directly rather than exec-ing verify-tag
verify-tag: move tag verification code to tag.c
verify-tag: prepare verify_tag for libification
verify-tag: update variable name and type
t7030: test verifying multiple tags
builtin/verify-tag.c: ignore SIGPIPE in gpg-interface

1  2 
builtin/tag.c
diff --combined builtin/tag.c
index 528a1bab69a6166877847dd3dbda5d5f724da3e9,7b2918ef38c603b52a5e02d0e81d7e23abaa5560..50e4ae5678c21f348c3ce0e0d0662c9d5f995847
@@@ -29,7 -29,6 +29,7 @@@ static const char * const git_tag_usage
  };
  
  static unsigned int colopts;
 +static int force_sign_annotate;
  
  static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, const char *format)
  {
@@@ -105,13 -104,7 +105,7 @@@ static int delete_tag(const char *name
  static int verify_tag(const char *name, const char *ref,
                                const unsigned char *sha1)
  {
-       const char *argv_verify_tag[] = {"verify-tag",
-                                       "-v", "SHA1_HEX", NULL};
-       argv_verify_tag[2] = sha1_to_hex(sha1);
-       if (run_command_v_opt(argv_verify_tag, RUN_GIT_CMD))
-               return error(_("could not verify the tag '%s'"), name);
-       return 0;
+       return gpg_verify_tag(sha1, name, GPG_VERIFY_VERBOSE);
  }
  
  static int do_sign(struct strbuf *buffer)
@@@ -167,11 -160,6 +161,11 @@@ static int git_tag_config(const char *v
        status = git_gpg_config(var, value, cb);
        if (status)
                return status;
 +      if (!strcmp(var, "tag.forcesignannotated")) {
 +              force_sign_annotate = git_config_bool(var, value);
 +              return 0;
 +      }
 +
        if (starts_with(var, "column."))
                return git_column_config(var, value, "tag", &colopts);
        return git_default_config(var, value, cb);
@@@ -333,7 -321,7 +327,7 @@@ int cmd_tag(int argc, const char **argv
        char *cleanup_arg = NULL;
        int create_reflog = 0;
        int annotate = 0, force = 0;
 -      int cmdmode = 0;
 +      int cmdmode = 0, create_tag_object = 0;
        const char *msgfile = NULL, *keyid = NULL;
        struct msg_arg msg = { 0, STRBUF_INIT };
        struct ref_transaction *transaction;
                opt.sign = 1;
                set_signing_key(keyid);
        }
 -      if (opt.sign)
 -              annotate = 1;
 +      create_tag_object = (opt.sign || annotate || msg.given || msgfile);
 +
        if (argc == 0 && !cmdmode)
                cmdmode = 'l';
  
 -      if ((annotate || msg.given || msgfile || force) && (cmdmode != 0))
 +      if ((create_tag_object || force) && (cmdmode != 0))
                usage_with_options(git_tag_usage, options);
  
        finalize_colopts(&colopts, -1);
        if (msg.given || msgfile) {
                if (msg.given && msgfile)
                        die(_("only one -F or -m option is allowed."));
 -              annotate = 1;
                if (msg.given)
                        strbuf_addbuf(&buf, &(msg.buf));
                else {
        else
                die(_("Invalid cleanup mode %s"), cleanup_arg);
  
 -      if (annotate)
 +      if (create_tag_object) {
 +              if (force_sign_annotate && !annotate)
 +                      opt.sign = 1;
                create_tag(object, tag, &buf, &opt, prev, object);
 +      }
  
        transaction = ref_transaction_begin(&err);
        if (!transaction ||