path: root/Documentation/technical/api-string-list.txt
AgeCommit message (Collapse)Author
2014-11-25sort_string_list(): rename to string_list_sort()Michael Haggerty
The new name is more consistent with the names of other string_list-related functions. Suggested-by: Junio C Hamano <> Signed-off-by: Michael Haggerty <> Signed-off-by: Junio C Hamano <>
2014-07-21string-list: add string_list initializer helper functionTanay Abhra
The string-list API has STRING_LIST_INIT_* macros to be used to define variables with initializers, but lacks functions to initialize an uninitialized piece of memory to be used as a string-list at the run-time. Introduce `string_list_init()` function for that. Signed-off-by: Tanay Abhra <> Reviewed-by: Matthieu Moy <> Signed-off-by: Junio C Hamano <>
2014-06-06string-list: spell all values out that are given to a string_list initializerTanay Abhra
STRING_LIST_INIT_{NODUP,DUP} initializers list values only for earlier structure members, relying on the usual convention in C that the omitted members are initailized to 0, i.e. the former is expanded to the latter: struct string_list l = STRING_LIST_INIT_DUP; struct string_list l = { NULL, 0, 0, 1 }; and the last member that is not mentioned (i.e. 'cmp') is initialized to NULL. While there is nothing wrong in this construct, spelling out all the values where the macros are defined will serve also as a documentation, so let's do so. Signed-off-by: Tanay Abhra <> Signed-off-by: Junio C Hamano <>
2013-01-02Merge branch 'mh/ceiling'Junio C Hamano
An element on GIT_CEILING_DIRECTORIES list that does not name the real path to a directory (i.e. a symbolic link) could have caused the GIT_DIR discovery logic to escape the ceiling. * mh/ceiling: string_list_longest_prefix(): remove function setup_git_directory_gently_1(): resolve symlinks in ceiling paths longest_ancestor_length(): require prefix list entries to be normalized longest_ancestor_length(): take a string_list argument for prefixes longest_ancestor_length(): use string_list_split() Introduce new function real_path_if_valid() real_path_internal(): add comment explaining use of cwd Introduce new static function real_path_internal()
2012-11-08string_list: add a function string_list_remove_empty_items()Michael Haggerty
Signed-off-by: Michael Haggerty <> Acked-by: Johan Herland <> Signed-off-by: Jeff King <>
2012-10-29string_list_longest_prefix(): remove functionMichael Haggerty
This function was added in f103f95b11d087f07c0c48bf784cd9197e18f203 in the erroneous expectation that it would be used in the reimplementation of longest_ancestor_length(). But it turned out to be easier to use a function specialized for comparing path prefixes (i.e., one that knows about slashes and root paths) than to prepare the paths in such a way that a generic string prefix comparison function can be used. So delete string_list_longest_prefix() and its documentation and test cases. Signed-off-by: Michael Haggerty <> Signed-off-by: Jeff King <>
2012-09-18string_list API: document what "sorted" meansMichael Haggerty
The recent work on using string_list to represent the list of refs that matched with the refs on the other side during fetch heavily depends on the sort order by string_list's implementation, and changing string_list will break it. Document that it uses strcmp() order, at least for now. Signed-off-by: Michael Haggerty <> Signed-off-by: Junio C Hamano <>
2012-09-12api-string-list.txt: initialize the string_list the easy wayMichael Haggerty
In the demo code blurb, show how to initialize the string_list using STRING_LIST_INIT_NODUP rather than memset(). Signed-off-by: Michael Haggerty <> Signed-off-by: Junio C Hamano <>
2012-09-12string_list: add a function string_list_longest_prefix()Michael Haggerty
Add a function that finds the longest string from a string_list that is a prefix of a given string. Signed-off-by: Michael Haggerty <> Signed-off-by: Junio C Hamano <>
2012-09-12string_list: add a new function, string_list_remove_duplicates()Michael Haggerty
Add a function that deletes duplicate entries from a sorted string_list. Signed-off-by: Michael Haggerty <> Signed-off-by: Junio C Hamano <>
2012-09-12string_list: add a new function, filter_string_list()Michael Haggerty
This function allows entries that don't match a specified criterion to be discarded from a string_list while preserving the order of the remaining entries. Signed-off-by: Michael Haggerty <> Signed-off-by: Junio C Hamano <>
2012-09-12string_list: add two new functions for splitting stringsMichael Haggerty
Add two new functions, string_list_split() and string_list_split_in_place(). These split a string into a string_list on a separator character. The first makes copies of the substrings (leaving the input string untouched) and the second splits the original string in place, overwriting the separator characters with NULs and referring to the original string's memory. These functions are similar to the strbuf_split_*() functions except that they work with the more powerful string_list interface. Signed-off-by: Michael Haggerty <> Signed-off-by: Junio C Hamano <>
2012-09-12string_list: add function string_list_append_nodup()Michael Haggerty
Add a new function that appends a string to a string_list without copying it. This can be used to pass ownership of an already-copied string to a string_list that has strdup_strings set. Signed-off-by: Michael Haggerty <> Signed-off-by: Junio C Hamano <>
2012-03-30string-list: document that string_list_insert() inserts unique stringsHeiko Voigt
Signed-off-by: Heiko Voigt <> Signed-off-by: Junio C Hamano <>
2011-08-14string-list: Add API to remove an item from an unsorted listJohannes Sixt
Teach the string-list API how to remove an entry in O(1) runtime by moving the last entry to the vacated spot. As such, the routine works only for unsorted lists. Signed-off-by: Johannes Sixt <> Signed-off-by: Elijah Newren <> Signed-off-by: Junio C Hamano <>
2010-06-27string_list: Fix argument order for string_list_appendJulian Phillips
Update the definition and callers of string_list_append to use the string_list as the first argument. This helps make the string_list API easier to use by being more consistent. Signed-off-by: Julian Phillips <> Signed-off-by: Junio C Hamano <>
2010-03-25string-list: add unsorted_string_list_lookup()Stephen Boyd
Sometimes users need to lookup a string in an unsorted string_list. In that case they should use this function instead of the version for sorted strings. Signed-off-by: Stephen Boyd <> Signed-off-by: Junio C Hamano <>
2008-07-22Fix two leftovers from path_list->string_listJohannes Schindelin
In the documentation, where you cannot get compile errors for using the wrong member name, there were two mentions of 'path' left. Signed-off-by: Johannes Schindelin <> Signed-off-by: Junio C Hamano <>
2008-07-22Rename path_list to string_listJohannes Schindelin
The name path_list was correct for the first usage of that data structure, but it really is a general-purpose string list. $ perl -i -pe 's/path-list/string-list/g' $(git grep -l path-list) $ perl -i -pe 's/path_list/string_list/g' $(git grep -l path_list) $ git mv path-list.h string-list.h $ git mv path-list.c string-list.c $ perl -i -pe 's/has_path/has_string/g' $(git grep -l has_path) $ perl -i -pe 's/path/string/g' string-list.[ch] $ git mv Documentation/technical/api-path-list.txt \ Documentation/technical/api-string-list.txt $ perl -i -pe 's/strdup_paths/strdup_strings/g' $(git grep -l strdup_paths) ... and then fix all users of string-list to access the member "string" instead of "path". Documentation/technical/api-string-list.txt needed some rewrapping, too. Signed-off-by: Johannes Schindelin <> Signed-off-by: Junio C Hamano <>