git-shortlog: make common repository prefix configurable with .mailmap
The code had "/pub/scm/linux/kernel/git/" hardcoded which was too specific to the kernel project. With this, a line in the .mailmap file: # repo-abbrev: /pub/scm/linux/kernel/git/ can be used to cause the substring to be abbreviated to /.../ on the title line of the commit message. Signed-off-by: Junio C Hamano <junkio@cox.net>maint
							parent
							
								
									c95044d4f3
								
							
						
					
					
						commit
						7595e2ee6e
					
				|  | @ -9,6 +9,8 @@ | ||||||
| static const char shortlog_usage[] = | static const char shortlog_usage[] = | ||||||
| "git-shortlog [-n] [-s] [<commit-id>... ]"; | "git-shortlog [-n] [-s] [<commit-id>... ]"; | ||||||
|  |  | ||||||
|  | static char *common_repo_prefix; | ||||||
|  |  | ||||||
| static int compare_by_number(const void *a1, const void *a2) | static int compare_by_number(const void *a1, const void *a2) | ||||||
| { | { | ||||||
| 	const struct path_list_item *i1 = a1, *i2 = a2; | 	const struct path_list_item *i1 = a1, *i2 = a2; | ||||||
|  | @ -35,8 +37,26 @@ static int read_mailmap(const char *filename) | ||||||
| 		char *end_of_name, *left_bracket, *right_bracket; | 		char *end_of_name, *left_bracket, *right_bracket; | ||||||
| 		char *name, *email; | 		char *name, *email; | ||||||
| 		int i; | 		int i; | ||||||
| 		if (buffer[0] == '#') | 		if (buffer[0] == '#') { | ||||||
|  | 			static const char abbrev[] = "# repo-abbrev:"; | ||||||
|  | 			int abblen = sizeof(abbrev) - 1; | ||||||
|  | 			int len = strlen(buffer); | ||||||
|  |  | ||||||
|  | 			if (len && buffer[len - 1] == '\n') | ||||||
|  | 				buffer[--len] = 0; | ||||||
|  | 			if (!strncmp(buffer, abbrev, abblen)) { | ||||||
|  | 				char *cp; | ||||||
|  |  | ||||||
|  | 				if (common_repo_prefix) | ||||||
|  | 					free(common_repo_prefix); | ||||||
|  | 				common_repo_prefix = xmalloc(len); | ||||||
|  |  | ||||||
|  | 				for (cp = buffer + abblen; isspace(*cp); cp++) | ||||||
|  | 					; /* nothing */ | ||||||
|  | 				strcpy(common_repo_prefix, cp); | ||||||
|  | 			} | ||||||
| 			continue; | 			continue; | ||||||
|  | 		} | ||||||
| 		if ((left_bracket = strchr(buffer, '<')) == NULL) | 		if ((left_bracket = strchr(buffer, '<')) == NULL) | ||||||
| 			continue; | 			continue; | ||||||
| 		if ((right_bracket = strchr(left_bracket + 1, '>')) == NULL) | 		if ((right_bracket = strchr(left_bracket + 1, '>')) == NULL) | ||||||
|  | @ -87,7 +107,7 @@ static void insert_author_oneline(struct path_list *list, | ||||||
| 		const char *author, int authorlen, | 		const char *author, int authorlen, | ||||||
| 		const char *oneline, int onelinelen) | 		const char *oneline, int onelinelen) | ||||||
| { | { | ||||||
| 	const char *dot3 = "/pub/scm/linux/kernel/git/"; | 	const char *dot3 = common_repo_prefix; | ||||||
| 	char *buffer, *p; | 	char *buffer, *p; | ||||||
| 	struct path_list_item *item; | 	struct path_list_item *item; | ||||||
| 	struct path_list *onelines; | 	struct path_list *onelines; | ||||||
|  |  | ||||||
|  | @ -3,6 +3,8 @@ | ||||||
| # So have an email->real name table to translate the | # So have an email->real name table to translate the | ||||||
| # (hopefully few) missing names | # (hopefully few) missing names | ||||||
| # | # | ||||||
|  | # repo-abbrev: /pub/scm/linux/kernel/git/ | ||||||
|  | # | ||||||
| Adrian Bunk <bunk@stusta.de> | Adrian Bunk <bunk@stusta.de> | ||||||
| Andreas Herrmann <aherrman@de.ibm.com> | Andreas Herrmann <aherrman@de.ibm.com> | ||||||
| Andrew Morton <akpm@osdl.org> | Andrew Morton <akpm@osdl.org> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Junio C Hamano
						Junio C Hamano