Skip to content

Commit 108ed1a

Browse files
stefanbellergitster
authored andcommitted
object.c: allow parse_object_buffer to handle arbitrary repositories
Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4ff7e5c commit 108ed1a

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

object.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,21 +185,21 @@ struct object *lookup_unknown_object(const unsigned char *sha1)
185185
return obj;
186186
}
187187

188-
struct object *parse_object_buffer_the_repository(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)
188+
struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)
189189
{
190190
struct object *obj;
191191
*eaten_p = 0;
192192

193193
obj = NULL;
194194
if (type == OBJ_BLOB) {
195-
struct blob *blob = lookup_blob(the_repository, oid);
195+
struct blob *blob = lookup_blob(r, oid);
196196
if (blob) {
197197
if (parse_blob_buffer(blob, buffer, size))
198198
return NULL;
199199
obj = &blob->object;
200200
}
201201
} else if (type == OBJ_TREE) {
202-
struct tree *tree = lookup_tree(the_repository, oid);
202+
struct tree *tree = lookup_tree(r, oid);
203203
if (tree) {
204204
obj = &tree->object;
205205
if (!tree->buffer)
@@ -211,20 +211,20 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e
211211
}
212212
}
213213
} else if (type == OBJ_COMMIT) {
214-
struct commit *commit = lookup_commit(the_repository, oid);
214+
struct commit *commit = lookup_commit(r, oid);
215215
if (commit) {
216-
if (parse_commit_buffer(the_repository, commit, buffer, size, 1))
216+
if (parse_commit_buffer(r, commit, buffer, size, 1))
217217
return NULL;
218-
if (!get_cached_commit_buffer(the_repository, commit, NULL)) {
219-
set_commit_buffer(the_repository, commit, buffer, size);
218+
if (!get_cached_commit_buffer(r, commit, NULL)) {
219+
set_commit_buffer(r, commit, buffer, size);
220220
*eaten_p = 1;
221221
}
222222
obj = &commit->object;
223223
}
224224
} else if (type == OBJ_TAG) {
225-
struct tag *tag = lookup_tag(the_repository, oid);
225+
struct tag *tag = lookup_tag(r, oid);
226226
if (tag) {
227-
if (parse_tag_buffer(the_repository, tag, buffer, size))
227+
if (parse_tag_buffer(r, tag, buffer, size))
228228
return NULL;
229229
obj = &tag->object;
230230
}

object.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name
138138
* parsing it. eaten_p indicates if the object has a borrowed copy
139139
* of buffer and the caller should not free() it.
140140
*/
141-
#define parse_object_buffer(r, o, t, s, b, e) parse_object_buffer_##r(o, t, s, b, e)
142-
struct object *parse_object_buffer_the_repository(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);
141+
struct object *parse_object_buffer(struct repository *r, const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);
143142

144143
/** Returns the object, with potentially excess memory allocated. **/
145144
struct object *lookup_unknown_object(const unsigned char *sha1);

0 commit comments

Comments
 (0)