object: add repository argument to parse_object
Add a repository argument to allow the callers of parse_object to be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Jun 28, 2018 at 18:21 UTC
109cd76dd3467bd05f8d2145b857006649741d5c
33 files changed
+95
-72
builtin/diff-tree.c
+2
-1
@@ -5,6 +5,7 @@
5
#include "log-tree.h"
6
#include "builtin.h"
7
#include "submodule.h"
8
+#include "repository.h"
9
10
static struct rev_info log_tree_opt;
11
@@ -68,7 +69,7 @@ static int diff_tree_stdin(char *line)
69
line[len-1] = 0;
70
if (parse_oid_hex(line, &oid, &p))
71
return -1;
71
- obj = parse_object(&oid);
72
+ obj = parse_object(the_repository, &oid);
73
if (!obj)
74
return -1;
75
if (obj->type == OBJ_COMMIT)
builtin/diff.c
+1
-1
@@ -400,7 +400,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
400
const char *name = entry->name;
401
int flags = (obj->flags & UNINTERESTING);
402
if (!obj->parsed)
403
- obj = parse_object(&obj->oid);
403
+ obj = parse_object(the_repository, &obj->oid);
404
obj = deref_tag(obj, NULL, 0);
405
if (!obj)
406
die(_("invalid object '%s' given."), name);
builtin/fast-export.c
+1
-1
@@ -801,7 +801,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)
801
802
/* handle nested tags */
803
while (tag && tag->object.type == OBJ_TAG) {
804
- parse_object(&tag->object.oid);
804
+ parse_object(the_repository, &tag->object.oid);
805
string_list_append(&extra_refs, full_name)->util = tag;
806
tag = (struct tag *)tag->tagged;
807
}
builtin/fmt-merge-msg.c
+4
-2
@@ -11,6 +11,7 @@
11
#include "branch.h"
12
#include "fmt-merge-msg.h"
13
#include "gpg-interface.h"
14
+#include "repository.h"
15
16
static const char * const fmt_merge_msg_usage[] = {
17
N_("git fmt-merge-msg [-m <message>] [--log[=<n>] | --no-log] [--file <file>]"),
@@ -343,7 +344,8 @@ static void shortlog(const char *name,
344
const struct object_id *oid = &origin_data->oid;
345
int limit = opts->shortlog_len;
346
346
- branch = deref_tag(parse_object(oid), oid_to_hex(oid), GIT_SHA1_HEXSZ);
347
+ branch = deref_tag(parse_object(the_repository, oid), oid_to_hex(oid),
348
+ GIT_SHA1_HEXSZ);
349
if (!branch || branch->type != OBJ_COMMIT)
350
return;
351
@@ -563,7 +565,7 @@ static void find_merge_parents(struct merge_parents *result,
565
* "name" here and we do not want to contaminate its
566
* util field yet.
567
*/
566
- obj = parse_object(&oid);
568
+ obj = parse_object(the_repository, &oid);
569
parent = (struct commit *)peel_to_type(NULL, 0, obj, OBJ_COMMIT);
570
if (!parent)
571
continue;
builtin/fsck.c
+2
-2
@@ -452,7 +452,7 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid,
452
{
453
struct object *obj;
454
455
- obj = parse_object(oid);
455
+ obj = parse_object(the_repository, oid);
456
if (!obj) {
457
if (is_promisor_object(oid)) {
458
/*
@@ -614,7 +614,7 @@ static int fsck_cache_tree(struct cache_tree *it)
614
fprintf(stderr, "Checking cache tree\n");
615
616
if (0 <= it->entry_count) {
617
- struct object *obj = parse_object(&it->oid);
617
+ struct object *obj = parse_object(the_repository, &it->oid);
618
if (!obj) {
619
error("%s: invalid sha1 pointer in cache-tree",
620
oid_to_hex(&it->oid));
builtin/log.c
+2
-1
@@ -30,6 +30,7 @@
30
#include "gpg-interface.h"
31
#include "progress.h"
32
#include "commit-slab.h"
33
+#include "repository.h"
34
35
#define MAIL_DEFAULT_WRAP 72
36
@@ -619,7 +620,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
620
rev.shown_one = 1;
621
if (ret)
622
break;
622
- o = parse_object(&t->tagged->oid);
623
+ o = parse_object(the_repository, &t->tagged->oid);
624
if (!o)
625
ret = error(_("Could not read object %s"),
626
oid_to_hex(&t->tagged->oid));
builtin/name-rev.c
+4
-3
@@ -1,5 +1,6 @@
1
#include "builtin.h"
2
#include "cache.h"
3
+#include "repository.h"
4
#include "config.h"
5
#include "commit.h"
6
#include "tag.h"
@@ -203,7 +204,7 @@ static int tipcmp(const void *a_, const void *b_)
204
205
static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)
206
{
206
- struct object *o = parse_object(oid);
207
+ struct object *o = parse_object(the_repository, oid);
208
struct name_ref_data *data = cb_data;
209
int can_abbreviate_output = data->tags_only && data->name_only;
210
int deref = 0;
@@ -261,7 +262,7 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo
262
struct tag *t = (struct tag *) o;
263
if (!t->tagged)
264
break; /* broken repository */
264
- o = parse_object(&t->tagged->oid);
265
+ o = parse_object(the_repository, &t->tagged->oid);
266
deref = 1;
267
taggerdate = t->date;
268
}
@@ -451,7 +452,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
452
}
453
454
commit = NULL;
454
- object = parse_object(&oid);
455
+ object = parse_object(the_repository, &oid);
456
if (object) {
457
struct object *peeled = deref_tag(object, *argv, 0);
458
if (peeled && peeled->type == OBJ_COMMIT)
builtin/receive-pack.c
+3
-3
@@ -1108,8 +1108,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)
1108
struct object *old_object, *new_object;
1109
struct commit *old_commit, *new_commit;
1110
1111
- old_object = parse_object(old_oid);
1112
- new_object = parse_object(new_oid);
1111
+ old_object = parse_object(the_repository, old_oid);
1112
+ new_object = parse_object(the_repository, new_oid);
1113
1114
if (!old_object || !new_object ||
1115
old_object->type != OBJ_COMMIT ||
@@ -1132,7 +1132,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
1132
1133
if (is_null_oid(new_oid)) {
1134
struct strbuf err = STRBUF_INIT;
1135
- if (!parse_object(old_oid)) {
1135
+ if (!parse_object(the_repository, old_oid)) {
1136
old_oid = NULL;
1137
if (ref_exists(name)) {
1138
rp_warning("Allowing deletion of corrupt ref.");
builtin/reflog.c
+2
-1
@@ -2,6 +2,7 @@
2
#include "config.h"
3
#include "lockfile.h"
4
#include "object-store.h"
5
+#include "repository.h"
6
#include "commit.h"
7
#include "refs.h"
8
#include "dir.h"
@@ -129,7 +130,7 @@ static int commit_is_complete(struct commit *commit)
130
struct commit_list *parent;
131
132
c = (struct commit *)object_array_pop(&study);
132
- if (!c->object.parsed && !parse_object(&c->object.oid))
133
+ if (!c->object.parsed && !parse_object(the_repository, &c->object.oid))
134
c->object.flags |= INCOMPLETE;
135
136
if (c->object.flags & INCOMPLETE) {
builtin/rev-list.c
+1
-1
@@ -239,7 +239,7 @@ static int finish_object(struct object *obj, const char *name, void *cb_data)
239
return 1;
240
}
241
if (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)
242
- parse_object(&obj->oid);
242
+ parse_object(the_repository, &obj->oid);
243
return 0;
244
}
245
bundle.c
+3
-2
@@ -2,6 +2,7 @@
2
#include "lockfile.h"
3
#include "bundle.h"
4
#include "object-store.h"
5
+#include "repository.h"
6
#include "object.h"
7
#include "commit.h"
8
#include "diff.h"
@@ -142,7 +143,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
143
init_revisions(&revs, NULL);
144
for (i = 0; i < p->nr; i++) {
145
struct ref_list_entry *e = p->list + i;
145
- struct object *o = parse_object(&e->oid);
146
+ struct object *o = parse_object(the_repository, &e->oid);
147
if (o) {
148
o->flags |= PREREQ_MARK;
149
add_pending_object(&revs, o, e->name);
@@ -167,7 +168,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
168
169
for (i = 0; i < p->nr; i++) {
170
struct ref_list_entry *e = p->list + i;
170
- struct object *o = parse_object(&e->oid);
171
+ struct object *o = parse_object(the_repository, &e->oid);
172
assert(o); /* otherwise we'd have returned early */
173
if (o->flags & SHOWN)
174
continue;
commit.c
+3
-2
@@ -27,7 +27,8 @@ const char *commit_type = "commit";
27
struct commit *lookup_commit_reference_gently(const struct object_id *oid,
28
int quiet)
29
{
30
- struct object *obj = deref_tag(parse_object(oid), NULL, 0);
30
+ struct object *obj = deref_tag(parse_object(the_repository, oid),
31
+ NULL, 0);
32
33
if (!obj)
34
return NULL;
@@ -1692,7 +1693,7 @@ struct commit *get_merge_parent(const char *name)
1693
struct object_id oid;
1694
if (get_oid(name, &oid))
1695
return NULL;
1695
- obj = parse_object(&oid);
1696
+ obj = parse_object(the_repository, &oid);
1697
commit = (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);
1698
if (commit && !merge_remote_util(commit))
1699
set_merge_remote_desc(commit, name, obj);
fetch-pack.c
+10
-8
@@ -84,7 +84,7 @@ static void cache_one_alternate(const char *refname,
84
void *vcache)
85
{
86
struct alternate_object_cache *cache = vcache;
87
- struct object *obj = parse_object(oid);
87
+ struct object *obj = parse_object(the_repository, oid);
88
89
if (!obj || (obj->flags & ALTERNATE))
90
return;
@@ -126,7 +126,8 @@ static void rev_list_push(struct commit *commit, int mark)
126
127
static int rev_list_insert_ref(const char *refname, const struct object_id *oid)
128
{
129
- struct object *o = deref_tag(parse_object(oid), refname, 0);
129
+ struct object *o = deref_tag(parse_object(the_repository, oid),
130
+ refname, 0);
131
132
if (o && o->type == OBJ_COMMIT)
133
rev_list_push((struct commit *)o, SEEN);
@@ -143,7 +144,8 @@ static int rev_list_insert_ref_oid(const char *refname, const struct object_id *
144
static int clear_marks(const char *refname, const struct object_id *oid,
145
int flag, void *cb_data)
146
{
146
- struct object *o = deref_tag(parse_object(oid), refname, 0);
147
+ struct object *o = deref_tag(parse_object(the_repository, oid),
148
+ refname, 0);
149
150
if (o && o->type == OBJ_COMMIT)
151
clear_commit_marks((struct commit *)o,
@@ -437,7 +439,7 @@ static int find_common(struct fetch_pack_args *args,
439
if (!lookup_object(oid.hash))
440
die(_("object not found: %s"), line);
441
/* make sure that it is parsed as shallow */
440
- if (!parse_object(&oid))
442
+ if (!parse_object(the_repository, &oid))
443
die(_("error in object: %s"), line);
444
if (unregister_shallow(&oid))
445
die(_("no shallow found: %s"), line);
@@ -570,14 +572,14 @@ static struct commit_list *complete;
572
573
static int mark_complete(const struct object_id *oid)
574
{
573
- struct object *o = parse_object(oid);
575
+ struct object *o = parse_object(the_repository, oid);
576
577
while (o && o->type == OBJ_TAG) {
578
struct tag *t = (struct tag *) o;
579
if (!t->tagged)
580
break; /* broken repository */
581
o->flags |= COMPLETE;
580
- o = parse_object(&t->tagged->oid);
582
+ o = parse_object(the_repository, &t->tagged->oid);
583
}
584
if (o && o->type == OBJ_COMMIT) {
585
struct commit *commit = (struct commit *)o;
@@ -768,7 +770,7 @@ static int everything_local(struct fetch_pack_args *args,
770
771
if (!has_object_file_with_flags(&ref->old_oid, flags))
772
continue;
771
- o = parse_object(&ref->old_oid);
773
+ o = parse_object(the_repository, &ref->old_oid);
774
if (!o)
775
continue;
776
@@ -1318,7 +1320,7 @@ static void receive_shallow_info(struct fetch_pack_args *args,
1320
if (!lookup_object(oid.hash))
1321
die(_("object not found: %s"), reader->line);
1322
/* make sure that it is parsed as shallow */
1321
- if (!parse_object(&oid))
1323
+ if (!parse_object(the_repository, &oid))
1324
die(_("error in object: %s"), reader->line);
1325
if (unregister_shallow(&oid))
1326
die(_("no shallow found: %s"), reader->line);
fsck.c
+2
-1
@@ -1,5 +1,6 @@
1
#include "cache.h"
2
#include "object-store.h"
3
+#include "repository.h"
4
#include "object.h"
5
#include "blob.h"
6
#include "tree.h"
@@ -511,7 +512,7 @@ int fsck_walk(struct object *obj, void *data, struct fsck_options *options)
512
return -1;
513
514
if (obj->type == OBJ_NONE)
514
- parse_object(&obj->oid);
515
+ parse_object(the_repository, &obj->oid);
516
517
switch (obj->type) {
518
case OBJ_BLOB:
http-backend.c
+1
-1
@@ -436,7 +436,7 @@ static int show_text_ref(const char *name, const struct object_id *oid,
436
{
437
const char *name_nons = strip_namespace(name);
438
struct strbuf *buf = cb_data;
439
- struct object *o = parse_object(oid);
439
+ struct object *o = parse_object(the_repository, oid);
440
if (!o)
441
return 0;
442
http-push.c
+4
-2
@@ -1,4 +1,5 @@
1
#include "cache.h"
2
+#include "repository.h"
3
#include "commit.h"
4
#include "tag.h"
5
#include "blob.h"
@@ -14,6 +15,7 @@
15
#include "packfile.h"
16
#include "object-store.h"
17
18
+
19
#ifdef EXPAT_NEEDS_XMLPARSE_H
20
#include <xmlparse.h>
21
#else
@@ -722,7 +724,7 @@ static void one_remote_object(const struct object_id *oid)
724
725
obj = lookup_object(oid->hash);
726
if (!obj)
725
- obj = parse_object(oid);
727
+ obj = parse_object(the_repository, oid);
728
729
/* Ignore remote objects that don't exist locally */
730
if (!obj)
@@ -1459,7 +1461,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)
1461
return;
1462
}
1463
1462
- o = parse_object(&ref->old_oid);
1464
+ o = parse_object(the_repository, &ref->old_oid);
1465
if (!o) {
1466
fprintf(stderr,
1467
"Unable to parse object %s for remote ref %s\n",
log-tree.c
+4
-3
@@ -2,6 +2,7 @@
2
#include "config.h"
3
#include "diff.h"
4
#include "object-store.h"
5
+#include "repository.h"
6
#include "commit.h"
7
#include "tag.h"
8
#include "graph.h"
@@ -98,13 +99,13 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,
99
warning("invalid replace ref %s", refname);
100
return 0;
101
}
101
- obj = parse_object(&original_oid);
102
+ obj = parse_object(the_repository, &original_oid);
103
if (obj)
104
add_name_decoration(DECORATION_GRAFTED, "replaced", obj);
105
return 0;
106
}
107
107
- obj = parse_object(oid);
108
+ obj = parse_object(the_repository, oid);
109
if (!obj)
110
return 0;
111
@@ -125,7 +126,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,
126
if (!obj)
127
break;
128
if (!obj->parsed)
128
- parse_object(&obj->oid);
129
+ parse_object(the_repository, &obj->oid);
130
add_name_decoration(DECORATION_REF_TAG, refname, obj);
131
}
132
return 0;
merge-recursive.c
+3
-1
@@ -9,6 +9,7 @@
9
#include "lockfile.h"
10
#include "cache-tree.h"
11
#include "object-store.h"
12
+#include "repository.h"
13
#include "commit.h"
14
#include "blob.h"
15
#include "builtin.h"
@@ -3466,7 +3467,8 @@ static struct commit *get_ref(const struct object_id *oid, const char *name)
3467
{
3468
struct object *object;
3469
3469
- object = deref_tag(parse_object(oid), name, strlen(name));
3470
+ object = deref_tag(parse_object(the_repository, oid), name,
3471
+ strlen(name));
3472
if (!object)
3473
return NULL;
3474
if (object->type == OBJ_TREE)
object.c
+2
-2
@@ -239,14 +239,14 @@ struct object *parse_object_buffer(const struct object_id *oid, enum object_type
239
struct object *parse_object_or_die(const struct object_id *oid,
240
const char *name)
241
{
242
- struct object *o = parse_object(oid);
242
+ struct object *o = parse_object(the_repository, oid);
243
if (o)
244
return o;
245
246
die(_("unable to parse object: %s"), name ? name : oid_to_hex(oid));
247
}
248
249
-struct object *parse_object(const struct object_id *oid)
249
+struct object *parse_object_the_repository(const struct object_id *oid)
250
{
251
unsigned long size;
252
enum object_type type;
object.h
+2
-1
@@ -120,7 +120,8 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet);
120
*
121
* Returns NULL if the object is missing or corrupt.
122
*/
123
-struct object *parse_object(const struct object_id *oid);
123
+#define parse_object(r, oid) parse_object_##r(oid)
124
+struct object *parse_object_the_repository(const struct object_id *oid);
125
126
/*
127
* Like parse_object, but will die() instead of returning NULL. If the
packfile.c
+1
-1
@@ -1934,7 +1934,7 @@ static int add_promisor_object(const struct object_id *oid,
1934
void *set_)
1935
{
1936
struct oidset *set = set_;
1937
- struct object *obj = parse_object(oid);
1937
+ struct object *obj = parse_object(the_repository, oid);
1938
if (!obj)
1939
return 1;
1940
pretty.c
+1
-1
@@ -1146,7 +1146,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
1146
1147
/* these depend on the commit */
1148
if (!commit->object.parsed)
1149
- parse_object(&commit->object.oid);
1149
+ parse_object(the_repository, &commit->object.oid);
1150
1151
switch (placeholder[0]) {
1152
case 'H': /* commit hash */
ref-filter.c
+2
-1
@@ -4,6 +4,7 @@
4
#include "refs.h"
5
#include "wildmatch.h"
6
#include "object-store.h"
7
+#include "repository.h"
8
#include "commit.h"
9
#include "remote.h"
10
#include "color.h"
@@ -1914,7 +1915,7 @@ static const struct object_id *match_points_at(struct oid_array *points_at,
1915
1916
if (oid_array_lookup(points_at, oid) >= 0)
1917
return oid;
1917
- obj = parse_object(oid);
1918
+ obj = parse_object(the_repository, oid);
1919
if (!obj)
1920
die(_("malformed object at '%s'"), refname);
1921
if (obj->type == OBJ_TAG)
reflog-walk.c
+2
-1
@@ -305,7 +305,8 @@ static struct commit *next_reflog_commit(struct commit_reflog *log)
305
{
306
for (; log->recno >= 0; log->recno--) {
307
struct reflog_info *entry = &log->reflogs->items[log->recno];
308
- struct object *obj = parse_object(&entry->noid);
308
+ struct object *obj = parse_object(the_repository,
309
+ &entry->noid);
310
311
if (obj && obj->type == OBJ_COMMIT)
312
return (struct commit *)obj;
refs/files-backend.c
+1
-1
@@ -1660,7 +1660,7 @@ static int write_ref_to_lockfile(struct ref_lock *lock,
1660
struct object *o;
1661
int fd;
1662
1663
- o = parse_object(oid);
1663
+ o = parse_object(the_repository, oid);
1664
if (!o) {
1665
strbuf_addf(err,
1666
"trying to write ref '%s' with nonexistent object %s",
remote.c
+2
-2
@@ -1801,12 +1801,12 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
1801
* Both new_commit and old_commit must be commit-ish and new_commit is descendant of
1802
* old_commit. Otherwise we require --force.
1803
*/
1804
- o = deref_tag(parse_object(old_oid), NULL, 0);
1804
+ o = deref_tag(parse_object(the_repository, old_oid), NULL, 0);
1805
if (!o || o->type != OBJ_COMMIT)
1806
return 0;
1807
old_commit = (struct commit *) o;
1808
1809
- o = deref_tag(parse_object(new_oid), NULL, 0);
1809
+ o = deref_tag(parse_object(the_repository, new_oid), NULL, 0);
1810
if (!o || o->type != OBJ_COMMIT)
1811
return 0;
1812
new_commit = (struct commit *) o;
revision.c
+7
-7
@@ -197,7 +197,7 @@ void add_head_to_pending(struct rev_info *revs)
197
struct object *obj;
198
if (get_oid("HEAD", &oid))
199
return;
200
- obj = parse_object(&oid);
200
+ obj = parse_object(the_repository, &oid);
201
if (!obj)
202
return;
203
add_pending_object(revs, obj, "HEAD");
@@ -209,7 +209,7 @@ static struct object *get_reference(struct rev_info *revs, const char *name,
209
{
210
struct object *object;
211
212
- object = parse_object(oid);
212
+ object = parse_object(the_repository, oid);
213
if (!object) {
214
if (revs->ignore_missing)
215
return object;
@@ -246,7 +246,7 @@ static struct commit *handle_commit(struct rev_info *revs,
246
add_pending_object(revs, object, tag->tag);
247
if (!tag->tagged)
248
die("bad tag");
249
- object = parse_object(&tag->tagged->oid);
249
+ object = parse_object(the_repository, &tag->tagged->oid);
250
if (!object) {
251
if (revs->ignore_missing_links || (flags & UNINTERESTING))
252
return NULL;
@@ -1249,7 +1249,7 @@ static void handle_one_reflog_commit(struct object_id *oid, void *cb_data)
1249
{
1250
struct all_refs_cb *cb = cb_data;
1251
if (!is_null_oid(oid)) {
1252
- struct object *o = parse_object(oid);
1252
+ struct object *o = parse_object(the_repository, oid);
1253
if (o) {
1254
o->flags |= cb->all_flags;
1255
/* ??? CMDLINEFLAGS ??? */
@@ -1577,8 +1577,8 @@ static int handle_dotdot_1(const char *arg, char *dotdot,
1577
*dotdot = '\0';
1578
}
1579
1580
- a_obj = parse_object(&a_oid);
1581
- b_obj = parse_object(&b_oid);
1580
+ a_obj = parse_object(the_repository, &a_oid);
1581
+ b_obj = parse_object(the_repository, &b_oid);
1582
if (!a_obj || !b_obj)
1583
return dotdot_missing(arg, dotdot, revs, symmetric);
1584
@@ -2883,7 +2883,7 @@ static int mark_uninteresting(const struct object_id *oid,
2883
uint32_t pos,
2884
void *unused)
2885
{
2886
- struct object *o = parse_object(oid);
2886
+ struct object *o = parse_object(the_repository, oid);
2887
o->flags |= UNINTERESTING | SEEN;
2888
return 0;
2889
}
server-info.c
+1
-1
@@ -56,7 +56,7 @@ static int add_info_ref(const char *path, const struct object_id *oid,
56
int flag, void *cb_data)
57
{
58
FILE *fp = cb_data;
59
- struct object *o = parse_object(oid);
59
+ struct object *o = parse_object(the_repository, oid);
60
if (!o)
61
return -1;
62
sha1-name.c
+7
-7
@@ -239,7 +239,7 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da
239
return 0;
240
241
/* We need to do this the hard way... */
242
- obj = deref_tag(parse_object(oid), NULL, 0);
242
+ obj = deref_tag(parse_object(the_repository, oid), NULL, 0);
243
if (obj && obj->type == OBJ_COMMIT)
244
return 1;
245
return 0;
@@ -263,7 +263,7 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_
263
return 0;
264
265
/* We need to do this the hard way... */
266
- obj = deref_tag(parse_object(oid), NULL, 0);
266
+ obj = deref_tag(parse_object(the_repository, oid), NULL, 0);
267
if (obj && (obj->type == OBJ_TREE || obj->type == OBJ_COMMIT))
268
return 1;
269
return 0;
@@ -891,7 +891,7 @@ struct object *peel_to_type(const char *name, int namelen,
891
if (name && !namelen)
892
namelen = strlen(name);
893
while (1) {
894
- if (!o || (!o->parsed && !parse_object(&o->oid)))
894
+ if (!o || (!o->parsed && !parse_object(the_repository, &o->oid)))
895
return NULL;
896
if (expected_type == OBJ_ANY || o->type == expected_type)
897
return o;
@@ -964,12 +964,12 @@ static int peel_onion(const char *name, int len, struct object_id *oid,
964
if (get_oid_1(name, sp - name - 2, &outer, lookup_flags))
965
return -1;
966
967
- o = parse_object(&outer);
967
+ o = parse_object(the_repository, &outer);
968
if (!o)
969
return -1;
970
if (!expected_type) {
971
o = deref_tag(o, name, sp - name - 2);
972
- if (!o || (!o->parsed && !parse_object(&o->oid)))
972
+ if (!o || (!o->parsed && !parse_object(the_repository, &o->oid)))
973
return -1;
974
oidcpy(oid, &o->oid);
975
return 0;
@@ -1096,7 +1096,7 @@ static int handle_one_ref(const char *path, const struct object_id *oid,
1096
int flag, void *cb_data)
1097
{
1098
struct commit_list **list = cb_data;
1099
- struct object *object = parse_object(oid);
1099
+ struct object *object = parse_object(the_repository, oid);
1100
if (!object)
1101
return 0;
1102
if (object->type == OBJ_TAG) {
@@ -1142,7 +1142,7 @@ static int get_oid_oneline(const char *prefix, struct object_id *oid,
1142
int matches;
1143
1144
commit = pop_most_recent_commit(&list, ONELINE_SEEN);
1145
- if (!parse_object(&commit->object.oid))
1145
+ if (!parse_object(the_repository, &commit->object.oid))
1146
continue;
1147
buf = get_commit_buffer(commit, NULL);
1148
p = strstr(buf, "\n\n");
tag.c
+3
-2
@@ -68,7 +68,8 @@ struct object *deref_tag(struct object *o, const char *warn, int warnlen)
68
{
69
while (o && o->type == OBJ_TAG)
70
if (((struct tag *)o)->tagged)
71
- o = parse_object(&((struct tag *)o)->tagged->oid);
71
+ o = parse_object(the_repository,
72
+ &((struct tag *)o)->tagged->oid);
73
else
74
o = NULL;
75
if (!o && warn) {
@@ -82,7 +83,7 @@ struct object *deref_tag(struct object *o, const char *warn, int warnlen)
83
struct object *deref_tag_noverify(struct object *o)
84
{
85
while (o && o->type == OBJ_TAG) {
85
- o = parse_object(&o->oid);
86
+ o = parse_object(the_repository, &o->oid);
87
if (o && o->type == OBJ_TAG && ((struct tag *)o)->tagged)
88
o = ((struct tag *)o)->tagged;
89
else
tree.c
+3
-2
@@ -8,6 +8,7 @@
8
#include "tag.h"
9
#include "alloc.h"
10
#include "tree-walk.h"
11
+#include "repository.h"
12
13
const char *tree_type = "tree";
14
@@ -244,7 +245,7 @@ void free_tree_buffer(struct tree *tree)
245
246
struct tree *parse_tree_indirect(const struct object_id *oid)
247
{
247
- struct object *obj = parse_object(oid);
248
+ struct object *obj = parse_object(the_repository, oid);
249
do {
250
if (!obj)
251
return NULL;
@@ -257,6 +258,6 @@ struct tree *parse_tree_indirect(const struct object_id *oid)
258
else
259
return NULL;
260
if (!obj->parsed)
260
- parse_object(&obj->oid);
261
+ parse_object(the_repository, &obj->oid);
262
} while (1);
263
}
upload-pack.c
+7
-6
@@ -3,6 +3,7 @@
3
#include "refs.h"
4
#include "pkt-line.h"
5
#include "sideband.h"
6
+#include "repository.h"
7
#include "object-store.h"
8
#include "tag.h"
9
#include "object.h"
@@ -311,7 +312,7 @@ static int got_oid(const char *hex, struct object_id *oid)
312
if (!has_object_file(oid))
313
return -1;
314
314
- o = parse_object(oid);
315
+ o = parse_object(the_repository, oid);
316
if (!o)
317
die("oops (%s)", oid_to_hex(oid));
318
if (o->type == OBJ_COMMIT) {
@@ -349,7 +350,7 @@ static int reachable(struct commit *want)
350
break;
351
}
352
if (!commit->object.parsed)
352
- parse_object(&commit->object.oid);
353
+ parse_object(the_repository, &commit->object.oid);
354
if (commit->object.flags & REACHABLE)
355
continue;
356
commit->object.flags |= REACHABLE;
@@ -800,7 +801,7 @@ static int process_shallow(const char *line, struct object_array *shallows)
801
struct object *object;
802
if (get_oid_hex(arg, &oid))
803
die("invalid shallow line: %s", line);
803
- object = parse_object(&oid);
804
+ object = parse_object(the_repository, &oid);
805
if (!object)
806
return 1;
807
if (object->type != OBJ_COMMIT)
@@ -926,7 +927,7 @@ static void receive_needs(void)
927
if (allow_filter && parse_feature_request(features, "filter"))
928
filter_capability_requested = 1;
929
929
- o = parse_object(&oid_buf);
930
+ o = parse_object(the_repository, &oid_buf);
931
if (!o) {
932
packet_write_fmt(1,
933
"ERR upload-pack: not our ref %s",
@@ -1167,7 +1168,7 @@ static int parse_want(const char *line)
1168
die("git upload-pack: protocol error, "
1169
"expected to get oid, not '%s'", line);
1170
1170
- o = parse_object(&oid);
1171
+ o = parse_object(the_repository, &oid);
1172
if (!o) {
1173
packet_write_fmt(1,
1174
"ERR upload-pack: not our ref %s",
@@ -1279,7 +1280,7 @@ static int process_haves(struct oid_array *haves, struct oid_array *common)
1280
1281
oid_array_append(common, oid);
1282
1282
- o = parse_object(oid);
1283
+ o = parse_object(the_repository, oid);
1284
if (!o)
1285
die("oops (%s)", oid_to_hex(oid));
1286
if (o->type == OBJ_COMMIT) {
walker.c
+2
-1
@@ -1,5 +1,6 @@
1
#include "cache.h"
2
#include "walker.h"
3
+#include "repository.h"
4
#include "object-store.h"
5
#include "commit.h"
6
#include "tree.h"
@@ -178,7 +179,7 @@ static int loop(struct walker *walker)
179
}
180
}
181
if (!obj->type)
181
- parse_object(&obj->oid);
182
+ parse_object(the_repository, &obj->oid);
183
if (process_object(walker, obj))
184
return -1;
185
}