Skip to content

Commit 109cd76

Browse files
stefanbellergitster
authored andcommitted
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>
1 parent b16b60f commit 109cd76

33 files changed

+95
-72
lines changed

builtin/diff-tree.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "log-tree.h"
66
#include "builtin.h"
77
#include "submodule.h"
8+
#include "repository.h"
89

910
static struct rev_info log_tree_opt;
1011

@@ -68,7 +69,7 @@ static int diff_tree_stdin(char *line)
6869
line[len-1] = 0;
6970
if (parse_oid_hex(line, &oid, &p))
7071
return -1;
71-
obj = parse_object(&oid);
72+
obj = parse_object(the_repository, &oid);
7273
if (!obj)
7374
return -1;
7475
if (obj->type == OBJ_COMMIT)

builtin/diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
400400
const char *name = entry->name;
401401
int flags = (obj->flags & UNINTERESTING);
402402
if (!obj->parsed)
403-
obj = parse_object(&obj->oid);
403+
obj = parse_object(the_repository, &obj->oid);
404404
obj = deref_tag(obj, NULL, 0);
405405
if (!obj)
406406
die(_("invalid object '%s' given."), name);

builtin/fast-export.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)
801801

802802
/* handle nested tags */
803803
while (tag && tag->object.type == OBJ_TAG) {
804-
parse_object(&tag->object.oid);
804+
parse_object(the_repository, &tag->object.oid);
805805
string_list_append(&extra_refs, full_name)->util = tag;
806806
tag = (struct tag *)tag->tagged;
807807
}

builtin/fmt-merge-msg.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "branch.h"
1212
#include "fmt-merge-msg.h"
1313
#include "gpg-interface.h"
14+
#include "repository.h"
1415

1516
static const char * const fmt_merge_msg_usage[] = {
1617
N_("git fmt-merge-msg [-m <message>] [--log[=<n>] | --no-log] [--file <file>]"),
@@ -343,7 +344,8 @@ static void shortlog(const char *name,
343344
const struct object_id *oid = &origin_data->oid;
344345
int limit = opts->shortlog_len;
345346

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);
347349
if (!branch || branch->type != OBJ_COMMIT)
348350
return;
349351

@@ -563,7 +565,7 @@ static void find_merge_parents(struct merge_parents *result,
563565
* "name" here and we do not want to contaminate its
564566
* util field yet.
565567
*/
566-
obj = parse_object(&oid);
568+
obj = parse_object(the_repository, &oid);
567569
parent = (struct commit *)peel_to_type(NULL, 0, obj, OBJ_COMMIT);
568570
if (!parent)
569571
continue;

builtin/fsck.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid,
452452
{
453453
struct object *obj;
454454

455-
obj = parse_object(oid);
455+
obj = parse_object(the_repository, oid);
456456
if (!obj) {
457457
if (is_promisor_object(oid)) {
458458
/*
@@ -614,7 +614,7 @@ static int fsck_cache_tree(struct cache_tree *it)
614614
fprintf(stderr, "Checking cache tree\n");
615615

616616
if (0 <= it->entry_count) {
617-
struct object *obj = parse_object(&it->oid);
617+
struct object *obj = parse_object(the_repository, &it->oid);
618618
if (!obj) {
619619
error("%s: invalid sha1 pointer in cache-tree",
620620
oid_to_hex(&it->oid));

builtin/log.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "gpg-interface.h"
3131
#include "progress.h"
3232
#include "commit-slab.h"
33+
#include "repository.h"
3334

3435
#define MAIL_DEFAULT_WRAP 72
3536

@@ -619,7 +620,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
619620
rev.shown_one = 1;
620621
if (ret)
621622
break;
622-
o = parse_object(&t->tagged->oid);
623+
o = parse_object(the_repository, &t->tagged->oid);
623624
if (!o)
624625
ret = error(_("Could not read object %s"),
625626
oid_to_hex(&t->tagged->oid));

builtin/name-rev.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "builtin.h"
22
#include "cache.h"
3+
#include "repository.h"
34
#include "config.h"
45
#include "commit.h"
56
#include "tag.h"
@@ -203,7 +204,7 @@ static int tipcmp(const void *a_, const void *b_)
203204

204205
static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)
205206
{
206-
struct object *o = parse_object(oid);
207+
struct object *o = parse_object(the_repository, oid);
207208
struct name_ref_data *data = cb_data;
208209
int can_abbreviate_output = data->tags_only && data->name_only;
209210
int deref = 0;
@@ -261,7 +262,7 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo
261262
struct tag *t = (struct tag *) o;
262263
if (!t->tagged)
263264
break; /* broken repository */
264-
o = parse_object(&t->tagged->oid);
265+
o = parse_object(the_repository, &t->tagged->oid);
265266
deref = 1;
266267
taggerdate = t->date;
267268
}
@@ -451,7 +452,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
451452
}
452453

453454
commit = NULL;
454-
object = parse_object(&oid);
455+
object = parse_object(the_repository, &oid);
455456
if (object) {
456457
struct object *peeled = deref_tag(object, *argv, 0);
457458
if (peeled && peeled->type == OBJ_COMMIT)

builtin/receive-pack.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,8 +1108,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)
11081108
struct object *old_object, *new_object;
11091109
struct commit *old_commit, *new_commit;
11101110

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);
11131113

11141114
if (!old_object || !new_object ||
11151115
old_object->type != OBJ_COMMIT ||
@@ -1132,7 +1132,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
11321132

11331133
if (is_null_oid(new_oid)) {
11341134
struct strbuf err = STRBUF_INIT;
1135-
if (!parse_object(old_oid)) {
1135+
if (!parse_object(the_repository, old_oid)) {
11361136
old_oid = NULL;
11371137
if (ref_exists(name)) {
11381138
rp_warning("Allowing deletion of corrupt ref.");

builtin/reflog.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "config.h"
33
#include "lockfile.h"
44
#include "object-store.h"
5+
#include "repository.h"
56
#include "commit.h"
67
#include "refs.h"
78
#include "dir.h"
@@ -129,7 +130,7 @@ static int commit_is_complete(struct commit *commit)
129130
struct commit_list *parent;
130131

131132
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))
133134
c->object.flags |= INCOMPLETE;
134135

135136
if (c->object.flags & INCOMPLETE) {

builtin/rev-list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ static int finish_object(struct object *obj, const char *name, void *cb_data)
239239
return 1;
240240
}
241241
if (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)
242-
parse_object(&obj->oid);
242+
parse_object(the_repository, &obj->oid);
243243
return 0;
244244
}
245245

0 commit comments

Comments
 (0)