Convert lookup_blob to struct object_id
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sat, 6 May 2017 22:10:14 +0000 (22:10 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 May 2017 06:12:57 +0000 (15:12 +0900)
Convert lookup_blob to take a pointer to struct object_id.

The commit was created with manual changes to blob.c and blob.h, plus
the following semantic patch:

@@
expression E1;
@@
- lookup_blob(E1.hash)
+ lookup_blob(&E1)

@@
expression E1;
@@
- lookup_blob(E1->hash)
+ lookup_blob(E1)

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 files changed:
blob.c
blob.h
builtin/fast-export.c
builtin/fsck.c
builtin/index-pack.c
builtin/merge-tree.c
builtin/unpack-objects.c
fsck.c
http-push.c
list-objects.c
object.c
reachable.c
revision.c
tag.c
walker.c

diff --git a/blob.c b/blob.c
index 1fcb8e4..fa2ab4f 100644 (file)
--- a/blob.c
+++ b/blob.c
@@ -3,11 +3,11 @@
 
 const char *blob_type = "blob";
 
-struct blob *lookup_blob(const unsigned char *sha1)
+struct blob *lookup_blob(const struct object_id *oid)
 {
-       struct object *obj = lookup_object(sha1);
+       struct object *obj = lookup_object(oid->hash);
        if (!obj)
-               return create_object(sha1, alloc_blob_node());
+               return create_object(oid->hash, alloc_blob_node());
        return object_as_type(obj, OBJ_BLOB, 0);
 }
 
diff --git a/blob.h b/blob.h
index 59b394e..4460616 100644 (file)
--- a/blob.h
+++ b/blob.h
@@ -9,7 +9,7 @@ struct blob {
        struct object object;
 };
 
-struct blob *lookup_blob(const unsigned char *sha1);
+struct blob *lookup_blob(const struct object_id *oid);
 
 int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);
 
index b4521cb..ae36b14 100644 (file)
@@ -232,7 +232,7 @@ static void export_blob(const struct object_id *oid)
 
        if (anonymize) {
                buf = anonymize_blob(&size);
-               object = (struct object *)lookup_blob(oid->hash);
+               object = (struct object *)lookup_blob(oid);
                eaten = 0;
        } else {
                buf = read_sha1_file(oid->hash, &type, &size);
index c40e14d..2f67e82 100644 (file)
@@ -781,7 +781,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
                        mode = active_cache[i]->ce_mode;
                        if (S_ISGITLINK(mode))
                                continue;
-                       blob = lookup_blob(active_cache[i]->oid.hash);
+                       blob = lookup_blob(&active_cache[i]->oid);
                        if (!blob)
                                continue;
                        obj = &blob->object;
index 2241ee6..b75133f 100644 (file)
@@ -829,7 +829,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
        if (strict) {
                read_lock();
                if (type == OBJ_BLOB) {
-                       struct blob *blob = lookup_blob(oid->hash);
+                       struct blob *blob = lookup_blob(oid);
                        if (blob)
                                blob->object.flags |= FLAG_CHECKED;
                        else
index cdeb656..bad6735 100644 (file)
@@ -168,7 +168,7 @@ static struct merge_list *create_entry(unsigned stage, unsigned mode, const stru
        res->stage = stage;
        res->path = path;
        res->mode = mode;
-       res->blob = lookup_blob(oid->hash);
+       res->blob = lookup_blob(oid);
        return res;
 }
 
index 3dc5e56..7d5efa2 100644 (file)
@@ -249,7 +249,7 @@ static void write_object(unsigned nr, enum object_type type,
                added_object(nr, type, buf, size);
                free(buf);
 
-               blob = lookup_blob(obj_list[nr].oid.hash);
+               blob = lookup_blob(&obj_list[nr].oid);
                if (blob)
                        blob->object.flags |= FLAG_WRITTEN;
                else
diff --git a/fsck.c b/fsck.c
index e6152e4..ab3016c 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -365,7 +365,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op
                        result = options->walk(obj, OBJ_TREE, data, options);
                }
                else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) {
-                       obj = &lookup_blob(entry.oid->hash)->object;
+                       obj = &lookup_blob(entry.oid)->object;
                        if (name)
                                put_object_name(options, obj, "%s%s", name,
                                        entry.path);
index 04568e4..9bb5e06 100644 (file)
@@ -1315,7 +1315,7 @@ static struct object_list **process_tree(struct tree *tree,
                        p = process_tree(lookup_tree(entry.oid->hash), p);
                        break;
                case OBJ_BLOB:
-                       p = process_blob(lookup_blob(entry.oid->hash), p);
+                       p = process_blob(lookup_blob(entry.oid), p);
                        break;
                default:
                        /* Subproject commit - not in this repository */
index f3ca6aa..721e5fb 100644 (file)
@@ -119,7 +119,7 @@ static void process_tree(struct rev_info *revs,
                                        cb_data);
                else
                        process_blob(revs,
-                                    lookup_blob(entry.oid->hash),
+                                    lookup_blob(entry.oid),
                                     show, base, entry.path,
                                     cb_data);
        }
index 0208c40..2c8d1e5 100644 (file)
--- a/object.c
+++ b/object.c
@@ -190,7 +190,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
 
        obj = NULL;
        if (type == OBJ_BLOB) {
-               struct blob *blob = lookup_blob(oid.hash);
+               struct blob *blob = lookup_blob(&oid);
                if (blob) {
                        if (parse_blob_buffer(blob, buffer, size))
                                return NULL;
@@ -266,7 +266,7 @@ struct object *parse_object(const unsigned char *sha1)
                        error("sha1 mismatch %s", sha1_to_hex(repl));
                        return NULL;
                }
-               parse_blob_buffer(lookup_blob(oid.hash), NULL, 0);
+               parse_blob_buffer(lookup_blob(&oid), NULL, 0);
                return lookup_object(sha1);
        }
 
index a8a979b..8ea0bdd 100644 (file)
@@ -88,7 +88,7 @@ static void add_recent_object(const struct object_id *oid,
                obj = (struct object *)lookup_tree(oid->hash);
                break;
        case OBJ_BLOB:
-               obj = (struct object *)lookup_blob(oid->hash);
+               obj = (struct object *)lookup_blob(oid);
                break;
        default:
                die("unknown object type for %s: %s",
index f8e0dee..db2de7a 100644 (file)
@@ -62,7 +62,7 @@ static void mark_tree_contents_uninteresting(struct tree *tree)
                        mark_tree_uninteresting(lookup_tree(entry.oid->hash));
                        break;
                case OBJ_BLOB:
-                       mark_blob_uninteresting(lookup_blob(entry.oid->hash));
+                       mark_blob_uninteresting(lookup_blob(entry.oid));
                        break;
                default:
                        /* Subproject commit - not in this repository */
@@ -1275,7 +1275,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)
                if (S_ISGITLINK(ce->ce_mode))
                        continue;
 
-               blob = lookup_blob(ce->oid.hash);
+               blob = lookup_blob(&ce->oid);
                if (!blob)
                        die("unable to add index blob to traversal");
                add_pending_object_with_path(revs, &blob->object, "",
diff --git a/tag.c b/tag.c
index 79b78d3..dff2516 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -142,7 +142,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
        bufptr = nl + 1;
 
        if (!strcmp(type, blob_type)) {
-               item->tagged = &lookup_blob(oid.hash)->object;
+               item->tagged = &lookup_blob(&oid)->object;
        } else if (!strcmp(type, tree_type)) {
                item->tagged = &lookup_tree(oid.hash)->object;
        } else if (!strcmp(type, commit_type)) {
index b499fcb..3d6029c 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -52,7 +52,7 @@ static int process_tree(struct walker *walker, struct tree *tree)
                                obj = &tree->object;
                }
                else {
-                       struct blob *blob = lookup_blob(entry.oid->hash);
+                       struct blob *blob = lookup_blob(entry.oid);
                        if (blob)
                                obj = &blob->object;
                }