aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/tag.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/tag.c')
-rw-r--r--builtin/tag.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/builtin/tag.c b/builtin/tag.c
index 93d10d5915..46cbf892e3 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -5,7 +5,10 @@
* Carlos Rica <jasampler@gmail.com>
* Based on git-tag.sh and mktag.c by Linus Torvalds.
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "advice.h"
#include "config.h"
@@ -14,8 +17,9 @@
#include "gettext.h"
#include "hex.h"
#include "refs.h"
+#include "object-file.h"
#include "object-name.h"
-#include "object-store-ll.h"
+#include "odb.h"
#include "path.h"
#include "tag.h"
#include "parse-options.h"
@@ -164,12 +168,12 @@ static int do_sign(struct strbuf *buffer, struct object_id **compat_oid,
int ret = -1;
if (sign_buffer(buffer, &sig, keyid))
- return -1;
+ goto out;
if (compat) {
const struct git_hash_algo *algo = the_repository->hash_algo;
- if (convert_object_file(&compat_buf, algo, compat,
+ if (convert_object_file(the_repository ,&compat_buf, algo, compat,
buffer->buf, buffer->len, OBJ_TAG, 1))
goto out;
if (sign_buffer(&compat_buf, &compat_sig, keyid))
@@ -240,7 +244,7 @@ static void write_tag_body(int fd, const struct object_id *oid)
struct strbuf payload = STRBUF_INIT;
struct strbuf signature = STRBUF_INIT;
- orig = buf = repo_read_object_file(the_repository, oid, &type, &size);
+ orig = buf = odb_read_object(the_repository->objects, oid, &type, &size);
if (!buf)
return;
if (parse_signature(buf, size, &payload, &signature)) {
@@ -300,7 +304,7 @@ static void create_tag(const struct object_id *object, const char *object_ref,
struct strbuf header = STRBUF_INIT;
int should_edit;
- type = oid_object_info(the_repository, object, NULL);
+ type = odb_read_object_info(the_repository->objects, object, NULL);
if (type <= OBJ_NONE)
die(_("bad object type."));
@@ -397,13 +401,13 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
}
strbuf_addstr(sb, " (");
- type = oid_object_info(the_repository, oid, NULL);
+ type = odb_read_object_info(the_repository->objects, oid, NULL);
switch (type) {
default:
strbuf_addstr(sb, "object of unknown type");
break;
case OBJ_COMMIT:
- if ((buf = repo_read_object_file(the_repository, oid, &type, &size))) {
+ if ((buf = odb_read_object(the_repository->objects, oid, &type, &size))) {
subject_len = find_commit_subject(buf, &subject_start);
strbuf_insert(sb, sb->len, subject_start, subject_len);
} else {
@@ -447,17 +451,6 @@ static int parse_msg_arg(const struct option *opt, const char *arg, int unset)
return 0;
}
-static int strbuf_check_tag_ref(struct strbuf *sb, const char *name)
-{
- if (name[0] == '-')
- return -1;
-
- strbuf_reset(sb);
- strbuf_addf(sb, "refs/tags/%s", name);
-
- return check_refname_format(sb->buf, 0);
-}
-
int cmd_tag(int argc,
const char **argv,
const char *prefix,
@@ -487,9 +480,16 @@ int cmd_tag(int argc,
int edit_flag = 0;
struct option options[] = {
OPT_CMDMODE('l', "list", &cmdmode, N_("list tag names"), 'l'),
- { OPTION_INTEGER, 'n', NULL, &filter.lines, N_("n"),
- N_("print <n> lines of each tag message"),
- PARSE_OPT_OPTARG, NULL, 1 },
+ {
+ .type = OPTION_INTEGER,
+ .short_name = 'n',
+ .value = &filter.lines,
+ .precision = sizeof(filter.lines),
+ .argh = N_("n"),
+ .help = N_("print <n> lines of each tag message"),
+ .flags = PARSE_OPT_OPTARG,
+ .defval = 1,
+ },
OPT_CMDMODE('d', "delete", &cmdmode, N_("delete tags"), 'd'),
OPT_CMDMODE('v', "verify", &cmdmode, N_("verify tags"), 'v'),
@@ -521,9 +521,14 @@ int cmd_tag(int argc,
N_("do not output a newline after empty formatted refs")),
OPT_REF_SORT(&sorting_options),
{
- OPTION_CALLBACK, 0, "points-at", &filter.points_at, N_("object"),
- N_("print only tags of the object"), PARSE_OPT_LASTARG_DEFAULT,
- parse_opt_object_name, (intptr_t) "HEAD"
+ .type = OPTION_CALLBACK,
+ .long_name = "points-at",
+ .value = &filter.points_at,
+ .argh = N_("object"),
+ .help = N_("print only tags of the object"),
+ .flags = PARSE_OPT_LASTARG_DEFAULT,
+ .callback = parse_opt_object_name,
+ .defval = (intptr_t) "HEAD",
},
OPT_STRING( 0 , "format", &format.format, N_("format"),
N_("format to use for the output")),
@@ -650,7 +655,7 @@ int cmd_tag(int argc,
if (repo_get_oid(the_repository, object_ref, &object))
die(_("Failed to resolve '%s' as a valid ref."), object_ref);
- if (strbuf_check_tag_ref(&ref, tag))
+ if (check_tag_ref(&ref, tag))
die(_("'%s' is not a valid tag name."), tag);
if (refs_read_ref(get_main_ref_store(the_repository), ref.buf, &prev))
@@ -675,13 +680,13 @@ int cmd_tag(int argc,
if (create_tag_object) {
if (force_sign_annotate && !annotate)
opt.sign = 1;
- path = git_pathdup("TAG_EDITMSG");
+ path = repo_git_path(the_repository, "TAG_EDITMSG");
create_tag(&object, object_ref, tag, &buf, &opt, &prev, &object,
&trailer_args, path);
}
transaction = ref_store_transaction_begin(get_main_ref_store(the_repository),
- &err);
+ 0, &err);
if (!transaction ||
ref_transaction_update(transaction, ref.buf, &object, &prev,
NULL, NULL,
@@ -706,7 +711,6 @@ int cmd_tag(int argc,
cleanup:
ref_sorting_release(sorting);
ref_filter_clear(&filter);
- ref_format_clear(&format);
strbuf_release(&buf);
strbuf_release(&ref);
strbuf_release(&reflog_msg);