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

[PATCH v2 21/21] Documentation: update and rename api-sha1-array.txt

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Mar 26, 2017, 16:01 UTC
Message-ID
<20170326160143.769630-22-sandals@crustytoothpaste.net>
In-Reply-To
<20170326160143.769630-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 14 of 40 in “object_id part 7”
  1. 00/21 object_id part 7brian m. carlson, Mar 26, 2017
  2. 08/21 fsck: convert init_skiplist to struct object_idbrian m. carlson, Mar 26, 2017
  3. 12/21 sha1_name: convert disambiguate_hint_fn to take object_idbrian m. carlson, Mar 26, 2017
  4. 16/21 Make sha1_array_append take a struct object_id *brian m. carlson, Mar 26, 2017
  5. Jeff KingMar 28, 2017
  6. Junio C HamanoMar 28, 2017
  7. brian m. carlsonMar 29, 2017
  8. Junio C HamanoMar 29, 2017
  9. brian m. carlsonMar 29, 2017
  10. 09/21 parse-options-cb: convert sha1_array_append caller to struct object_idbrian m. carlson, Mar 26, 2017
  11. 18/21 Convert sha1_array_lookup to take struct object_idbrian m. carlson, Mar 26, 2017
  12. 17/21 Convert remaining callers of sha1_array_lookup to object_idbrian m. carlson, Mar 26, 2017
  13. 10/21 test-sha1-array: convert most code to struct object_idbrian m. carlson, Mar 26, 2017
  14. 21/21 Documentation: update and rename api-sha1-array.txtbrian m. carlson, Mar 26, 2017
  15. 07/21 builtin/receive-pack: convert portions to struct object_idbrian m. carlson, Mar 26, 2017
  16. Jeff KingMar 28, 2017
  17. brian m. carlsonMar 29, 2017
  18. Jeff KingMar 30, 2017
  19. 20/21 Rename sha1_array to oid_arraybrian m. carlson, Mar 26, 2017
  20. 05/21 builtin/pull: convert portions to struct object_idbrian m. carlson, Mar 26, 2017
  21. 19/21 Convert sha1_array_for_each_unique and for_each_abbrev to object_idbrian m. carlson, Mar 26, 2017
  22. 06/21 builtin/receive-pack: fix incorrect pointer arithmeticbrian m. carlson, Mar 26, 2017
  23. Jeff KingMar 28, 2017
  24. Junio C HamanoMar 28, 2017
  25. 14/21 builtin/pull: convert to struct object_idbrian m. carlson, Mar 26, 2017
  26. 01/21 Define new hash-size constants for allocating memorybrian m. carlson, Mar 26, 2017
  27. 03/21 Convert GIT_SHA1_RAWSZ used for allocation to GIT_MAX_RAWSZbrian m. carlson, Mar 26, 2017
  28. 11/21 sha1_name: convert struct disambiguate_state to object_idbrian m. carlson, Mar 26, 2017
  29. 15/21 sha1-array: convert internal storage for struct sha1_array to object_idbrian m. carlson, Mar 26, 2017
  30. Jeff KingMar 28, 2017
  31. 13/21 submodule: convert check_for_new_submodule_commits to object_idbrian m. carlson, Mar 26, 2017
  32. 02/21 Convert GIT_SHA1_HEXSZ used for allocation to GIT_MAX_HEXSZbrian m. carlson, Mar 26, 2017
  33. 04/21 builtin/diff: convert to struct object_idbrian m. carlson, Mar 26, 2017
  34. Jeff KingMar 28, 2017
  35. brian m. carlsonMar 28, 2017
  36. Jeff KingMar 28, 2017
  37. Jeff KingMar 28, 2017
  38. Junio C HamanoMar 28, 2017
  39. Jeff KingMar 28, 2017
  40. Junio C HamanoMar 28, 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.