MCPcopy Create free account
hub / github.com/git/git / cmd__string_list

Function cmd__string_list

t/helper/test-string-list.c:5–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include "string-list.h"
4
5int cmd__string_list(int argc, const char **argv)
6{
7 if (argc == 2 && !strcmp(argv[1], "sort")) {
8 struct string_list list = STRING_LIST_INIT_NODUP;
9 struct strbuf sb = STRBUF_INIT;
10 struct string_list_item *item;
11
12 strbuf_read(&sb, 0, 0);
13
14 /*
15 * Split by newline, but don't create a string_list item
16 * for the empty string after the last separator.
17 */
18 if (sb.len && sb.buf[sb.len - 1] == '\n')
19 strbuf_setlen(&sb, sb.len - 1);
20 string_list_split_in_place(&list, sb.buf, "\n", -1);
21
22 string_list_sort(&list);
23
24 for_each_string_list_item(item, &list)
25 puts(item->string);
26
27 string_list_clear(&list, 0);
28 strbuf_release(&sb);
29 return 0;
30 }
31
32 fprintf(stderr, "%s: unknown function name: %s\n", argv[0],
33 argv[1] ? argv[1] : "(there was none)");
34 return 1;
35}

Callers

nothing calls this directly

Calls 6

strbuf_readFunction · 0.85
strbuf_setlenFunction · 0.85
string_list_clearFunction · 0.85
strbuf_releaseFunction · 0.85
string_list_sortFunction · 0.50

Tested by

no test coverage detected