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

[PATCH 1/6] Introduce a get_oid function.

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Apr 17, 2016, 23:10 UTC
Message-ID
<1460934641-435791-2-git-send-email-sandals@crustytoothpaste.net>
In-Reply-To
<1460934641-435791-1-git-send-email-sandals@crustytoothpaste.net>

The get_oid function is equivalent to the get_sha1 function, but uses a struct object_id instead.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 cache.h     | 2 ++
 sha1_name.c | 9 +++++++++
 2 files changed, 11 insertions(+)
diff --git a/cache.h b/cache.h
index 2711048c..22b73646 100644
--- a/cache.h
+++ b/cache.h
@@ -1156,6 +1156,8 @@ extern int get_sha1_blob(const char *str, unsigned char *sha1);
 extern void maybe_die_on_misspelt_object_name(const char *name, const char *prefix);
 extern int get_sha1_with_context(const char *str, unsigned flags, unsigned char *sha1, struct object_context *orc);
 
+extern int get_oid(const char *str, struct object_id *oid);
+
 typedef int each_abbrev_fn(const unsigned char *sha1, void *);
 extern int for_each_abbrev(const char *prefix, each_abbrev_fn, void *);
 
diff --git a/sha1_name.c b/sha1_name.c
index 776101e8..ca7ddd6f 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1215,6 +1215,15 @@ int get_sha1(const char *name, unsigned char *sha1)
 }
 
 /*
+ * This is like "get_sha1()", but for struct object_id.
+ */
+int get_oid(const char *name, struct object_id *oid)
+{
+	return get_sha1(name, oid->hash);
+}
+
+
+/*
  * Many callers know that the user meant to name a commit-ish by
  * syntactical positions where the object name appears.  Calling this
  * function allows the machinery to disambiguate shorter-than-unique
-- 
2.8.0.rc3.226.g39d4020
Previous: brian m. carlsonNext: brian m. carlson
Message 2 of 10 in “object_id Part 3”
  1. 0/6 object_id Part 3brian m. carlson, Apr 17, 2016
  2. 1/6 Introduce a get_oid function.brian m. carlson, Apr 17, 2016
  3. 2/6 test-match-trees: convert to use struct object_idbrian m. carlson, Apr 17, 2016
  4. 3/6 match-trees: convert shift_tree and shift_tree_by to object_idbrian m. carlson, Apr 17, 2016
  5. 4/6 Convert struct name_entry to use struct object_id.brian m. carlson, Apr 17, 2016
  6. Junio C HamanoApr 19, 2016
  7. brian m. carlsonApr 19, 2016
  8. Junio C HamanoApr 20, 2016
  9. 5/6 tree-walk: convert tree_entry_extract to struct object_idbrian m. carlson, Apr 17, 2016
  10. 6/6 match-trees: convert several leaf functions to struct object_idbrian m. carlson, Apr 17, 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.