mirror of
https://github.com/git/git.git
synced 2024-10-30 05:47:53 +01:00
91061c444a
Rewrite the wildmatch() test suite so that each test now tests all combinations of the wildmatch() WM_CASEFOLD and WM_PATHNAME flags. Before this change some test inputs were not tested on e.g. WM_PATHNAME. Now the function is stress tested on all possible inputs, and for each input we declare what the result should be if the mode is case-insensitive, or pathname matching, or case-sensitive or not matching pathnames. Also before this change, nothing was testing case-insensitive non-pathname matching, so I've added that to test-wildmatch.c and made use of it. This yields a rather scary patch, but there are no functional changes here, just more test coverage. Some now-redundant tests were deleted as a result of this change, since they were now duplicating an earlier test. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 lines
722 B
C
23 lines
722 B
C
#include "cache.h"
|
|
|
|
int cmd_main(int argc, const char **argv)
|
|
{
|
|
int i;
|
|
for (i = 2; i < argc; i++) {
|
|
if (argv[i][0] == '/')
|
|
die("Forward slash is not allowed at the beginning of the\n"
|
|
"pattern because Windows does not like it. Use `XXX/' instead.");
|
|
else if (!strncmp(argv[i], "XXX/", 4))
|
|
argv[i] += 3;
|
|
}
|
|
if (!strcmp(argv[1], "wildmatch"))
|
|
return !!wildmatch(argv[3], argv[2], WM_PATHNAME);
|
|
else if (!strcmp(argv[1], "iwildmatch"))
|
|
return !!wildmatch(argv[3], argv[2], WM_PATHNAME | WM_CASEFOLD);
|
|
else if (!strcmp(argv[1], "pathmatch"))
|
|
return !!wildmatch(argv[3], argv[2], 0);
|
|
else if (!strcmp(argv[1], "ipathmatch"))
|
|
return !!wildmatch(argv[3], argv[2], WM_CASEFOLD);
|
|
else
|
|
return 1;
|
|
}
|