git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: git@vger.kernel.org
Cc: "Paul Tan" <pyokagan@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Jeff King" <peff@peff.net>
Subject: [PATCH 04/20] builtin/log: convert some static functions to use struct object_id
Date: Sun, 28 Aug 2016 23:27:41 +0000	[thread overview]
Message-ID: <20160828232757.373278-5-sandals@crustytoothpaste.net> (raw)
In-Reply-To: <20160828232757.373278-1-sandals@crustytoothpaste.net>

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 builtin/log.c | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/builtin/log.c b/builtin/log.c
index 92dc34dc..226212c9 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -464,9 +464,9 @@ static void show_tagger(char *buf, int len, struct rev_info *rev)
 	strbuf_release(&out);
 }
 
-static int show_blob_object(const unsigned char *sha1, struct rev_info *rev, const char *obj_name)
+static int show_blob_object(const struct object_id *oid, struct rev_info *rev, const char *obj_name)
 {
-	unsigned char sha1c[20];
+	struct object_id oidc;
 	struct object_context obj_context;
 	char *buf;
 	unsigned long size;
@@ -474,13 +474,13 @@ static int show_blob_object(const unsigned char *sha1, struct rev_info *rev, con
 	fflush(rev->diffopt.file);
 	if (!DIFF_OPT_TOUCHED(&rev->diffopt, ALLOW_TEXTCONV) ||
 	    !DIFF_OPT_TST(&rev->diffopt, ALLOW_TEXTCONV))
-		return stream_blob_to_fd(1, sha1, NULL, 0);
+		return stream_blob_to_fd(1, oid->hash, NULL, 0);
 
-	if (get_sha1_with_context(obj_name, 0, sha1c, &obj_context))
+	if (get_sha1_with_context(obj_name, 0, oidc.hash, &obj_context))
 		die(_("Not a valid object name %s"), obj_name);
 	if (!obj_context.path[0] ||
-	    !textconv_object(obj_context.path, obj_context.mode, sha1c, 1, &buf, &size))
-		return stream_blob_to_fd(1, sha1, NULL, 0);
+	    !textconv_object(obj_context.path, obj_context.mode, oidc.hash, 1, &buf, &size))
+		return stream_blob_to_fd(1, oid->hash, NULL, 0);
 
 	if (!buf)
 		die(_("git show %s: bad file"), obj_name);
@@ -489,15 +489,15 @@ static int show_blob_object(const unsigned char *sha1, struct rev_info *rev, con
 	return 0;
 }
 
-static int show_tag_object(const unsigned char *sha1, struct rev_info *rev)
+static int show_tag_object(const struct object_id *oid, struct rev_info *rev)
 {
 	unsigned long size;
 	enum object_type type;
-	char *buf = read_sha1_file(sha1, &type, &size);
+	char *buf = read_sha1_file(oid->hash, &type, &size);
 	int offset = 0;
 
 	if (!buf)
-		return error(_("Could not read object %s"), sha1_to_hex(sha1));
+		return error(_("Could not read object %s"), oid_to_hex(oid));
 
 	assert(type == OBJ_TAG);
 	while (offset < size && buf[offset] != '\n') {
@@ -574,7 +574,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
 		const char *name = objects[i].name;
 		switch (o->type) {
 		case OBJ_BLOB:
-			ret = show_blob_object(o->oid.hash, &rev, name);
+			ret = show_blob_object(&o->oid, &rev, name);
 			break;
 		case OBJ_TAG: {
 			struct tag *t = (struct tag *)o;
@@ -585,7 +585,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
 					diff_get_color_opt(&rev.diffopt, DIFF_COMMIT),
 					t->tag,
 					diff_get_color_opt(&rev.diffopt, DIFF_RESET));
-			ret = show_tag_object(o->oid.hash, &rev);
+			ret = show_tag_object(&o->oid, &rev);
 			rev.shown_one = 1;
 			if (ret)
 				break;
@@ -1248,11 +1248,11 @@ static struct commit *get_base_commit(const char *base_commit,
 		if (upstream) {
 			struct commit_list *base_list;
 			struct commit *commit;
-			unsigned char sha1[20];
+			struct object_id oid;
 
-			if (get_sha1(upstream, sha1))
+			if (get_oid(upstream, &oid))
 				die(_("Failed to resolve '%s' as a valid ref."), upstream);
-			commit = lookup_commit_or_die(sha1, "upstream base");
+			commit = lookup_commit_or_die(oid.hash, "upstream base");
 			base_list = get_merge_bases_many(commit, total, list);
 			/* There should be one and only one merge base. */
 			if (!base_list || base_list->next)
@@ -1339,15 +1339,15 @@ static void prepare_bases(struct base_tree_info *bases,
 	 * and stuff them in bases structure.
 	 */
 	while ((commit = get_revision(&revs)) != NULL) {
-		unsigned char sha1[20];
+		struct object_id oid;
 		struct object_id *patch_id;
 		if (commit->util)
 			continue;
-		if (commit_patch_id(commit, &diffopt, sha1, 0))
+		if (commit_patch_id(commit, &diffopt, oid.hash, 0))
 			die(_("cannot get patch id"));
 		ALLOC_GROW(bases->patch_id, bases->nr_patch_id + 1, bases->alloc_patch_id);
 		patch_id = bases->patch_id + bases->nr_patch_id;
-		hashcpy(patch_id->hash, sha1);
+		oidcpy(patch_id, &oid);
 		bases->nr_patch_id++;
 	}
 }
@@ -1628,10 +1628,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 			check_head = 1;
 
 		if (check_head) {
-			unsigned char sha1[20];
+			struct object_id oid;
 			const char *ref, *v;
 			ref = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
-						 sha1, NULL);
+						 oid.hash, NULL);
 			if (ref && skip_prefix(ref, "refs/heads/", &v))
 				branch_name = xstrdup(v);
 			else
@@ -1802,9 +1802,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 
 static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
 {
-	unsigned char sha1[20];
-	if (get_sha1(arg, sha1) == 0) {
-		struct commit *commit = lookup_commit_reference(sha1);
+	struct object_id oid;
+	if (get_oid(arg, &oid) == 0) {
+		struct commit *commit = lookup_commit_reference(oid.hash);
 		if (commit) {
 			commit->object.flags |= flags;
 			add_pending_object(revs, &commit->object, arg);

  parent reply	other threads:[~2016-08-28 23:28 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-28 23:27 [PATCH 00/20] object_id part 5 brian m. carlson
2016-08-28 23:27 ` [PATCH 01/20] cache: convert struct cache_entry to use struct object_id brian m. carlson
2016-08-29 10:50   ` Johannes Schindelin
2016-08-29 13:48   ` Jakub Narębski
2016-08-29 15:43     ` Johannes Schindelin
2016-08-29 22:25       ` brian m. carlson
2016-08-28 23:27 ` [PATCH 02/20] builtin/apply: convert static functions to " brian m. carlson
2016-08-28 23:27 ` [PATCH 03/20] builtin/blame: convert struct origin to use " brian m. carlson
2016-08-28 23:27 ` brian m. carlson [this message]
2016-08-28 23:27 ` [PATCH 05/20] builtin/cat-file: convert struct expand_data " brian m. carlson
2016-08-28 23:27 ` [PATCH 06/20] builtin/cat-file: convert some static functions to " brian m. carlson
2016-08-28 23:27 ` [PATCH 07/20] builtin: convert textconv_object to use " brian m. carlson
2016-08-28 23:27 ` [PATCH 08/20] streaming: make stream_blob_to_fd take " brian m. carlson
2016-08-29 11:26   ` Johannes Schindelin
2016-08-28 23:27 ` [PATCH 09/20] builtin/checkout: convert some static functions to " brian m. carlson
2016-08-28 23:27 ` [PATCH 10/20] notes-merge: convert struct notes_merge_pair " brian m. carlson
2016-08-31 10:51   ` Johannes Schindelin
2016-08-28 23:27 ` [PATCH 11/20] Convert read_mmblob to take " brian m. carlson
2016-08-28 23:27 ` [PATCH 12/20] builtin/blame: convert file to use " brian m. carlson
2016-08-28 23:27 ` [PATCH 13/20] builtin/rm: convert " brian m. carlson
2016-08-28 23:27 ` [PATCH 14/20] notes: convert init_notes " brian m. carlson
2016-08-28 23:27 ` [PATCH 15/20] builtin/update-index: convert file to " brian m. carlson
2016-08-28 23:27 ` [PATCH 16/20] sha1_name: convert get_sha1_mb " brian m. carlson
2016-08-28 23:27 ` [PATCH 17/20] refs: add an update_ref_oid function brian m. carlson
2016-08-28 23:27 ` [PATCH 18/20] builtin/am: convert to struct object_id brian m. carlson
2016-08-29  7:02   ` Paul Tan
2016-08-29 22:15     ` brian m. carlson
2016-08-28 23:27 ` [PATCH 19/20] builtin/commit-tree: " brian m. carlson
2016-08-28 23:27 ` [PATCH 20/20] builtin/reset: convert to use " brian m. carlson
2016-08-31 11:08   ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160828232757.373278-5-sandals@crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=pyokagan@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).