diff options
| author | Jiang Xin <worldhello.net@gmail.com> | 2023-05-16 10:19:48 +0800 |
|---|---|---|
| committer | Jiang Xin <worldhello.net@gmail.com> | 2023-05-16 10:19:48 +0800 |
| commit | 03d05937a70900819a5a73583a96bcb1fd06eb68 (patch) | |
| tree | d952758a83872e5da54abd45fc8463037fb329ee /string-list.c | |
| parent | f66ad35508e31c80fb0a7c235bdadfb76fc8ffaf (diff) | |
| parent | 0df2c180904f6b709766f9c24669a9d01543f915 (diff) | |
Merge tag 'v2.41.0-rc0'
Git 2.41-rc0
* tag 'v2.41.0-rc0': (508 commits)
Git 2.41-rc0
t5583: fix shebang line
merge-tree: load default git config
fetch: introduce machine-parseable "porcelain" output format
fetch: move option related variables into main function
fetch: lift up parsing of "fetch.output" config variable
fetch: introduce `display_format` enum
fetch: refactor calculation of the display table width
fetch: print left-hand side when fetching HEAD:foo
fetch: add a test to exercise invalid output formats
fetch: split out tests for output format
fetch: fix `--no-recurse-submodules` with multi-remote fetches
The eighteenth batch
The seventeenth batch
diff-files: integrate with sparse index
t1092: add tests for `git diff-files`
test: rev-parse-upstream: add missing cmp
t: drop "verbose" helper function
t7001: use "ls-files --format" instead of "cut"
t7001: avoid git on upstream of pipe
...
Diffstat (limited to 'string-list.c')
| -rw-r--r-- | string-list.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/string-list.c b/string-list.c index 42bacaec55..0f8ac117fd 100644 --- a/string-list.c +++ b/string-list.c @@ -1,5 +1,6 @@ -#include "cache.h" +#include "git-compat-util.h" #include "string-list.h" +#include "alloc.h" void string_list_init_nodup(struct string_list *list) { @@ -202,6 +203,15 @@ void string_list_clear_func(struct string_list *list, string_list_clear_func_t c list->nr = list->alloc = 0; } +void string_list_setlen(struct string_list *list, size_t nr) +{ + if (list->strdup_strings) + BUG("cannot setlen a string_list which owns its entries"); + if (nr > list->nr) + BUG("cannot grow a string_list with setlen"); + list->nr = nr; +} + struct string_list_item *string_list_append_nodup(struct string_list *list, char *string) { @@ -300,7 +310,7 @@ int string_list_split(struct string_list *list, const char *string, } int string_list_split_in_place(struct string_list *list, char *string, - int delim, int maxsplit) + const char *delim, int maxsplit) { int count = 0; char *p = string, *end; @@ -314,7 +324,7 @@ int string_list_split_in_place(struct string_list *list, char *string, string_list_append(list, p); return count; } - end = strchr(p, delim); + end = strpbrk(p, delim); if (end) { *end = '\0'; string_list_append(list, p); |
