Merge branch 'jk/refspecs-negative'
[git] / t / helper / test-parse-pathspec-file.c
1 #include "test-tool.h"
2 #include "parse-options.h"
3 #include "pathspec.h"
4 #include "gettext.h"
5
6 int cmd__parse_pathspec_file(int argc, const char **argv)
7 {
8         struct pathspec pathspec;
9         const char *pathspec_from_file = NULL;
10         int pathspec_file_nul = 0, i;
11
12         static const char *const usage[] = {
13                 "test-tool parse-pathspec-file --pathspec-from-file [--pathspec-file-nul]",
14                 NULL
15         };
16
17         struct option options[] = {
18                 OPT_PATHSPEC_FROM_FILE(&pathspec_from_file),
19                 OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul),
20                 OPT_END()
21         };
22
23         parse_options(argc, argv, NULL, options, usage, 0);
24
25         parse_pathspec_file(&pathspec, 0, 0, NULL, pathspec_from_file,
26                             pathspec_file_nul);
27
28         for (i = 0; i < pathspec.nr; i++)
29                 printf("%s\n", pathspec.items[i].original);
30
31         clear_pathspec(&pathspec);
32         return 0;
33 }