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

[PATCH 11/20] Convert read_mmblob to take struct object_id.

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Aug 28, 2016, 23:27 UTC
Message-ID
<20160828232757.373278-12-sandals@crustytoothpaste.net>
In-Reply-To
<20160828232757.373278-1-sandals@crustytoothpaste.net>

Since all of its callers have been updated, convert read_mmblob to take a pointer to struct object_id.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 builtin/apply.c    | 6 +++---
 builtin/checkout.c | 6 +++---
 merge-recursive.c  | 6 +++---
 notes-merge.c      | 6 +++---
 xdiff-interface.c  | 8 ++++----
 xdiff-interface.h  | 3 ++-
 6 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/builtin/apply.c b/builtin/apply.c
index 76b16121..df2c95d3 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -3435,9 +3435,9 @@ static int three_way_merge(struct image *image,
 	mmbuffer_t result = { NULL };
 	int status;
 
-	read_mmblob(&base_file, base->hash);
-	read_mmblob(&our_file, ours->hash);
-	read_mmblob(&their_file, theirs->hash);
+	read_mmblob(&base_file, base);
+	read_mmblob(&our_file, ours);
+	read_mmblob(&their_file, theirs);
 	status = ll_merge(&result, path,
 			  &base_file, "base",
 			  &our_file, "ours",
diff --git a/builtin/checkout.c b/builtin/checkout.c
index ec85af56..13169221 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -195,9 +195,9 @@ static int checkout_merged(int pos, struct checkout *state)
 	if (is_null_oid(&threeway[1]) || is_null_oid(&threeway[2]))
 		return error(_("path '%s' does not have necessary versions"), path);
 
-	read_mmblob(&ancestor, threeway[0].hash);
-	read_mmblob(&ours, threeway[1].hash);
-	read_mmblob(&theirs, threeway[2].hash);
+	read_mmblob(&ancestor, &threeway[0]);
+	read_mmblob(&ours, &threeway[1]);
+	read_mmblob(&theirs, &threeway[2]);
 
 	/*
 	 * NEEDSWORK: re-create conflicts from merges with
diff --git a/merge-recursive.c b/merge-recursive.c
index e3db594d..3750d253 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -910,9 +910,9 @@ static int merge_3way(struct merge_options *o,
 		name2 = mkpathdup("%s", branch2);
 	}
 
-	read_mmblob(&orig, one->oid.hash);
-	read_mmblob(&src1, a->oid.hash);
-	read_mmblob(&src2, b->oid.hash);
+	read_mmblob(&orig, &one->oid);
+	read_mmblob(&src1, &a->oid);
+	read_mmblob(&src2, &b->oid);
 
 	merge_status = ll_merge(result_buf, a->path, &orig, base_name,
 				&src1, name1, &src2, name2, &ll_opts);
diff --git a/notes-merge.c b/notes-merge.c
index 68129cdb..d405a412 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -343,9 +343,9 @@ static int ll_merge_in_worktree(struct notes_merge_options *o,
 	mmfile_t base, local, remote;
 	int status;
 
-	read_mmblob(&base, p->base.hash);
-	read_mmblob(&local, p->local.hash);
-	read_mmblob(&remote, p->remote.hash);
+	read_mmblob(&base, &p->base);
+	read_mmblob(&local, &p->local);
+	read_mmblob(&remote, &p->remote);
 
 	status = ll_merge(&result_buf, oid_to_hex(&p->obj), &base, NULL,
 			  &local, o->local_ref, &remote, o->remote_ref, NULL);
diff --git a/xdiff-interface.c b/xdiff-interface.c
index f34ea762..3bfc69ca 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -178,20 +178,20 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
 	return 0;
 }
 
-void read_mmblob(mmfile_t *ptr, const unsigned char *sha1)
+void read_mmblob(mmfile_t *ptr, const struct object_id *oid)
 {
 	unsigned long size;
 	enum object_type type;
 
-	if (!hashcmp(sha1, null_sha1)) {
+	if (!oidcmp(oid, &null_oid)) {
 		ptr->ptr = xstrdup("");
 		ptr->size = 0;
 		return;
 	}
 
-	ptr->ptr = read_sha1_file(sha1, &type, &size);
+	ptr->ptr = read_sha1_file(oid->hash, &type, &size);
 	if (!ptr->ptr || type != OBJ_BLOB)
-		die("unable to read blob object %s", sha1_to_hex(sha1));
+		die("unable to read blob object %s", oid_to_hex(oid));
 	ptr->size = size;
 }
 
diff --git a/xdiff-interface.h b/xdiff-interface.h
index fbb5a1c3..6f6ba909 100644
--- a/xdiff-interface.h
+++ b/xdiff-interface.h
@@ -1,6 +1,7 @@
 #ifndef XDIFF_INTERFACE_H
 #define XDIFF_INTERFACE_H
 
+#include "cache.h"
 #include "xdiff/xdiff.h"
 
 /*
@@ -20,7 +21,7 @@ int parse_hunk_header(char *line, int len,
 		      int *ob, int *on,
 		      int *nb, int *nn);
 int read_mmfile(mmfile_t *ptr, const char *filename);
-void read_mmblob(mmfile_t *ptr, const unsigned char *sha1);
+void read_mmblob(mmfile_t *ptr, const struct object_id *oid);
 int buffer_is_binary(const char *ptr, unsigned long size);
 
 extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags);
Previous: brian m. carlsonNext: brian m. carlson
Message 23 of 30 in “object_id part 5”
  1. 00/20 object_id part 5brian m. carlson, Aug 28, 2016
  2. 02/20 builtin/apply: convert static functions to struct object_idbrian m. carlson, Aug 28, 2016
  3. 07/20 builtin: convert textconv_object to use struct object_idbrian m. carlson, Aug 28, 2016
  4. 01/20 cache: convert struct cache_entry to use struct object_idbrian m. carlson, Aug 28, 2016
  5. Johannes SchindelinAug 29, 2016
  6. Jakub NarębskiAug 29, 2016
  7. Johannes SchindelinAug 29, 2016
  8. brian m. carlsonAug 29, 2016
  9. 18/20 builtin/am: convert to struct object_idbrian m. carlson, Aug 28, 2016
  10. Paul TanAug 29, 2016
  11. brian m. carlsonAug 29, 2016
  12. 06/20 builtin/cat-file: convert some static functions to struct object_idbrian m. carlson, Aug 28, 2016
  13. 17/20 refs: add an update_ref_oid function.brian m. carlson, Aug 28, 2016
  14. 03/20 builtin/blame: convert struct origin to use struct object_idbrian m. carlson, Aug 28, 2016
  15. 16/20 sha1_name: convert get_sha1_mb to struct object_idbrian m. carlson, Aug 28, 2016
  16. 19/20 builtin/commit-tree: convert to struct object_idbrian m. carlson, Aug 28, 2016
  17. 05/20 builtin/cat-file: convert struct expand_data to use struct object_idbrian m. carlson, Aug 28, 2016
  18. 20/20 builtin/reset: convert to use struct object_idbrian m. carlson, Aug 28, 2016
  19. Johannes SchindelinAug 31, 2016
  20. 04/20 builtin/log: convert some static functions to use struct object_idbrian m. carlson, Aug 28, 2016
  21. 13/20 builtin/rm: convert to use struct object_idbrian m. carlson, Aug 28, 2016
  22. 12/20 builtin/blame: convert file to use struct object_idbrian m. carlson, Aug 28, 2016
  23. 11/20 Convert read_mmblob to take struct object_id.brian m. carlson, Aug 28, 2016
  24. 14/20 notes: convert init_notes to use struct object_idbrian m. carlson, Aug 28, 2016
  25. 15/20 builtin/update-index: convert file to struct object_idbrian m. carlson, Aug 28, 2016
  26. 09/20 builtin/checkout: convert some static functions to struct object_idbrian m. carlson, Aug 28, 2016
  27. 08/20 streaming: make stream_blob_to_fd take struct object_idbrian m. carlson, Aug 28, 2016
  28. Johannes SchindelinAug 29, 2016
  29. 10/20 notes-merge: convert struct notes_merge_pair to struct object_idbrian m. carlson, Aug 28, 2016
  30. Johannes SchindelinAug 31, 2016

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.