git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 29/53] Convert lookup_blob to struct object_id

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
May 1, 2017, 02:29 UTC
Message-ID
<20170501022946.258735-30-sandals@crustytoothpaste.net>
In-Reply-To
<20170501022946.258735-1-sandals@crustytoothpaste.net>
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>
---
 blob.c                   | 6 +++---
 blob.h                   | 2 +-
 builtin/fast-export.c    | 2 +-
 builtin/fsck.c           | 2 +-
 builtin/index-pack.c     | 2 +-
 builtin/merge-tree.c     | 2 +-
 builtin/unpack-objects.c | 2 +-
 fsck.c                   | 2 +-
 http-push.c              | 2 +-
 list-objects.c           | 2 +-
 object.c                 | 4 ++--
 reachable.c              | 2 +-
 revision.c               | 4 ++--
 tag.c                    | 2 +-
 walker.c                 | 2 +-
 15 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/blob.c b/blob.c
index 1fcb8e44b..fa2ab4f7a 100644
--- 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 59b394eea..446061683 100644
--- 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);
 
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index b4521cb62..ae36b14db 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -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);
diff --git a/builtin/fsck.c b/builtin/fsck.c
index c40e14de6..2f67e8217 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -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;
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 2241ee68e..b75133f62 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -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
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index cdeb6562d..bad6735c7 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -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;
 }
 
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 3dc5e5691..7d5efa2b3 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -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 e6152e4e6..ab3016c0e 100644
--- 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);
diff --git a/http-push.c b/http-push.c
index 04568e4fb..9bb5e0648 100644
--- a/http-push.c
+++ b/http-push.c
@@ -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 */
diff --git a/list-objects.c b/list-objects.c
index f3ca6aafb..721e5fb08 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -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);
 	}
diff --git a/object.c b/object.c
index 0208c407a..2c8d1e5d3 100644
--- 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);
 	}
 
diff --git a/reachable.c b/reachable.c
index a8a979bd4..8ea0bdd7c 100644
--- a/reachable.c
+++ b/reachable.c
@@ -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",
diff --git a/revision.c b/revision.c
index f8e0dee6d..db2de7a7a 100644
--- a/revision.c
+++ b/revision.c
@@ -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 79b78d358..dff251673 100644
--- 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)) {
diff --git a/walker.c b/walker.c
index b499fcb72..3d6029c8e 100644
--- 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;
 		}
Previous: brian m. carlsonNext: brian m. carlson
Message 40 of 69 in “object_id part 8”
  1. 00/53 object_id part 8brian m. carlson, May 1, 2017
  2. 01/53 fetch-pack: convert to struct object_idbrian m. carlson, May 1, 2017
  3. 02/53 Clean up outstanding object_id transforms.brian m. carlson, May 1, 2017
  4. Brandon WilliamsMay 2, 2017
  5. brian m. carlsonMay 3, 2017
  6. 03/53 Convert struct cache_tree to use struct object_idbrian m. carlson, May 1, 2017
  7. Brandon WilliamsMay 2, 2017
  8. brian m. carlsonMay 3, 2017
  9. 05/53 builtin/prune: convert to struct object_idbrian m. carlson, May 1, 2017
  10. 04/53 builtin/name-rev: convert to struct object_idbrian m. carlson, May 1, 2017
  11. 06/53 bundle: convert to struct object_idbrian m. carlson, May 1, 2017
  12. 10/53 fast-import: convert internal structs to struct object_idbrian m. carlson, May 1, 2017
  13. 08/53 builtin/blame: convert static function to struct object_idbrian m. carlson, May 1, 2017
  14. 07/53 branch: convert to struct object_idbrian m. carlson, May 1, 2017
  15. 12/53 submodule: convert merge_submodule to use struct object_idbrian m. carlson, May 1, 2017
  16. 11/53 fast-import: convert to struct object_idbrian m. carlson, May 1, 2017
  17. Jonathan TanMay 1, 2017
  18. Jeff KingMay 1, 2017
  19. Jonathan TanMay 1, 2017
  20. brian m. carlsonMay 3, 2017
  21. 14/53 parse-options-cb: convert to struct object_idbrian m. carlson, May 1, 2017
  22. 13/53 notes-cache: convert to struct object_idbrian m. carlson, May 1, 2017
  23. 16/53 builtin/verify-commit: convert to struct object_idbrian m. carlson, May 1, 2017
  24. 09/53 builtin/rev-parse: convert to struct object_idbrian m. carlson, May 1, 2017
  25. Jonathan TanMay 1, 2017
  26. 15/53 reflog_expire: convert to struct object_idbrian m. carlson, May 1, 2017
  27. 19/53 notes-utils: convert internals to struct object_idbrian m. carlson, May 1, 2017
  28. 21/53 shallow: convert shallow registration functions to object_idbrian m. carlson, May 1, 2017
  29. 24/53 Convert remaining callers of lookup_commit_reference* to object_idbrian m. carlson, May 1, 2017
  30. 22/53 sequencer: convert some functions to struct object_idbrian m. carlson, May 1, 2017
  31. 18/53 http-push: convert some static functions to struct object_idbrian m. carlson, May 1, 2017
  32. 23/53 builtin/tag: convert to struct object_idbrian m. carlson, May 1, 2017
  33. 25/53 Convert lookup_commit* to struct object_idbrian m. carlson, May 1, 2017
  34. 26/53 pack: convert struct pack_idx_entry to struct object_idbrian m. carlson, May 1, 2017
  35. 17/53 tag: convert parse_tag_buffer to struct object_idbrian m. carlson, May 1, 2017
  36. 20/53 revision: convert prepare_show_merge to struct object_idbrian m. carlson, May 1, 2017
  37. 28/53 Convert remaining callers of lookup_blob to object_idbrian m. carlson, May 1, 2017
  38. 30/53 tree: convert read_tree_1 to use struct object_id internallybrian m. carlson, May 1, 2017
  39. 27/53 builtin/unpack-objects: convert to struct object_idbrian m. carlson, May 1, 2017
  40. 29/53 Convert lookup_blob to struct object_idbrian m. carlson, May 1, 2017
  41. 37/53 ref-filter: convert some static functions to struct object_idbrian m. carlson, May 1, 2017
  42. 35/53 Convert the verify_pack callback to struct object_idbrian m. carlson, May 1, 2017
  43. 38/53 refs: convert struct ref_update to use struct object_idbrian m. carlson, May 1, 2017
  44. 36/53 Convert struct ref_array_item to struct object_idbrian m. carlson, May 1, 2017
  45. 40/53 http-push: convert process_ls_object and descendants to object_idbrian m. carlson, May 1, 2017
  46. 39/53 refs/files-backend: convert many internals to struct object_idbrian m. carlson, May 1, 2017
  47. Jonathan TanMay 1, 2017
  48. brian m. carlsonMay 3, 2017
  49. 33/53 log-tree: convert to struct object_idbrian m. carlson, May 1, 2017
  50. 34/53 Convert lookup_tag to struct object_idbrian m. carlson, May 1, 2017
  51. 31/53 builtin/reflog: convert tree_is_complete to take struct object_idbrian m. carlson, May 1, 2017
  52. 41/53 revision: rename add_pending_sha1 to add_pending_oidbrian m. carlson, May 1, 2017
  53. 32/53 Convert lookup_tree to struct object_idbrian m. carlson, May 1, 2017
  54. 42/53 revision: convert remaining parse_object callers to object_idbrian m. carlson, May 1, 2017
  55. 43/53 upload-pack: convert remaining parse_object callers to object_idbrian m. carlson, May 1, 2017
  56. 47/53 sequencer: convert fast_forward_to to struct object_idbrian m. carlson, May 1, 2017
  57. 49/53 builtin/ls-tree: convert to struct object_idbrian m. carlson, May 1, 2017
  58. 51/53 sequencer: convert do_recursive_merge to struct object_idbrian m. carlson, May 1, 2017
  59. 45/53 builtin/read-tree: convert to struct object_idbrian m. carlson, May 1, 2017
  60. 44/53 sha1_name: convert internals of peel_onion to object_idbrian m. carlson, May 1, 2017
  61. 46/53 builtin/ls-files: convert overlay_tree_on_cache to object_idbrian m. carlson, May 1, 2017
  62. 52/53 tree: convert parse_tree_indirect to struct object_idbrian m. carlson, May 1, 2017
  63. 50/53 diff-lib: convert do_diff_cache to struct object_idbrian m. carlson, May 1, 2017
  64. 53/53 object: convert parse_object* to take struct object_idbrian m. carlson, May 1, 2017
  65. Jonathan TanMay 1, 2017
  66. 48/53 merge: convert checkout_fast_forward to struct object_idbrian m. carlson, May 1, 2017
  67. Stefan BellerMay 1, 2017
  68. Brandon WilliamsMay 2, 2017
  69. brian m. carlsonMay 4, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.