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

[PATCH v3 20/20] Documentation: update and rename api-sha1-array.txt

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Mar 31, 2017, 01:40 UTC
Message-ID
<20170331014001.953484-21-sandals@crustytoothpaste.net>
In-Reply-To
<20170331014001.953484-1-sandals@crustytoothpaste.net>

Since the structure and functions have changed names, update the code examples and the documentation. Rename the file to match the new name of the API.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 .../{api-sha1-array.txt => api-oid-array.txt}      | 44 +++++++++++-----------
 1 file changed, 22 insertions(+), 22 deletions(-)
 rename Documentation/technical/{api-sha1-array.txt => api-oid-array.txt} (61%)
diff --git a/Documentation/technical/api-sha1-array.txt b/Documentation/technical/api-oid-array.txt
similarity index 61%
rename from Documentation/technical/api-sha1-array.txt
rename to Documentation/technical/api-oid-array.txt
index dcc52943a5..b0c11f868d 100644
--- a/Documentation/technical/api-sha1-array.txt
+++ b/Documentation/technical/api-oid-array.txt
@@ -1,7 +1,7 @@
-sha1-array API
+oid-array API
 ==============
 
-The sha1-array API provides storage and manipulation of sets of SHA-1
+The oid-array API provides storage and manipulation of sets of object
 identifiers. The emphasis is on storage and processing efficiency,
 making them suitable for large lists. Note that the ordering of items is
 not preserved over some operations.
@@ -9,10 +9,10 @@ not preserved over some operations.
 Data Structures
 ---------------
 
-`struct sha1_array`::
+`struct oid_array`::
 
-	A single array of SHA-1 hashes. This should be initialized by
-	assignment from `SHA1_ARRAY_INIT`.  The `sha1` member contains
+	A single array of object IDs. This should be initialized by
+	assignment from `OID_ARRAY_INIT`.  The `oid` member contains
 	the actual data. The `nr` member contains the number of items in
 	the set.  The `alloc` and `sorted` members are used internally,
 	and should not be needed by API callers.
@@ -20,22 +20,22 @@ Data Structures
 Functions
 ---------
 
-`sha1_array_append`::
-	Add an item to the set. The sha1 will be placed at the end of
+`oid_array_append`::
+	Add an item to the set. The object ID will be placed at the end of
 	the array (but note that some operations below may lose this
 	ordering).
 
-`sha1_array_lookup`::
-	Perform a binary search of the array for a specific sha1.
+`oid_array_lookup`::
+	Perform a binary search of the array for a specific object ID.
 	If found, returns the offset (in number of elements) of the
-	sha1. If not found, returns a negative integer. If the array is
-	not sorted, this function has the side effect of sorting it.
+	object ID. If not found, returns a negative integer. If the array
+	is not sorted, this function has the side effect of sorting it.
 
-`sha1_array_clear`::
+`oid_array_clear`::
 	Free all memory associated with the array and return it to the
 	initial, empty state.
 
-`sha1_array_for_each_unique`::
+`oid_array_for_each_unique`::
 	Efficiently iterate over each unique element of the list,
 	executing the callback function for each one. If the array is
 	not sorted, this function has the side effect of sorting it. If
@@ -47,25 +47,25 @@ Examples
 --------
 
 -----------------------------------------
-int print_callback(const unsigned char sha1[20],
+int print_callback(const struct object_id *oid,
 		    void *data)
 {
-	printf("%s\n", sha1_to_hex(sha1));
+	printf("%s\n", oid_to_hex(oid));
 	return 0; /* always continue */
 }
 
 void some_func(void)
 {
-	struct sha1_array hashes = SHA1_ARRAY_INIT;
-	unsigned char sha1[20];
+	struct sha1_array hashes = OID_ARRAY_INIT;
+	struct object_id oid;
 
 	/* Read objects into our set */
-	while (read_object_from_stdin(sha1))
-		sha1_array_append(&hashes, sha1);
+	while (read_object_from_stdin(oid.hash))
+		oid_array_append(&hashes, &oid);
 
 	/* Check if some objects are in our set */
-	while (read_object_from_stdin(sha1)) {
-		if (sha1_array_lookup(&hashes, sha1) >= 0)
+	while (read_object_from_stdin(oid.hash)) {
+		if (oid_array_lookup(&hashes, &oid) >= 0)
 			printf("it's in there!\n");
 
 	/*
@@ -75,6 +75,6 @@ void some_func(void)
 	 * Instead, this will sort once and then skip duplicates
 	 * in linear time.
 	 */
-	sha1_array_for_each_unique(&hashes, print_callback, NULL);
+	oid_array_for_each_unique(&hashes, print_callback, NULL);
 }
 -----------------------------------------
Previous: brian m. carlsonNext: brian m. carlson
Message 9 of 24 in “object_id part 7”
  1. 00/20 object_id part 7brian m. carlson, Mar 31, 2017
  2. 04/20 builtin/diff: convert to struct object_idbrian m. carlson, Mar 31, 2017
  3. 09/20 test-sha1-array: convert most code to struct object_idbrian m. carlson, Mar 31, 2017
  4. 13/20 builtin/pull: convert to struct object_idbrian m. carlson, Mar 31, 2017
  5. 15/20 Make sha1_array_append take a struct object_id *brian m. carlson, Mar 31, 2017
  6. 12/20 submodule: convert check_for_new_submodule_commits to object_idbrian m. carlson, Mar 31, 2017
  7. 16/20 Convert remaining callers of sha1_array_lookup to object_idbrian m. carlson, Mar 31, 2017
  8. 19/20 Rename sha1_array to oid_arraybrian m. carlson, Mar 31, 2017
  9. 20/20 Documentation: update and rename api-sha1-array.txtbrian m. carlson, Mar 31, 2017
  10. 14/20 sha1-array: convert internal storage for struct sha1_array to object_idbrian m. carlson, Mar 31, 2017
  11. Junio C HamanoMar 31, 2017
  12. 18/20 Convert sha1_array_for_each_unique and for_each_abbrev to object_idbrian m. carlson, Mar 31, 2017
  13. 07/20 fsck: convert init_skiplist to struct object_idbrian m. carlson, Mar 31, 2017
  14. 17/20 Convert sha1_array_lookup to take struct object_idbrian m. carlson, Mar 31, 2017
  15. 11/20 sha1_name: convert disambiguate_hint_fn to take object_idbrian m. carlson, Mar 31, 2017
  16. 08/20 parse-options-cb: convert sha1_array_append caller to struct object_idbrian m. carlson, Mar 31, 2017
  17. 10/20 sha1_name: convert struct disambiguate_state to object_idbrian m. carlson, Mar 31, 2017
  18. 01/20 Define new hash-size constants for allocating memorybrian m. carlson, Mar 31, 2017
  19. 03/20 Convert GIT_SHA1_RAWSZ used for allocation to GIT_MAX_RAWSZbrian m. carlson, Mar 31, 2017
  20. 05/20 builtin/pull: convert portions to struct object_idbrian m. carlson, Mar 31, 2017
  21. 06/20 builtin/receive-pack: convert portions to struct object_idbrian m. carlson, Mar 31, 2017
  22. René ScharfeJul 15, 2017
  23. 02/20 Convert GIT_SHA1_HEXSZ used for allocation to GIT_MAX_HEXSZbrian m. carlson, Mar 31, 2017
  24. Junio C HamanoMar 31, 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.