object: add repository argument to parse_object_buffer
authorStefan Beller <sbeller@google.com>
Fri, 29 Jun 2018 01:21:53 +0000 (18:21 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Jun 2018 17:43:38 +0000 (10:43 -0700)
Add a repository argument to allow the callers of parse_object_buffer
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>
builtin/fast-export.c
builtin/fsck.c
builtin/index-pack.c
builtin/unpack-objects.c
object.c
object.h
ref-filter.c
index e39c4e2c1d00e4090965d01305e952539395f1ea..03a2e4b79e6a4937d2679a9fe79c5a307605783e 100644 (file)
@@ -244,7 +244,8 @@ static void export_blob(const struct object_id *oid)
                        die ("Could not read blob %s", oid_to_hex(oid));
                if (check_object_signature(oid, buf, size, type_name(type)) < 0)
                        die("sha1 mismatch in blob %s", oid_to_hex(oid));
-               object = parse_object_buffer(oid, type, size, buf, &eaten);
+               object = parse_object_buffer(the_repository, oid, type,
+                                            size, buf, &eaten);
        }
 
        if (!object)
index 12d01e917475eb04a15156dad1e367495ef09a71..09cf5333444ff1fc3737e6e44d34714e5af3b76c 100644 (file)
@@ -392,7 +392,8 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
         * verify_packfile(), data_valid variable for details.
         */
        struct object *obj;
-       obj = parse_object_buffer(oid, type, size, buffer, eaten);
+       obj = parse_object_buffer(the_repository, oid, type, size, buffer,
+                                 eaten);
        if (!obj) {
                errors_found |= ERROR_OBJECT;
                return error("%s: object corrupt or missing", oid_to_hex(oid));
@@ -525,7 +526,9 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
        if (!contents && type != OBJ_BLOB)
                BUG("read_loose_object streamed a non-blob");
 
-       obj = parse_object_buffer(oid, type, size, contents, &eaten);
+       obj = parse_object_buffer(the_repository, oid, type, size,
+                                 contents, &eaten);
+
        if (!obj) {
                errors_found |= ERROR_OBJECT;
                error("%s: object could not be parsed: %s",
index 74fe2973e1256e092652fce28ba2036cc3203af9..9c08cf3ceadaff8b56aecf2421d06c060fcf835a 100644 (file)
@@ -851,7 +851,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
                         * we do not need to free the memory here, as the
                         * buf is deleted by the caller.
                         */
-                       obj = parse_object_buffer(oid, type, size, buf,
+                       obj = parse_object_buffer(the_repository, oid, type,
+                                                 size, buf,
                                                  &eaten);
                        if (!obj)
                                die(_("invalid %s"), type_name(type));
index 335b5ed9a0f1d17c1d1a2b67319c1282d77272a5..75d1d5ea0b8417b5842257b08d320868c6880764 100644 (file)
@@ -265,7 +265,8 @@ static void write_object(unsigned nr, enum object_type type,
                int eaten;
                hash_object_file(buf, size, type_name(type), &obj_list[nr].oid);
                added_object(nr, type, buf, size);
-               obj = parse_object_buffer(&obj_list[nr].oid, type, size, buf,
+               obj = parse_object_buffer(the_repository, &obj_list[nr].oid,
+                                         type, size, buf,
                                          &eaten);
                if (!obj)
                        die("invalid %s", type_name(type));
index 002ebb69e3ba8c215f5ec7688afb4045543d5151..49719694c146c118cb7a4ff8e532203039006b82 100644 (file)
--- a/object.c
+++ b/object.c
@@ -186,7 +186,7 @@ struct object *lookup_unknown_object(const unsigned char *sha1)
        return obj;
 }
 
-struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)
+struct object *parse_object_buffer_the_repository(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)
 {
        struct object *obj;
        *eaten_p = 0;
@@ -278,7 +278,8 @@ struct object *parse_object_the_repository(const struct object_id *oid)
                        return NULL;
                }
 
-               obj = parse_object_buffer(oid, type, size, buffer, &eaten);
+               obj = parse_object_buffer(the_repository, oid, type, size,
+                                         buffer, &eaten);
                if (!eaten)
                        free(buffer);
                return obj;
index f840a428859eadd9054e9d7dbd4a29b794ab5d8d..2ba23c07a72167ec26fd5092c7a500f90932a0bd 100644 (file)
--- a/object.h
+++ b/object.h
@@ -135,7 +135,8 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name
  * parsing it.  eaten_p indicates if the object has a borrowed copy
  * of buffer and the caller should not free() it.
  */
-struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);
+#define parse_object_buffer(r, o, t, s, b, e) parse_object_buffer_##r(o, t, s, b, e)
+struct object *parse_object_buffer_the_repository(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);
 
 /** Returns the object, with potentially excess memory allocated. **/
 struct object *lookup_unknown_object(const unsigned  char *sha1);
index 044c28c515465db18501a0a7ca8970d3fd261ae1..ec9479af1f81d4f7295cf4c91368ddf0c3b957fb 100644 (file)
@@ -807,7 +807,8 @@ static void *get_obj(const struct object_id *oid, struct object **obj, unsigned
        void *buf = read_object_file(oid, &type, sz);
 
        if (buf)
-               *obj = parse_object_buffer(oid, type, *sz, buf, eaten);
+               *obj = parse_object_buffer(the_repository, oid, type, *sz,
+                                          buf, eaten);
        else
                *obj = NULL;
        return buf;