Skip to content

Commit 346cbec

Browse files
committed
object.c: parse_object_or_die() accept r as parameter
`parse_object_or_die()` and its callers are modified to enable passing `r` as an argument to `parse_object_or_die()`. Refer commit 60ffcbd. Signed-off-by: Parth Gala <parthpgala@gmail.com>
1 parent 21e58f7 commit 346cbec

8 files changed

Lines changed: 24 additions & 14 deletions

File tree

builtin/grep.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ static int grep_submodule(struct grep_opt *opt,
396396
const char *filename, const char *path, int cached)
397397
{
398398
struct repository subrepo;
399+
struct repository *r = the_repository;
399400
struct repository *superproject = opt->repo;
400401
const struct submodule *sub;
401402
struct grep_opt subopt;
@@ -444,7 +445,7 @@ static int grep_submodule(struct grep_opt *opt,
444445
struct strbuf base = STRBUF_INIT;
445446

446447
obj_read_lock();
447-
object = parse_object_or_die(oid, oid_to_hex(oid));
448+
object = parse_object_or_die(r, oid, oid_to_hex(oid));
448449
obj_read_unlock();
449450
data = read_object_with_reference(&subrepo,
450451
&object->oid, tree_type,
@@ -790,6 +791,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
790791
const char *show_in_pager = NULL, *default_pager = "dummy";
791792
struct grep_opt opt;
792793
struct object_array list = OBJECT_ARRAY_INIT;
794+
struct repository *r = the_repository;
793795
struct pathspec pathspec;
794796
struct string_list path_list = STRING_LIST_INIT_NODUP;
795797
int i;
@@ -1028,7 +1030,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
10281030
break;
10291031
}
10301032

1031-
object = parse_object_or_die(&oid, arg);
1033+
object = parse_object_or_die(r, &oid, arg);
10321034
if (!seen_dashdash)
10331035
verify_non_filename(prefix, arg);
10341036
add_object_array_with_path(object, arg, &list, oc.mode, oc.path);

builtin/prune.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ static void remove_temporary_files(const char *path)
125125
int cmd_prune(int argc, const char **argv, const char *prefix)
126126
{
127127
struct rev_info revs;
128+
struct repository *r = the_repository;
128129
int exclude_promisor_objects = 0;
129130
const struct option options[] = {
130131
OPT__DRY_RUN(&show_only, N_("do not remove, show only")),
@@ -154,7 +155,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
154155
const char *name = *argv++;
155156

156157
if (!get_oid(name, &oid)) {
157-
struct object *object = parse_object_or_die(&oid,
158+
struct object *object = parse_object_or_die(r, &oid,
158159
name);
159160
add_pending_object(&revs, object, "");
160161
}

bundle.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ static int compute_and_write_prerequisites(int bundle_fd,
298298
{
299299
struct child_process rls = CHILD_PROCESS_INIT;
300300
struct strbuf buf = STRBUF_INIT;
301+
struct repository *r = the_repository;
301302
FILE *rls_fout;
302303
int i;
303304

@@ -316,13 +317,13 @@ static int compute_and_write_prerequisites(int bundle_fd,
316317
if (buf.len > 0 && buf.buf[0] == '-') {
317318
write_or_die(bundle_fd, buf.buf, buf.len);
318319
if (!get_oid_hex(buf.buf + 1, &oid)) {
319-
struct object *object = parse_object_or_die(&oid,
320+
struct object *object = parse_object_or_die(r, &oid,
320321
buf.buf);
321322
object->flags |= UNINTERESTING;
322323
add_pending_object(revs, object, buf.buf);
323324
}
324325
} else if (!get_oid_hex(buf.buf, &oid)) {
325-
struct object *object = parse_object_or_die(&oid,
326+
struct object *object = parse_object_or_die(r, &oid,
326327
buf.buf);
327328
object->flags |= SHOWN;
328329
}
@@ -347,6 +348,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
347348
{
348349
int i;
349350
int ref_count = 0;
351+
struct repository *r = the_repository;
350352

351353
for (i = 0; i < revs->pending.nr; i++) {
352354
struct object_array_entry *e = revs->pending.objects + i;
@@ -407,7 +409,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
407409
* end up triggering "empty bundle"
408410
* error.
409411
*/
410-
obj = parse_object_or_die(&oid, e->name);
412+
obj = parse_object_or_die(r, &oid, e->name);
411413
obj->flags |= SHOWN;
412414
add_pending_object(revs, obj, e->name);
413415
}

object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,10 @@ struct object *parse_object_buffer(struct repository *r, const struct object_id
236236
return obj;
237237
}
238238

239-
struct object *parse_object_or_die(const struct object_id *oid,
239+
struct object *parse_object_or_die(struct repository *r, const struct object_id *oid,
240240
const char *name)
241241
{
242-
struct object *o = parse_object(the_repository, oid);
242+
struct object *o = parse_object(r, oid);
243243
if (o)
244244
return o;
245245

object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ struct object *parse_object(struct repository *r, const struct object_id *oid);
135135
* "name" parameter is not NULL, it is included in the error message
136136
* (otherwise, the hex object ID is given).
137137
*/
138-
struct object *parse_object_or_die(const struct object_id *oid, const char *name);
138+
struct object *parse_object_or_die(struct repository *, const struct object_id *oid, const char *name);
139139

140140
/* Given the result of read_sha1_file(), returns the object after
141141
* parsing it. eaten_p indicates if the object has a borrowed copy

pack-bitmap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
890890
struct list_objects_filter_options *filter)
891891
{
892892
unsigned int i;
893+
struct repository *r = the_repository;
893894

894895
struct object_list *wants = NULL;
895896
struct object_list *haves = NULL;
@@ -920,7 +921,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
920921
struct object *object = revs->pending.objects[i].item;
921922

922923
if (object->type == OBJ_NONE)
923-
parse_object_or_die(&object->oid, NULL);
924+
parse_object_or_die(r, &object->oid, NULL);
924925

925926
while (object->type == OBJ_TAG) {
926927
struct tag *tag = (struct tag *) object;
@@ -930,7 +931,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
930931
else
931932
object_list_insert(object, &wants);
932933

933-
object = parse_object_or_die(get_tagged_oid(tag), NULL);
934+
object = parse_object_or_die(r, get_tagged_oid(tag), NULL);
934935
}
935936

936937
if (object->flags & UNINTERESTING)

reachable.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ static int add_one_ref(const char *path, const struct object_id *oid,
3131
{
3232
struct rev_info *revs = (struct rev_info *)cb_data;
3333
struct object *object;
34+
struct repository *r = the_repository;
3435

3536
if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
3637
warning("symbolic ref is dangling: %s", path);
3738
return 0;
3839
}
3940

40-
object = parse_object_or_die(oid, path);
41+
object = parse_object_or_die(r, oid, path);
4142
add_pending_object(revs, object, "");
4243

4344
return 0;
@@ -68,6 +69,7 @@ static void add_recent_object(const struct object_id *oid,
6869
{
6970
struct object *obj;
7071
enum object_type type;
72+
struct repository *r = the_repository;
7173

7274
if (mtime <= data->timestamp)
7375
return;
@@ -86,7 +88,7 @@ static void add_recent_object(const struct object_id *oid,
8688
switch (type) {
8789
case OBJ_TAG:
8890
case OBJ_COMMIT:
89-
obj = parse_object_or_die(oid, NULL);
91+
obj = parse_object_or_die(r, oid, NULL);
9092
break;
9193
case OBJ_TREE:
9294
obj = (struct object *)lookup_tree(the_repository, oid);

upload-pack.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,8 @@ static int parse_want_ref(struct packet_writer *writer, const char *line,
12111211
struct object_array *want_obj)
12121212
{
12131213
const char *arg;
1214+
struct repository *r = the_repository;
1215+
12141216
if (skip_prefix(line, "want-ref ", &arg)) {
12151217
struct object_id oid;
12161218
struct string_list_item *item;
@@ -1224,7 +1226,7 @@ static int parse_want_ref(struct packet_writer *writer, const char *line,
12241226
item = string_list_append(wanted_refs, arg);
12251227
item->util = oiddup(&oid);
12261228

1227-
o = parse_object_or_die(&oid, arg);
1229+
o = parse_object_or_die(r, &oid, arg);
12281230
if (!(o->flags & WANTED)) {
12291231
o->flags |= WANTED;
12301232
add_object_array(o, NULL, want_obj);

0 commit comments

Comments
 (0)