git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] gitweb: Skip nonmatching lines in difftree output, consistently

From
Jakub Narebski <jnareb@gmail.com>
Date
Aug 6, 2006, 15:59 UTC
Message-ID
<11548799921728-git-send-email-jnareb@gmail.com>
In-Reply-To
<20060806155505.GA9548@moooo.ath.cx>
This fixes error for commitdiff on root commit (without parents).
Noticed-by: Matthias Lederhofer (matled)
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index bbea21a..78ef13d 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1983,7 +1983,7 @@ sub git_commit {
 	foreach my $line (@difftree) {
 		# ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M      ls-files.c'
 		# ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M      rev-tree.c'
-		if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) {
+		if ($line !~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/) {
 			next;
 		}
 		my $from_mode = $1;
@@ -2156,7 +2156,9 @@ sub git_commitdiff {
 	foreach my $line (@difftree) {
 		# ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M      ls-files.c'
 		# ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M      rev-tree.c'
-		$line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/;
+		if ($line !~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) {
+			next;
+		}
 		my $from_mode = $1;
 		my $to_mode = $2;
 		my $from_id = $3;
@@ -2230,7 +2232,9 @@ sub git_commitdiff_plain {
 	print "---\n\n";
 
 	foreach my $line (@difftree) {
-		$line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/;
+		if ($line !~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) {
+			next;
+		}
 		my $from_id = $3;
 		my $to_id = $4;
 		my $status = $5;
-- 
1.4.1.1
Previous: Matthias LederhoferNext: Jakub Narebski
Message 2 of 4 in “gitweb: ignore lines from diff-tree which do not match the expected format”
  1. gitweb: ignore lines from diff-tree which do not match the expected formatMatthias Lederhofer, Aug 6, 2006
  2. gitweb: Skip nonmatching lines in difftree output, consistentlyJakub Narebski, Aug 6, 2006
  3. Jakub NarebskiAug 6, 2006
  4. gitweb: fix commitdiff_plain for root commitsMatthias Lederhofer, Aug 6, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.