diff --stat=width[,name-width]: allow custom diffstat output width.
Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
		 Linus Torvalds
					Linus Torvalds
				
			
				
					committed by
					
						 Junio C Hamano
						Junio C Hamano
					
				
			
			
				
	
			
			
			 Junio C Hamano
						Junio C Hamano
					
				
			
						parent
						
							785f743276
						
					
				
				
					commit
					5c5b2ea9ab
				
			| @ -10,8 +10,11 @@ | |||||||
| --patch-with-raw:: | --patch-with-raw:: | ||||||
| 	Synonym for "-p --raw". | 	Synonym for "-p --raw". | ||||||
|  |  | ||||||
| --stat:: | --stat[=width[,name-width]]:: | ||||||
| 	Generate a diffstat. | 	Generate a diffstat.  You can override the default | ||||||
|  | 	output width for 80-column terminal by "--stat=width". | ||||||
|  | 	The width of the filename part can be controlled by | ||||||
|  | 	giving another width to it separated by a comma. | ||||||
|  |  | ||||||
| --summary:: | --summary:: | ||||||
| 	Output a condensed summary of extended header information | 	Output a condensed summary of extended header information | ||||||
|  | |||||||
							
								
								
									
										33
									
								
								diff.c
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								diff.c
									
									
									
									
									
								
							| @ -1735,15 +1735,32 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac) | |||||||
| 	else if (!strcmp(arg, "--patch-with-raw")) { | 	else if (!strcmp(arg, "--patch-with-raw")) { | ||||||
| 		options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW; | 		options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW; | ||||||
| 	} | 	} | ||||||
| 	else if (!strcmp(arg, "--stat")) | 	else if (!strncmp(arg, "--stat", 6)) { | ||||||
| 		options->output_format |= DIFF_FORMAT_DIFFSTAT; | 		char *end; | ||||||
| 	else if (!strncmp(arg, "--stat-width=", 13)) { | 		int width = options->stat_width; | ||||||
| 		options->stat_width = strtoul(arg + 13, NULL, 10); | 		int name_width = options->stat_name_width; | ||||||
| 		options->output_format |= DIFF_FORMAT_DIFFSTAT; | 		arg += 6; | ||||||
| 	} | 		end = (char *)arg; | ||||||
| 	else if (!strncmp(arg, "--stat-name-width=", 18)) { |  | ||||||
| 		options->stat_name_width = strtoul(arg + 18, NULL, 10); | 		switch (*arg) { | ||||||
|  | 		case '-': | ||||||
|  | 			if (!strncmp(arg, "-width=", 7)) | ||||||
|  | 				width = strtoul(arg + 7, &end, 10); | ||||||
|  | 			else if (!strncmp(arg, "-name-width=", 12)) | ||||||
|  | 				name_width = strtoul(arg + 12, &end, 10); | ||||||
|  | 			break; | ||||||
|  | 		case '=': | ||||||
|  | 			width = strtoul(arg+1, &end, 10); | ||||||
|  | 			if (*end == ',') | ||||||
|  | 				name_width = strtoul(end+1, &end, 10); | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		/* Important! This checks all the error cases! */ | ||||||
|  | 		if (*end) | ||||||
|  | 			return 0; | ||||||
| 		options->output_format |= DIFF_FORMAT_DIFFSTAT; | 		options->output_format |= DIFF_FORMAT_DIFFSTAT; | ||||||
|  | 		options->stat_name_width = name_width; | ||||||
|  | 		options->stat_width = width; | ||||||
| 	} | 	} | ||||||
| 	else if (!strcmp(arg, "--check")) | 	else if (!strcmp(arg, "--check")) | ||||||
| 		options->output_format |= DIFF_FORMAT_CHECKDIFF; | 		options->output_format |= DIFF_FORMAT_CHECKDIFF; | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user