Skip to content

Commit d28d2be

Browse files
committed
Merge branch 'rs/tag-wo-the-repository'
Code clean-up. * rs/tag-wo-the-repository: tag: stop using the_repository tag: support arbitrary repositories in parse_tag() tag: support arbitrary repositories in gpg_verify_tag() tag: use algo of repo parameter in parse_tag_buffer()
2 parents e0bfec3 + 009fcee commit d28d2be

10 files changed

Lines changed: 26 additions & 25 deletions

File tree

builtin/describe.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ static int replace_name(struct commit_name *e,
112112

113113
if (!e->tag) {
114114
t = lookup_tag(the_repository, &e->oid);
115-
if (!t || parse_tag(t))
115+
if (!t || parse_tag(the_repository, t))
116116
return 1;
117117
e->tag = t;
118118
}
119119

120120
t = lookup_tag(the_repository, oid);
121-
if (!t || parse_tag(t))
121+
if (!t || parse_tag(the_repository, t))
122122
return 0;
123123
*tag = t;
124124

@@ -335,7 +335,7 @@ static void append_name(struct commit_name *n, struct strbuf *dst)
335335
{
336336
if (n->prio == 2 && !n->tag) {
337337
n->tag = lookup_tag(the_repository, &n->oid);
338-
if (!n->tag || parse_tag(n->tag))
338+
if (!n->tag || parse_tag(the_repository, n->tag))
339339
die(_("annotated tag %s not available"), n->path);
340340
}
341341
if (n->tag && !n->name_checked) {

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3293,7 +3293,7 @@ static void add_tag_chain(const struct object_id *oid)
32933293

32943294
tag = lookup_tag(the_repository, oid);
32953295
while (1) {
3296-
if (!tag || parse_tag(tag) || !tag->tagged)
3296+
if (!tag || parse_tag(the_repository, tag) || !tag->tagged)
32973297
die(_("unable to pack objects reachable from tag %s"),
32983298
oid_to_hex(oid));
32993299

builtin/tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static int verify_tag(const char *name, const char *ref UNUSED,
149149
if (format->format)
150150
flags = GPG_VERIFY_OMIT_STATUS;
151151

152-
if (gpg_verify_tag(oid, name, flags))
152+
if (gpg_verify_tag(the_repository, oid, name, flags))
153153
return -1;
154154

155155
if (format->format)

builtin/verify-tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ int cmd_verify_tag(int argc,
6161
continue;
6262
}
6363

64-
if (gpg_verify_tag(&oid, name, flags)) {
64+
if (gpg_verify_tag(repo, &oid, name, flags)) {
6565
had_error = 1;
6666
continue;
6767
}

fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ static int fsck_walk_tag(struct tag *tag, void *data, struct fsck_options *optio
474474
{
475475
const char *name = fsck_get_object_name(options, &tag->object.oid);
476476

477-
if (parse_tag(tag))
477+
if (parse_tag(the_repository, tag))
478478
return -1;
479479
if (name)
480480
fsck_put_object_name(options, &tag->tagged->oid, "%s", name);

object-name.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
449449
} else if (type == OBJ_TAG) {
450450
struct tag *tag = lookup_tag(ds->repo, oid);
451451

452-
if (!parse_tag(tag) && tag->tag) {
452+
if (!parse_tag(ds->repo, tag) && tag->tag) {
453453
/*
454454
* TRANSLATORS: This is a line of ambiguous
455455
* tag object output. E.g.:

ref-filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2866,7 +2866,7 @@ static int match_points_at(struct oid_array *points_at,
28662866
while (obj && obj->type == OBJ_TAG) {
28672867
struct tag *tag = (struct tag *)obj;
28682868

2869-
if (parse_tag(tag) < 0) {
2869+
if (parse_tag(the_repository, tag) < 0) {
28702870
obj = NULL;
28712871
break;
28722872
}

tag.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#define USE_THE_REPOSITORY_VARIABLE
21
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "git-compat-util.h"
@@ -13,6 +12,7 @@
1312
#include "gpg-interface.h"
1413
#include "hex.h"
1514
#include "packfile.h"
15+
#include "repository.h"
1616

1717
const char *tag_type = "tag";
1818

@@ -44,28 +44,28 @@ static int run_gpg_verify(const char *buf, unsigned long size, unsigned flags)
4444
return ret;
4545
}
4646

47-
int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
48-
unsigned flags)
47+
int gpg_verify_tag(struct repository *r, const struct object_id *oid,
48+
const char *name_to_report, unsigned flags)
4949
{
5050
enum object_type type;
5151
char *buf;
5252
unsigned long size;
5353
int ret;
5454

55-
type = odb_read_object_info(the_repository->objects, oid, NULL);
55+
type = odb_read_object_info(r->objects, oid, NULL);
5656
if (type != OBJ_TAG)
5757
return error("%s: cannot verify a non-tag object of type %s.",
5858
name_to_report ?
5959
name_to_report :
60-
repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),
60+
oid_to_hex(oid),
6161
type_name(type));
6262

63-
buf = odb_read_object(the_repository->objects, oid, &type, &size);
63+
buf = odb_read_object(r->objects, oid, &type, &size);
6464
if (!buf)
6565
return error("%s: unable to read file.",
6666
name_to_report ?
6767
name_to_report :
68-
repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
68+
oid_to_hex(oid));
6969

7070
ret = run_gpg_verify(buf, size, flags);
7171

@@ -148,9 +148,11 @@ int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, u
148148
FREE_AND_NULL(item->tag);
149149
}
150150

151-
if (size < the_hash_algo->hexsz + 24)
151+
if (size < r->hash_algo->hexsz + 24)
152152
return -1;
153-
if (memcmp("object ", bufptr, 7) || parse_oid_hex(bufptr + 7, &oid, &bufptr) || *bufptr++ != '\n')
153+
if (memcmp("object ", bufptr, 7) ||
154+
parse_oid_hex_algop(bufptr + 7, &oid, &bufptr, r->hash_algo) ||
155+
*bufptr++ != '\n')
154156
return -1;
155157

156158
if (!starts_with(bufptr, "type "))
@@ -201,7 +203,7 @@ int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, u
201203
return 0;
202204
}
203205

204-
int parse_tag(struct tag *item)
206+
int parse_tag(struct repository *r, struct tag *item)
205207
{
206208
enum object_type type;
207209
void *data;
@@ -210,8 +212,7 @@ int parse_tag(struct tag *item)
210212

211213
if (item->object.parsed)
212214
return 0;
213-
data = odb_read_object(the_repository->objects, &item->object.oid,
214-
&type, &size);
215+
data = odb_read_object(r->objects, &item->object.oid, &type, &size);
215216
if (!data)
216217
return error("Could not read %s",
217218
oid_to_hex(&item->object.oid));
@@ -220,7 +221,7 @@ int parse_tag(struct tag *item)
220221
return error("Object %s not a tag",
221222
oid_to_hex(&item->object.oid));
222223
}
223-
ret = parse_tag_buffer(the_repository, item, data, size);
224+
ret = parse_tag_buffer(r, item, data, size);
224225
free(data);
225226
return ret;
226227
}

tag.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ struct tag {
1313
};
1414
struct tag *lookup_tag(struct repository *r, const struct object_id *oid);
1515
int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, unsigned long size);
16-
int parse_tag(struct tag *item);
16+
int parse_tag(struct repository *r, struct tag *item);
1717
void release_tag_memory(struct tag *t);
1818
struct object *deref_tag(struct repository *r, struct object *, const char *, int);
19-
int gpg_verify_tag(const struct object_id *oid,
19+
int gpg_verify_tag(struct repository *r, const struct object_id *oid,
2020
const char *name_to_report, unsigned flags);
2121
struct object_id *get_tagged_oid(struct tag *tag);
2222

walker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static int process_commit(struct walker *walker, struct commit *commit)
115115

116116
static int process_tag(struct walker *walker, struct tag *tag)
117117
{
118-
if (parse_tag(tag))
118+
if (parse_tag(the_repository, tag))
119119
return -1;
120120
return process(walker, tag->tagged);
121121
}

0 commit comments

Comments
 (0)