summaryrefslogtreecommitdiff
path: root/tag.c
diff options
context:
space:
mode:
Diffstat (limited to 'tag.c')
-rw-r--r--tag.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/tag.c b/tag.c
index 71b5444..fc3834d 100644
--- a/tag.c
+++ b/tag.c
@@ -1,11 +1,14 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "environment.h"
#include "tag.h"
-#include "object-store.h"
+#include "object-name.h"
+#include "object-store-ll.h"
#include "commit.h"
#include "tree.h"
#include "blob.h"
#include "alloc.h"
#include "gpg-interface.h"
+#include "hex.h"
#include "packfile.h"
const char *tag_type = "tag";
@@ -13,26 +16,28 @@ const char *tag_type = "tag";
static int run_gpg_verify(const char *buf, unsigned long size, unsigned flags)
{
struct signature_check sigc;
- size_t payload_size;
+ struct strbuf payload = STRBUF_INIT;
+ struct strbuf signature = STRBUF_INIT;
int ret;
memset(&sigc, 0, sizeof(sigc));
- payload_size = parse_signature(buf, size);
-
- if (size == payload_size) {
+ if (!parse_signature(buf, size, &payload, &signature)) {
if (flags & GPG_VERIFY_VERBOSE)
- write_in_full(1, buf, payload_size);
+ write_in_full(1, buf, size);
return error("no signature found");
}
- ret = check_signature(buf, payload_size, buf + payload_size,
- size - payload_size, &sigc);
+ sigc.payload_type = SIGNATURE_PAYLOAD_TAG;
+ sigc.payload = strbuf_detach(&payload, &sigc.payload_len);
+ ret = check_signature(&sigc, signature.buf, signature.len);
if (!(flags & GPG_VERIFY_OMIT_STATUS))
print_signature_buffer(&sigc, flags);
signature_check_clear(&sigc);
+ strbuf_release(&payload);
+ strbuf_release(&signature);
return ret;
}
@@ -49,15 +54,15 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
return error("%s: cannot verify a non-tag object of type %s.",
name_to_report ?
name_to_report :
- find_unique_abbrev(oid, DEFAULT_ABBREV),
+ repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),
type_name(type));
- buf = read_object_file(oid, &type, &size);
+ buf = repo_read_object_file(the_repository, oid, &type, &size);
if (!buf)
return error("%s: unable to read file.",
name_to_report ?
name_to_report :
- find_unique_abbrev(oid, DEFAULT_ABBREV));
+ repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
ret = run_gpg_verify(buf, size, flags);
@@ -103,7 +108,7 @@ struct tag *lookup_tag(struct repository *r, const struct object_id *oid)
struct object *obj = lookup_object(r, oid);
if (!obj)
return create_object(r, oid, alloc_tag_node(r));
- return object_as_type(r, obj, OBJ_TAG, 0);
+ return object_as_type(obj, OBJ_TAG, 0);
}
static timestamp_t parse_tag_date(const char *buf, const char *tail)
@@ -214,7 +219,8 @@ int parse_tag(struct tag *item)
if (item->object.parsed)
return 0;
- data = read_object_file(&item->object.oid, &type, &size);
+ data = repo_read_object_file(the_repository, &item->object.oid, &type,
+ &size);
if (!data)
return error("Could not read %s",
oid_to_hex(&item->object.oid));