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

[PATCH v3 17/56] builtin/remote: rewrite functions to take object_id arguments

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
May 25, 2015, 18:38 UTC
Message-ID
<1432579162-411464-18-git-send-email-sandals@crustytoothpaste.net>
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/remote.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/builtin/remote.c b/builtin/remote.c
index ab39fea..f4a6ec9 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -554,20 +554,20 @@ struct rename_info {
 };
 
 static int read_remote_branches(const char *refname,
-	const unsigned char *sha1, int flags, void *cb_data)
+	const struct object_id *oid, int flags, void *cb_data)
 {
 	struct rename_info *rename = cb_data;
 	struct strbuf buf = STRBUF_INIT;
 	struct string_list_item *item;
 	int flag;
-	unsigned char orig_sha1[20];
+	struct object_id orig_oid;
 	const char *symref;
 
 	strbuf_addf(&buf, "refs/remotes/%s/", rename->old);
 	if (starts_with(refname, buf.buf)) {
 		item = string_list_append(rename->remote_branches, xstrdup(refname));
 		symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING,
-					    orig_sha1, &flag);
+					    orig_oid.hash, &flag);
 		if (flag & REF_ISSYMREF)
 			item->util = xstrdup(symref);
 		else
@@ -620,8 +620,6 @@ static int mv(int argc, const char **argv)
 	struct string_list remote_branches = STRING_LIST_INIT_NODUP;
 	struct rename_info rename;
 	int i, refspec_updated = 0;
-	struct each_ref_fn_sha1_adapter wrapped_read_remote_branches =
-		{read_remote_branches, &rename};
 
 	if (argc != 3)
 		usage_with_options(builtin_remote_rename_usage, options);
@@ -699,13 +697,13 @@ static int mv(int argc, const char **argv)
 	 * First remove symrefs, then rename the rest, finally create
 	 * the new symrefs.
 	 */
-	for_each_ref(each_ref_fn_adapter, &wrapped_read_remote_branches);
+	for_each_ref(read_remote_branches, &rename);
 	for (i = 0; i < remote_branches.nr; i++) {
 		struct string_list_item *item = remote_branches.items + i;
 		int flag = 0;
-		unsigned char sha1[20];
+		struct object_id oid;
 
-		read_ref_full(item->string, RESOLVE_REF_READING, sha1, &flag);
+		read_ref_full(item->string, RESOLVE_REF_READING, oid.hash, &flag);
 		if (!(flag & REF_ISSYMREF))
 			continue;
 		if (delete_ref(item->string, NULL, REF_NODEREF))
@@ -866,7 +864,7 @@ static void free_remote_ref_states(struct ref_states *states)
 }
 
 static int append_ref_to_tracked_list(const char *refname,
-	const unsigned char *sha1, int flags, void *cb_data)
+	const struct object_id *oid, int flags, void *cb_data)
 {
 	struct ref_states *states = cb_data;
 	struct refspec refspec;
@@ -909,10 +907,7 @@ static int get_remote_ref_states(const char *name,
 		if (query & GET_PUSH_REF_STATES)
 			get_push_ref_states(remote_refs, states);
 	} else {
-		struct each_ref_fn_sha1_adapter wrapped_append_ref_to_tracked_list =
-			{append_ref_to_tracked_list, states};
-
-		for_each_ref(each_ref_fn_adapter, &wrapped_append_ref_to_tracked_list);
+		for_each_ref(append_ref_to_tracked_list, states);
 		string_list_sort(&states->tracked);
 		get_push_ref_states_noquery(states);
 	}
-- 
2.4.0
Previous: Michael HaggertyNext: brian m. carlson
Message 19 of 63 in “Convert parts of refs.c to struct object_id”
  1. 00/56 Convert parts of refs.c to struct object_idbrian m. carlson, May 25, 2015
  2. 01/56 refs: convert struct ref_entry to use struct object_idbrian m. carlson, May 25, 2015
  3. 02/56 each_ref_fn: change to take an object_id parameterbrian m. carlson, May 25, 2015
  4. 03/56 builtin/rev-parse: rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  5. 04/56 handle_one_ref(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  6. 05/56 register_ref(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  7. 06/56 append_ref(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  8. 07/56 add_pending_uninteresting_ref(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  9. 08/56 get_name(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  10. 09/56 builtin/fetch: rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  11. 10/56 grab_single_ref(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  12. 11/56 name_ref(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  13. 12/56 builtin/pack-objects: rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  14. 13/56 show_ref_cb(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  15. 14/56 builtin/reflog: rewrite ref functions to take an object_id argumentbrian m. carlson, May 25, 2015
  16. 15/56 add_branch_for_removal(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  17. 16/56 add_branch_for_removal(): don't set "util" field of string_list entriesbrian m. carlson, May 25, 2015
  18. Michael HaggertyJun 5, 2015
  19. 17/56 builtin/remote: rewrite functions to take object_id argumentsbrian m. carlson, May 25, 2015
  20. 18/56 show_reference(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  21. 19/56 append_matching_ref(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  22. 20/56 builtin/show-branch: rewrite functions to take object_id argumentsbrian m. carlson, May 25, 2015
  23. 21/56 append_one_rev(): rewrite to work with object_idbrian m. carlson, May 25, 2015
  24. 22/56 builtin/show-branch: rewrite functions to work with object_idbrian m. carlson, May 25, 2015
  25. 23/56 cmd_show_branch(): fix error messagebrian m. carlson, May 25, 2015
  26. 24/56 fsck: change functions to use object_idbrian m. carlson, May 25, 2015
  27. 25/56 builtin/show-ref: rewrite to use object_idbrian m. carlson, May 25, 2015
  28. 26/56 show_ref(): convert local variable peeled to object_idbrian m. carlson, May 25, 2015
  29. 27/56 builtin/show-ref: rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  30. 28/56 append_similar_ref(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  31. 29/56 http-backend: rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  32. 30/56 show_head_ref(): convert local variable "unused" to object_idbrian m. carlson, May 25, 2015
  33. 31/56 add_ref_decoration(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  34. 32/56 add_ref_decoration(): convert local variable original_sha1 to object_idbrian m. carlson, May 25, 2015
  35. 33/56 string_list_add_one_ref(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  36. 34/56 add_one_ref(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  37. 35/56 remote: rewrite functions to take object_id argumentsbrian m. carlson, May 25, 2015
  38. 36/56 register_replace_ref(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  39. 37/56 handle_one_reflog(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  40. 38/56 add_info_ref(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  41. 39/56 handle_one_ref(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  42. 40/56 shallow: rewrite functions to take object_id argumentsbrian m. carlson, May 25, 2015
  43. 41/56 submodule: rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  44. 42/56 write_refs_to_temp_dir(): convert local variable sha1 to object_idbrian m. carlson, May 25, 2015
  45. 43/56 write_one_ref(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  46. 44/56 find_symref(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  47. 45/56 find_symref(): convert local variable "unused" to object_idbrian m. carlson, May 25, 2015
  48. 46/56 upload-pack: rewrite functions to take object_id argumentsbrian m. carlson, May 25, 2015
  49. 47/56 send_ref(): convert local variable "peeled" to object_idbrian m. carlson, May 25, 2015
  50. 48/56 mark_complete(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  51. 49/56 clear_marks(): rewrite to take an object_id argumentbrian m. carlson, May 25, 2015
  52. 50/56 mark_complete_oid(): new function, taking an object_oidbrian m. carlson, May 25, 2015
  53. 51/56 mark_complete(): remove unneeded argumentsbrian m. carlson, May 25, 2015
  54. 52/56 rev_list_insert_ref_oid(): new function, taking an object_oidbrian m. carlson, May 25, 2015
  55. 53/56 rev_list_insert_ref(): remove unneeded argumentsbrian m. carlson, May 25, 2015
  56. 54/56 each_ref_fn_adapter(): remove adapterbrian m. carlson, May 25, 2015
  57. 55/56 warn_if_dangling_symref(): convert local variable "junk" to object_idbrian m. carlson, May 25, 2015
  58. 56/56 struct ref_lock: convert old_sha1 member to object_idbrian m. carlson, May 25, 2015
  59. Junio C HamanoMay 25, 2015
  60. brian m. carlsonMay 25, 2015
  61. Stefan BellerMay 26, 2015
  62. brian m. carlsonMay 27, 2015
  63. Junio C HamanoMay 27, 2015

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.