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

[PATCH v4 18/19] builtin/merge-base: convert to struct object_id

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Feb 20, 2017, 00:10 UTC
Message-ID
<20170220001031.559931-19-sandals@crustytoothpaste.net>
In-Reply-To
<20170220001031.559931-1-sandals@crustytoothpaste.net>
Convert the remaining uses of unsigned char [20] to struct object_id.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 builtin/merge-base.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index db95bc29cf..cfe2a796f8 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -36,12 +36,12 @@ static const char * const merge_base_usage[] = {
 
 static struct commit *get_commit_reference(const char *arg)
 {
-	unsigned char revkey[20];
+	struct object_id revkey;
 	struct commit *r;
 
-	if (get_sha1(arg, revkey))
+	if (get_oid(arg, &revkey))
 		die("Not a valid object name %s", arg);
-	r = lookup_commit_reference(revkey);
+	r = lookup_commit_reference(revkey.hash);
 	if (!r)
 		die("Not a valid commit name %s", arg);
 
@@ -113,14 +113,14 @@ struct rev_collect {
 	unsigned int initial : 1;
 };
 
-static void add_one_commit(unsigned char *sha1, struct rev_collect *revs)
+static void add_one_commit(struct object_id *oid, struct rev_collect *revs)
 {
 	struct commit *commit;
 
-	if (is_null_sha1(sha1))
+	if (is_null_oid(oid))
 		return;
 
-	commit = lookup_commit(sha1);
+	commit = lookup_commit(oid->hash);
 	if (!commit ||
 	    (commit->object.flags & TMP_MARK) ||
 	    parse_commit(commit))
@@ -139,15 +139,15 @@ static int collect_one_reflog_ent(struct object_id *ooid, struct object_id *noid
 
 	if (revs->initial) {
 		revs->initial = 0;
-		add_one_commit(ooid->hash, revs);
+		add_one_commit(ooid, revs);
 	}
-	add_one_commit(noid->hash, revs);
+	add_one_commit(noid, revs);
 	return 0;
 }
 
 static int handle_fork_point(int argc, const char **argv)
 {
-	unsigned char sha1[20];
+	struct object_id oid;
 	char *refname;
 	const char *commitname;
 	struct rev_collect revs;
@@ -155,7 +155,7 @@ static int handle_fork_point(int argc, const char **argv)
 	struct commit_list *bases;
 	int i, ret = 0;
 
-	switch (dwim_ref(argv[0], strlen(argv[0]), sha1, &refname)) {
+	switch (dwim_ref(argv[0], strlen(argv[0]), oid.hash, &refname)) {
 	case 0:
 		die("No such ref: '%s'", argv[0]);
 	case 1:
@@ -165,16 +165,16 @@ static int handle_fork_point(int argc, const char **argv)
 	}
 
 	commitname = (argc == 2) ? argv[1] : "HEAD";
-	if (get_sha1(commitname, sha1))
+	if (get_oid(commitname, &oid))
 		die("Not a valid object name: '%s'", commitname);
 
-	derived = lookup_commit_reference(sha1);
+	derived = lookup_commit_reference(oid.hash);
 	memset(&revs, 0, sizeof(revs));
 	revs.initial = 1;
 	for_each_reflog_ent(refname, collect_one_reflog_ent, &revs);
 
-	if (!revs.nr && !get_sha1(refname, sha1))
-		add_one_commit(sha1, &revs);
+	if (!revs.nr && !get_oid(refname, &oid))
+		add_one_commit(&oid, &revs);
 
 	for (i = 0; i < revs.nr; i++)
 		revs.commit[i]->object.flags &= ~TMP_MARK;
-- 
2.11.0
Previous: brian m. carlsonNext: brian m. carlson
Message 6 of 24 in “object_id part 6”
  1. 00/19 object_id part 6brian m. carlson, Feb 20, 2017
  2. 16/19 sha1_file: introduce an nth_packed_object_oid functionbrian m. carlson, Feb 20, 2017
  3. 15/19 refs: simplify parsing of reflog entriesbrian m. carlson, Feb 20, 2017
  4. 05/19 builtin/fast-export: convert to struct object_idbrian m. carlson, Feb 20, 2017
  5. 09/19 builtin/clone: convert to struct object_idbrian m. carlson, Feb 20, 2017
  6. 18/19 builtin/merge-base: convert to struct object_idbrian m. carlson, Feb 20, 2017
  7. 01/19 hex: introduce parse_oid_hexbrian m. carlson, Feb 20, 2017
  8. 12/19 builtin/replace: convert to struct object_idbrian m. carlson, Feb 20, 2017
  9. 14/19 refs: convert each_reflog_ent_fn to struct object_idbrian m. carlson, Feb 20, 2017
  10. 19/19 wt-status: convert to struct object_idbrian m. carlson, Feb 20, 2017
  11. 08/19 builtin/branch: convert to struct object_idbrian m. carlson, Feb 20, 2017
  12. 17/19 Convert object iteration callbacks to struct object_idbrian m. carlson, Feb 20, 2017
  13. 06/19 builtin/fmt-merge-message: convert to struct object_idbrian m. carlson, Feb 20, 2017
  14. 07/19 builtin/grep: convert to struct object_idbrian m. carlson, Feb 20, 2017
  15. 13/19 reflog-walk: convert struct reflog_info to struct object_idbrian m. carlson, Feb 20, 2017
  16. 11/19 Convert remaining callers of resolve_refdup to object_idbrian m. carlson, Feb 20, 2017
  17. 10/19 builtin/merge: convert to struct object_idbrian m. carlson, Feb 20, 2017
  18. 02/19 builtin/commit: convert to struct object_idbrian m. carlson, Feb 20, 2017
  19. 04/19 builtin/describe: convert to struct object_idbrian m. carlson, Feb 20, 2017
  20. 03/19 builtin/diff-tree: convert to struct object_idbrian m. carlson, Feb 20, 2017
  21. Jeff KingFeb 20, 2017
  22. brian m. carlsonFeb 21, 2017
  23. Jeff KingFeb 21, 2017
  24. brian m. carlsonFeb 21, 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.