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: Jeff King <peff@peff.net>,
	Michael Haggerty <mhagger@alum.mit.edu>,
	Stefan Beller <sbeller@google.com>
Subject: [PATCH v3 22/56] builtin/show-branch: rewrite functions to work with object_id
Date: Mon, 25 May 2015 18:38:48 +0000	[thread overview]
Message-ID: <1432579162-411464-23-git-send-email-sandals@crustytoothpaste.net> (raw)
In-Reply-To: <1432579162-411464-1-git-send-email-sandals@crustytoothpaste.net>

From: Michael Haggerty <mhagger@alum.mit.edu>

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 builtin/show-branch.c | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index b861e41..826d9fa 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -369,10 +369,10 @@ static void sort_ref_range(int bottom, int top)
 	      compare_ref_name);
 }
 
-static int append_ref(const char *refname, const unsigned char *sha1,
+static int append_ref(const char *refname, const struct object_id *oid,
 		      int allow_dups)
 {
-	struct commit *commit = lookup_commit_reference_gently(sha1, 1);
+	struct commit *commit = lookup_commit_reference_gently(oid->hash, 1);
 	int i;
 
 	if (!commit)
@@ -406,7 +406,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid,
 	 */
 	if (get_sha1(refname + ofs, tmp.hash) || oidcmp(&tmp, oid))
 		ofs = 5;
-	return append_ref(refname + ofs, oid->hash, 0);
+	return append_ref(refname + ofs, oid, 0);
 }
 
 static int append_remote_ref(const char *refname, const struct object_id *oid,
@@ -421,7 +421,7 @@ static int append_remote_ref(const char *refname, const struct object_id *oid,
 	 */
 	if (get_sha1(refname + ofs, tmp.hash) || oidcmp(&tmp, oid))
 		ofs = 5;
-	return append_ref(refname + ofs, oid->hash, 0);
+	return append_ref(refname + ofs, oid, 0);
 }
 
 static int append_tag_ref(const char *refname, const struct object_id *oid,
@@ -429,7 +429,7 @@ static int append_tag_ref(const char *refname, const struct object_id *oid,
 {
 	if (!starts_with(refname, "refs/tags/"))
 		return 0;
-	return append_ref(refname + 5, oid->hash, 0);
+	return append_ref(refname + 5, oid, 0);
 }
 
 static const char *match_ref_pattern = NULL;
@@ -463,7 +463,7 @@ static int append_matching_ref(const char *refname, const struct object_id *oid,
 		return append_head_ref(refname, oid, flag, cb_data);
 	if (starts_with(refname, "refs/tags/"))
 		return append_tag_ref(refname, oid, flag, cb_data);
-	return append_ref(refname, oid->hash, 0);
+	return append_ref(refname, oid, 0);
 }
 
 static void snarf_refs(int head, int remotes)
@@ -538,7 +538,7 @@ static void append_one_rev(const char *av)
 {
 	struct object_id revkey;
 	if (!get_sha1(av, revkey.hash)) {
-		append_ref(av, revkey.hash, 0);
+		append_ref(av, &revkey, 0);
 		return;
 	}
 	if (strchr(av, '*') || strchr(av, '?') || strchr(av, '[')) {
@@ -643,7 +643,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 	char head[128];
 	const char *head_p;
 	int head_len;
-	unsigned char head_sha1[20];
+	struct object_id head_oid;
 	int merge_base = 0;
 	int independent = 0;
 	int no_name = 0;
@@ -729,7 +729,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 		all_heads = 1;
 
 	if (reflog) {
-		unsigned char sha1[20];
+		struct object_id oid;
 		char nth_desc[256];
 		char *ref;
 		int base = 0;
@@ -740,7 +740,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 
 			fake_av[0] = resolve_refdup("HEAD",
 						    RESOLVE_REF_READING,
-						    sha1, NULL);
+						    oid.hash, NULL);
 			fake_av[1] = NULL;
 			av = fake_av;
 			ac = 1;
@@ -751,7 +751,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 		if (MAX_REVS < reflog)
 			die("Only %d entries can be shown at one time.",
 			    MAX_REVS);
-		if (!dwim_ref(*av, strlen(*av), sha1, &ref))
+		if (!dwim_ref(*av, strlen(*av), oid.hash, &ref))
 			die("No such ref %s", *av);
 
 		/* Has the base been specified? */
@@ -762,7 +762,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 				/* Ah, that is a date spec... */
 				unsigned long at;
 				at = approxidate(reflog_base);
-				read_ref_at(ref, flags, at, -1, sha1, NULL,
+				read_ref_at(ref, flags, at, -1, oid.hash, NULL,
 					    NULL, NULL, &base);
 			}
 		}
@@ -773,7 +773,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 			unsigned long timestamp;
 			int tz;
 
-			if (read_ref_at(ref, flags, 0, base+i, sha1, &logmsg,
+			if (read_ref_at(ref, flags, 0, base+i, oid.hash, &logmsg,
 					&timestamp, &tz, NULL)) {
 				reflog = i;
 				break;
@@ -788,7 +788,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 						msg);
 			free(logmsg);
 			sprintf(nth_desc, "%s@{%d}", *av, base+i);
-			append_ref(nth_desc, sha1, 1);
+			append_ref(nth_desc, &oid, 1);
 		}
 		free(ref);
 	}
@@ -802,7 +802,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 	}
 
 	head_p = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
-				    head_sha1, NULL);
+				    head_oid.hash, NULL);
 	if (head_p) {
 		head_len = strlen(head_p);
 		memcpy(head, head_p, head_len + 1);
@@ -821,7 +821,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 			if (rev_is_head(head,
 					head_len,
 					ref_name[i],
-					head_sha1, NULL))
+					head_oid.hash, NULL))
 				has_head++;
 		}
 		if (!has_head) {
@@ -836,17 +836,17 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 	}
 
 	for (num_rev = 0; ref_name[num_rev]; num_rev++) {
-		unsigned char revkey[20];
+		struct object_id revkey;
 		unsigned int flag = 1u << (num_rev + REV_SHIFT);
 
 		if (MAX_REVS <= num_rev)
 			die("cannot handle more than %d revs.", MAX_REVS);
-		if (get_sha1(ref_name[num_rev], revkey))
+		if (get_sha1(ref_name[num_rev], revkey.hash))
 			die("'%s' is not a valid ref.", ref_name[num_rev]);
-		commit = lookup_commit_reference(revkey);
+		commit = lookup_commit_reference(revkey.hash);
 		if (!commit)
 			die("cannot find commit %s (%s)",
-			    ref_name[num_rev], revkey);
+			    ref_name[num_rev], revkey.hash);
 		parse_commit(commit);
 		mark_seen(commit, &seen);
 
@@ -880,7 +880,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 			int is_head = rev_is_head(head,
 						  head_len,
 						  ref_name[i],
-						  head_sha1,
+						  head_oid.hash,
 						  rev[i]->object.sha1);
 			if (extra < 0)
 				printf("%c [%s] ",
-- 
2.4.0

  parent reply	other threads:[~2015-05-25 18:42 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-25 18:38 [PATCH v3 00/56] Convert parts of refs.c to struct object_id brian m. carlson
2015-05-25 18:38 ` [PATCH v3 01/56] refs: convert struct ref_entry to use " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 02/56] each_ref_fn: change to take an object_id parameter brian m. carlson
2015-05-25 18:38 ` [PATCH v3 03/56] builtin/rev-parse: rewrite to take an object_id argument brian m. carlson
2015-05-25 18:38 ` [PATCH v3 04/56] handle_one_ref(): " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 05/56] register_ref(): " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 06/56] append_ref(): " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 07/56] add_pending_uninteresting_ref(): " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 08/56] get_name(): " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 09/56] builtin/fetch: " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 10/56] grab_single_ref(): " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 11/56] name_ref(): " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 12/56] builtin/pack-objects: " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 13/56] show_ref_cb(): " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 14/56] builtin/reflog: rewrite ref functions " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 15/56] add_branch_for_removal(): rewrite " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 16/56] add_branch_for_removal(): don't set "util" field of string_list entries brian m. carlson
2015-06-05 14:48   ` Michael Haggerty
2015-05-25 18:38 ` [PATCH v3 17/56] builtin/remote: rewrite functions to take object_id arguments brian m. carlson
2015-05-25 18:38 ` [PATCH v3 18/56] show_reference(): rewrite to take an object_id argument brian m. carlson
2015-05-25 18:38 ` [PATCH v3 19/56] append_matching_ref(): " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 20/56] builtin/show-branch: rewrite functions to take object_id arguments brian m. carlson
2015-05-25 18:38 ` [PATCH v3 21/56] append_one_rev(): rewrite to work with object_id brian m. carlson
2015-05-25 18:38 ` brian m. carlson [this message]
2015-05-25 18:38 ` [PATCH v3 23/56] cmd_show_branch(): fix error message brian m. carlson
2015-05-25 18:38 ` [PATCH v3 24/56] fsck: change functions to use object_id brian m. carlson
2015-05-25 18:38 ` [PATCH v3 25/56] builtin/show-ref: rewrite " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 26/56] show_ref(): convert local variable peeled to object_id brian m. carlson
2015-05-25 18:38 ` [PATCH v3 27/56] builtin/show-ref: rewrite to take an object_id argument brian m. carlson
2015-05-25 18:38 ` [PATCH v3 28/56] append_similar_ref(): " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 29/56] http-backend: " brian m. carlson
2015-05-25 18:38 ` [PATCH v3 30/56] show_head_ref(): convert local variable "unused" to object_id brian m. carlson
2015-05-25 18:38 ` [PATCH v3 31/56] add_ref_decoration(): rewrite to take an object_id argument brian m. carlson
2015-05-25 18:38 ` [PATCH v3 32/56] add_ref_decoration(): convert local variable original_sha1 to object_id brian m. carlson
2015-05-25 18:38 ` [PATCH v3 33/56] string_list_add_one_ref(): rewrite to take an object_id argument brian m. carlson
2015-05-25 18:39 ` [PATCH v3 34/56] add_one_ref(): " brian m. carlson
2015-05-25 18:39 ` [PATCH v3 35/56] remote: rewrite functions to take object_id arguments brian m. carlson
2015-05-25 18:39 ` [PATCH v3 36/56] register_replace_ref(): rewrite to take an object_id argument brian m. carlson
2015-05-25 18:39 ` [PATCH v3 37/56] handle_one_reflog(): " brian m. carlson
2015-05-25 18:39 ` [PATCH v3 38/56] add_info_ref(): " brian m. carlson
2015-05-25 18:39 ` [PATCH v3 39/56] handle_one_ref(): " brian m. carlson
2015-05-25 18:39 ` [PATCH v3 40/56] shallow: rewrite functions to take object_id arguments brian m. carlson
2015-05-25 18:39 ` [PATCH v3 41/56] submodule: rewrite to take an object_id argument brian m. carlson
2015-05-25 18:39 ` [PATCH v3 42/56] write_refs_to_temp_dir(): convert local variable sha1 to object_id brian m. carlson
2015-05-25 18:39 ` [PATCH v3 43/56] write_one_ref(): rewrite to take an object_id argument brian m. carlson
2015-05-25 18:39 ` [PATCH v3 44/56] find_symref(): " brian m. carlson
2015-05-25 18:39 ` [PATCH v3 45/56] find_symref(): convert local variable "unused" to object_id brian m. carlson
2015-05-25 18:39 ` [PATCH v3 46/56] upload-pack: rewrite functions to take object_id arguments brian m. carlson
2015-05-25 18:39 ` [PATCH v3 47/56] send_ref(): convert local variable "peeled" to object_id brian m. carlson
2015-05-25 18:39 ` [PATCH v3 48/56] mark_complete(): rewrite to take an object_id argument brian m. carlson
2015-05-25 18:39 ` [PATCH v3 49/56] clear_marks(): " brian m. carlson
2015-05-25 18:39 ` [PATCH v3 50/56] mark_complete_oid(): new function, taking an object_oid brian m. carlson
2015-05-25 18:39 ` [PATCH v3 51/56] mark_complete(): remove unneeded arguments brian m. carlson
2015-05-25 18:39 ` [PATCH v3 52/56] rev_list_insert_ref_oid(): new function, taking an object_oid brian m. carlson
2015-05-25 18:39 ` [PATCH v3 53/56] rev_list_insert_ref(): remove unneeded arguments brian m. carlson
2015-05-25 18:39 ` [PATCH v3 54/56] each_ref_fn_adapter(): remove adapter brian m. carlson
2015-05-25 18:39 ` [PATCH v3 55/56] warn_if_dangling_symref(): convert local variable "junk" to object_id brian m. carlson
2015-05-25 18:39 ` [PATCH v3 56/56] struct ref_lock: convert old_sha1 member " brian m. carlson
2015-05-25 19:34 ` [PATCH v3 00/56] Convert parts of refs.c to struct object_id Junio C Hamano
2015-05-25 19:40   ` brian m. carlson
2015-05-26 17:37     ` Stefan Beller
2015-05-27  0:04       ` brian m. carlson
2015-05-27  5:12         ` Junio C Hamano

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=1432579162-411464-23-git-send-email-sandals@crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=mhagger@alum.mit.edu \
    --cc=peff@peff.net \
    --cc=sbeller@google.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).