summaryrefslogtreecommitdiff
path: root/test-string-list.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2012-09-12 16:04:45 +0200
committerJunio C Hamano <gitster@pobox.com>2012-09-12 11:43:25 -0700
commit31d5451eed2677531c80177ff9dc8f5285f5a187 (patch)
treebd709b58ba3096867e2f6166f516773b67aad0e1 /test-string-list.c
parenteb5f0c7a616531a024a582b72ca6d8775ff98d46 (diff)
downloadgit-31d5451eed2677531c80177ff9dc8f5285f5a187.tar.gz
string_list: add a new function, string_list_remove_duplicates()
Add a function that deletes duplicate entries from a sorted string_list. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'test-string-list.c')
-rw-r--r--test-string-list.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/test-string-list.c b/test-string-list.c
index 702276c1fc..2d6eda707e 100644
--- a/test-string-list.c
+++ b/test-string-list.c
@@ -87,6 +87,16 @@ int main(int argc, char **argv)
return 0;
}
+ if (argc == 3 && !strcmp(argv[1], "remove_duplicates")) {
+ struct string_list list = STRING_LIST_INIT_DUP;
+
+ parse_string_list(&list, argv[2]);
+ string_list_remove_duplicates(&list, 0);
+ write_list_compact(&list);
+ string_list_clear(&list, 0);
+ return 0;
+ }
+
fprintf(stderr, "%s: unknown function name: %s\n", argv[0],
argv[1] ? argv[1] : "(there was none)");
return 1;