commit.c: make find_commit_subject() more robust
Just like the pretty printing machinery, we should simply ignore blank lines at the beginning of the commit messages. This discrepancy was noticed when an early version of the rebase--helper produced commit objects with more than one empty line between the header and the commit message. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
		 Johannes Schindelin
					Johannes Schindelin
				
			
				
					committed by
					
						 Junio C Hamano
						Junio C Hamano
					
				
			
			
				
	
			
			
			 Junio C Hamano
						Junio C Hamano
					
				
			
						parent
						
							7735612244
						
					
				
				
					commit
					4e1b06da25
				
			
							
								
								
									
										2
									
								
								commit.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								commit.c
									
									
									
									
									
								
							| @ -398,7 +398,7 @@ int find_commit_subject(const char *commit_buffer, const char **subject) | |||||||
| 	while (*p && (*p != '\n' || p[1] != '\n')) | 	while (*p && (*p != '\n' || p[1] != '\n')) | ||||||
| 		p++; | 		p++; | ||||||
| 	if (*p) { | 	if (*p) { | ||||||
| 		p += 2; | 		p = skip_blank_lines(p + 2); | ||||||
| 		for (eol = p; *eol && *eol != '\n'; eol++) | 		for (eol = p; *eol && *eol != '\n'; eol++) | ||||||
| 			; /* do nothing */ | 			; /* do nothing */ | ||||||
| 	} else | 	} else | ||||||
|  | |||||||
| @ -87,4 +87,21 @@ test_expect_success 'blame --line-porcelain output' ' | |||||||
| 	test_cmp expect actual | 	test_cmp expect actual | ||||||
| ' | ' | ||||||
|  |  | ||||||
|  | test_expect_success '--porcelain detects first non-blank line as subject' ' | ||||||
|  | 	( | ||||||
|  | 		GIT_INDEX_FILE=.git/tmp-index && | ||||||
|  | 		export GIT_INDEX_FILE && | ||||||
|  | 		echo "This is it" >single-file && | ||||||
|  | 		git add single-file && | ||||||
|  | 		tree=$(git write-tree) && | ||||||
|  | 		commit=$(printf "%s\n%s\n%s\n\n\n  \noneline\n\nbody\n" \ | ||||||
|  | 			"tree $tree" \ | ||||||
|  | 			"author A <a@b.c> 123456789 +0000" \ | ||||||
|  | 			"committer C <c@d.e> 123456789 +0000" | | ||||||
|  | 		git hash-object -w -t commit --stdin) && | ||||||
|  | 		git blame --porcelain $commit -- single-file >output && | ||||||
|  | 		grep "^summary oneline$" output | ||||||
|  | 	) | ||||||
|  | ' | ||||||
|  |  | ||||||
| test_done | test_done | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user