merge(3p/git): Merge git subtree at v2.29.2
This also bumps the stable nixpkgs to 20.09 as of 2020-11-21, because there is some breakage in the git build related to the netrc credentials helper which someone has taken care of in nixpkgs. The stable channel is not used for anything other than git, so this should be fine. Change-Id: I3575a19dab09e1e9556cf8231d717de9890484fb
This commit is contained in:
		
							parent
							
								
									082c006c04
								
							
						
					
					
						commit
						f4609b896f
					
				
					 1485 changed files with 241535 additions and 109418 deletions
				
			
		
							
								
								
									
										94
									
								
								third_party/git/t/helper/test-regex.c
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										94
									
								
								third_party/git/t/helper/test-regex.c
									
										
									
									
										vendored
									
									
								
							|  | @ -1,5 +1,4 @@ | |||
| #include "test-tool.h" | ||||
| #include "git-compat-util.h" | ||||
| #include "gettext.h" | ||||
| 
 | ||||
| struct reg_flag { | ||||
|  | @ -8,12 +7,13 @@ struct reg_flag { | |||
| }; | ||||
| 
 | ||||
| static struct reg_flag reg_flags[] = { | ||||
| 	{ "EXTENDED",	 REG_EXTENDED	}, | ||||
| 	{ "NEWLINE",	 REG_NEWLINE	}, | ||||
| 	{ "ICASE",	 REG_ICASE	}, | ||||
| 	{ "NOTBOL",	 REG_NOTBOL	}, | ||||
| 	{ "EXTENDED",	REG_EXTENDED	}, | ||||
| 	{ "NEWLINE",	REG_NEWLINE	}, | ||||
| 	{ "ICASE",	REG_ICASE	}, | ||||
| 	{ "NOTBOL",	REG_NOTBOL	}, | ||||
| 	{ "NOTEOL",	REG_NOTEOL	}, | ||||
| #ifdef REG_STARTEND | ||||
| 	{ "STARTEND",	 REG_STARTEND	}, | ||||
| 	{ "STARTEND",	REG_STARTEND	}, | ||||
| #endif | ||||
| 	{ NULL, 0 } | ||||
| }; | ||||
|  | @ -41,36 +41,74 @@ int cmd__regex(int argc, const char **argv) | |||
| { | ||||
| 	const char *pat; | ||||
| 	const char *str; | ||||
| 	int flags = 0; | ||||
| 	int ret, silent = 0, flags = 0; | ||||
| 	regex_t r; | ||||
| 	regmatch_t m[1]; | ||||
| 
 | ||||
| 	if (argc == 2 && !strcmp(argv[1], "--bug")) | ||||
| 		return test_regex_bug(); | ||||
| 	else if (argc < 3) | ||||
| 		usage("test-tool regex --bug\n" | ||||
| 		      "test-tool regex <pattern> <string> [<options>]"); | ||||
| 	char errbuf[64]; | ||||
| 
 | ||||
| 	argv++; | ||||
| 	pat = *argv++; | ||||
| 	str = *argv++; | ||||
| 	while (*argv) { | ||||
| 		struct reg_flag *rf; | ||||
| 		for (rf = reg_flags; rf->name; rf++) | ||||
| 			if (!strcmp(*argv, rf->name)) { | ||||
| 				flags |= rf->flag; | ||||
| 				break; | ||||
| 			} | ||||
| 		if (!rf->name) | ||||
| 			die("do not recognize %s", *argv); | ||||
| 	argc--; | ||||
| 
 | ||||
| 	if (!argc) | ||||
| 		goto usage; | ||||
| 
 | ||||
| 	if (!strcmp(*argv, "--bug")) { | ||||
| 		if (argc == 1) | ||||
| 			return test_regex_bug(); | ||||
| 		else | ||||
| 			goto usage; | ||||
| 	} | ||||
| 	if (!strcmp(*argv, "--silent")) { | ||||
| 		silent = 1; | ||||
| 		argv++; | ||||
| 		argc--; | ||||
| 	} | ||||
| 	if (!argc) | ||||
| 		goto usage; | ||||
| 
 | ||||
| 	pat = *argv++; | ||||
| 	if (argc == 1) | ||||
| 		str = NULL; | ||||
| 	else { | ||||
| 		str = *argv++; | ||||
| 		while (*argv) { | ||||
| 			struct reg_flag *rf; | ||||
| 			for (rf = reg_flags; rf->name; rf++) | ||||
| 				if (!strcmp(*argv, rf->name)) { | ||||
| 					flags |= rf->flag; | ||||
| 					break; | ||||
| 				} | ||||
| 			if (!rf->name) | ||||
| 				die("do not recognize flag %s", *argv); | ||||
| 			argv++; | ||||
| 		} | ||||
| 	} | ||||
| 	git_setup_gettext(); | ||||
| 
 | ||||
| 	if (regcomp(&r, pat, flags)) | ||||
| 		die("failed regcomp() for pattern '%s'", pat); | ||||
| 	if (regexec(&r, str, 1, m, 0)) | ||||
| 		return 1; | ||||
| 	ret = regcomp(&r, pat, flags); | ||||
| 	if (ret) { | ||||
| 		if (silent) | ||||
| 			return ret; | ||||
| 
 | ||||
| 		regerror(ret, &r, errbuf, sizeof(errbuf)); | ||||
| 		die("failed regcomp() for pattern '%s' (%s)", pat, errbuf); | ||||
| 	} | ||||
| 	if (!str) | ||||
| 		return 0; | ||||
| 
 | ||||
| 	ret = regexec(&r, str, 1, m, 0); | ||||
| 	if (ret) { | ||||
| 		if (silent || ret == REG_NOMATCH) | ||||
| 			return ret; | ||||
| 
 | ||||
| 		regerror(ret, &r, errbuf, sizeof(errbuf)); | ||||
| 		die("failed regexec() for subject '%s' (%s)", str, errbuf); | ||||
| 	} | ||||
| 
 | ||||
| 	return 0; | ||||
| usage: | ||||
| 	usage("\ttest-tool regex --bug\n" | ||||
| 	      "\ttest-tool regex [--silent] <pattern>\n" | ||||
| 	      "\ttest-tool regex [--silent] <pattern> <string> [<options>]"); | ||||
| 	return -1; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue