Skip to contentSkip to conversation

gitweb: Remove commit title from comitdiff_plain body

PATCH In review Jakub Narebski 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitweb: Remove commit title from comitdiff_plain body

Remove commit title (first line of commit message) from the "body" of commitdiff_plain view: it is present there already in format-patch like Subject: header.

---

 gitweb/gitweb.perl |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +4 -1
index ec73cb1..6e3ab85 100755
@@ -5122,8 +5122,11 @@ sub git_commitdiff {
 		print "Subject: " . to_utf8($co{'title'}) . "\n";
 
 		print "X-Git-Tag: $tagname\n" if $tagname;
-		print "X-Git-Url: " . $cgi->self_url() . "\n\n";
+		print "X-Git-Url: " . $cgi->self_url() . "\n";
 
+		# remove title, i.e. first line of log
+		shift @{$co{'comment'}};
+		# leading empty lines would separate headers from body
 		foreach my $line (@{$co{'comment'}}) {
 			print to_utf8($line) . "\n";
 		}
#1 lore raw
Quoted 18 lines · Jakub Narebski

Remove commit title (first line of commit message) from the "body" of commitdiff_plain view: it is present there already in format-patch like Subject: header.

---

 gitweb/gitweb.perl |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +0 -0
index ec73cb1..6e3ab85 100755
@@ -5122,8 +5122,11 @@ sub git_commitdiff {
 		print "Subject: " . to_utf8($co{'title'}) . "\n";
 

gitweb/gitweb.perl sub git_commitdiff { · line 5132

Quoted 10 lines
gitweb/gitweb.perl +4 -1
 		print "X-Git-Tag: $tagname\n" if $tagname;
-		print "X-Git-Url: " . $cgi->self_url() . "\n\n";
+		print "X-Git-Url: " . $cgi->self_url() . "\n";
 
+		# remove title, i.e. first line of log
+		shift @{$co{'comment'}};
+		# leading empty lines would separate headers from body
 		foreach my $line (@{$co{'comment'}}) {
 			print to_utf8($line) . "\n";
 		}

You seem to be assuming messages that follow git convention, but is it a good assumption here? E.g. is the first element of @[$co{'comment'}] always known to be non blank? is the second element guaranteed to be empty?