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

[PATCH] string_list API: document what "sorted" means.

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Sep 17, 2012, 15:21 UTC
Message-ID
<1347895267-5054-1-git-send-email-mhagger@alum.mit.edu>

Junio pointed out that the sort order currently used by string_list could be considered to be an implementation detail internal to string_list. But the sort order is already visible to the outside world (e.g., via iteration or via print_string_list()), so it shouldn't be changed willy-nilly. Therefore, document the current sort order as part of the API's contract.

(If, at some future time, somebody wants a string_list that is sorted by a different criterion, then the order should be made specifiable via a callback function specified by the user.)

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 Documentation/technical/api-string-list.txt | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/Documentation/technical/api-string-list.txt b/Documentation/technical/api-string-list.txt
index 155ac8c..94d7a2b 100644
--- a/Documentation/technical/api-string-list.txt
+++ b/Documentation/technical/api-string-list.txt
@@ -1,8 +1,9 @@
 string-list API
 ===============
 
-The string_list API offers a data structure and functions to handle sorted
-and unsorted string lists.
+The string_list API offers a data structure and functions to handle
+sorted and unsorted string lists.  A "sorted" list is one whose
+entries are sorted by string value in `strcmp()` order.
 
 The 'string_list' struct used to be called 'path_list', but was renamed
 because it is not specific to paths.
@@ -143,7 +144,7 @@ write `string_list_insert(...)->util = ...;`.
 
 `sort_string_list`::
 
-	Make an unsorted list sorted.
+	Sort the list's entries by string value in `strcmp()` order.
 
 `unsorted_string_list_has_string`::
 
-- 
1.7.11.3
Next: Junio C Hamano
Message 1 of 7 in “string_list API: document what "sorted" means.”
  1. string_list API: document what "sorted" means.Michael Haggerty, Sep 17, 2012
  2. Junio C HamanoSep 17, 2012
  3. Michael HaggertySep 18, 2012
  4. Junio C HamanoSep 18, 2012
  5. Michael HaggertySep 18, 2012
  6. Junio C HamanoSep 18, 2012
  7. Michael HaggertySep 19, 2012

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.