{"thread":{"id":"5157","subject":"[PATCH] gitweb: ignore lines from diff-tree which do not match the expected format","startedAt":"2006-08-06T15:55:05Z","lastAt":"2006-08-06T17:24:47Z","messageCount":4,"participants":["Matthias Lederhofer","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"24893","messageId":"20060806155505.GA9548@moooo.ath.cx","threadId":"5157","inReplyTo":null,"subject":"[PATCH] gitweb: ignore lines from diff-tree which do not match the expected format","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-08-06T15:55:05Z","receivedAt":"2006-08-06T15:55:05Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"The sha1 on the first line of git diff-tree -r --root sha1 does not\nmatch the expected format and produces warnings.\n\nSigned-off-by: Matthias Lederhofer <matled@gmx.net>\n---\n gitweb/gitweb.perl |    8 ++++++--\n 1 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 1f4b0f5..b0da0ea 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1772,7 +1772,9 @@ sub git_tree {\n \tmy $alternate = 0;\n \tforeach my $line (@entries) {\n \t\t#'100644\tblob\t0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa\tpanic.c'\n-\t\t$line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\\t(.+)$/;\n+\t\tif (!($line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\\t(.+)$/)) {\n+\t\t\tnext;\n+\t\t}\n \t\tmy $t_mode = $1;\n \t\tmy $t_type = $2;\n \t\tmy $t_hash = $3;\n@@ -2163,7 +2165,9 @@ sub git_commitdiff {\n \tforeach my $line (@difftree) {\n \t\t# ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M      ls-files.c'\n \t\t# ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M      rev-tree.c'\n-\t\t$line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\\t(.*)$/;\n+\t\tif (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\\t(.*)$/)) {\n+\t\t\tnext;\n+\t\t}\n \t\tmy $from_mode = $1;\n \t\tmy $to_mode = $2;\n \t\tmy $from_id = $3;\n-- \n1.4.1.gfd699\n"},{"id":"24894","messageId":"11548799921728-git-send-email-jnareb@gmail.com","threadId":"5157","inReplyTo":"20060806155505.GA9548@moooo.ath.cx","subject":"[PATCH] gitweb: Skip nonmatching lines in difftree output, consistently","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-06T15:59:52Z","receivedAt":"2006-08-06T15:59:52Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"This fixes error for commitdiff on root commit (without parents).\n\nNoticed-by: Matthias Lederhofer (matled)\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\n gitweb/gitweb.perl |   10 +++++++---\n 1 files changed, 7 insertions(+), 3 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex bbea21a..78ef13d 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1983,7 +1983,7 @@ sub git_commit {\n \tforeach my $line (@difftree) {\n \t\t# ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M      ls-files.c'\n \t\t# ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M      rev-tree.c'\n-\t\tif (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\\t(.*)$/)) {\n+\t\tif ($line !~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\\t(.*)$/) {\n \t\t\tnext;\n \t\t}\n \t\tmy $from_mode = $1;\n@@ -2156,7 +2156,9 @@ sub git_commitdiff {\n \tforeach my $line (@difftree) {\n \t\t# ':100644 100644 03b218260e99b78c6df0ed378e59ed9205ccc96d 3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 M      ls-files.c'\n \t\t# ':100644 100644 7f9281985086971d3877aca27704f2aaf9c448ce bc190ebc71bbd923f2b728e505408f5e54bd073a M      rev-tree.c'\n-\t\t$line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\\t(.*)$/;\n+\t\tif ($line !~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\\t(.*)$/) {\n+\t\t\tnext;\n+\t\t}\n \t\tmy $from_mode = $1;\n \t\tmy $to_mode = $2;\n \t\tmy $from_id = $3;\n@@ -2230,7 +2232,9 @@ sub git_commitdiff_plain {\n \tprint \"---\\n\\n\";\n \n \tforeach my $line (@difftree) {\n-\t\t$line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\\t(.*)$/;\n+\t\tif ($line !~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\\t(.*)$/) {\n+\t\t\tnext;\n+\t\t}\n \t\tmy $from_id = $3;\n \t\tmy $to_id = $4;\n \t\tmy $status = $5;\n-- \n1.4.1.1\n"},{"id":"24895","messageId":"eb53p1$1eg$1@sea.gmane.org","threadId":"5157","inReplyTo":"11548799921728-git-send-email-jnareb@gmail.com","subject":"Re: [PATCH] gitweb: Skip nonmatching lines in difftree output, consistently","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-06T16:01:38Z","receivedAt":"2006-08-06T16:01:38Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jakub Narebski wrote:\n\n> This fixes error for commitdiff on root commit (without parents).\n> \n> Noticed-by: Matthias Lederhofer (matled)\n> Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n\nThis is an alternate patch.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"24897","messageId":"20060806172447.GA12085@moooo.ath.cx","threadId":"5157","inReplyTo":"11548799921728-git-send-email-jnareb@gmail.com","subject":"[PATCH] gitweb: fix commitdiff_plain for root commits","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-08-06T17:24:47Z","receivedAt":"2006-08-06T17:24:47Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Signed-off-by: Matthias Lederhofer <matled@gmx.net>\n---\nSee [PATCH] gitweb: fix commitdiff for root commits from Jakub:\n> No checking for empty $hash_parent in git_commitdiff_plain -- we\n> rely on gitweb to give correct parameters for commitdiff_plain\n> action.\nI think we should always check the input and prevent any warnings.\nThis patch is on top of Jakubs patch, mine just did the if (!($line =~\nm/..)) { next; } to be consistent with the other ifs.\n---\n gitweb/gitweb.perl |    8 +++++++-\n 1 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex d9648a0..b3bfc6b 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2200,6 +2200,13 @@ sub git_commitdiff {\n \n sub git_commitdiff_plain {\n \tmkdir($git_temp, 0700);\n+\tmy %co = git_read_commit($hash);\n+\tif (!%co) {\n+\t\tdie_error(undef, \"Unknown commit object\");\n+\t}\n+\tif (!defined $hash_parent) {\n+\t\t$hash_parent = $co{'parent'} || '--root';\n+\t}\n \topen my $fd, \"-|\", $GIT, \"diff-tree\", '-r', $hash_parent, $hash\n \t\tor die_error(undef, \"Open git-diff-tree failed\");\n \tmy @difftree = map { chomp; $_ } <$fd>;\n@@ -2221,7 +2228,6 @@ sub git_commitdiff_plain {\n \t}\n \n \tprint $cgi->header(-type => \"text/plain\", -charset => 'utf-8', '-content-disposition' => \"inline; filename=\\\"git-$hash.patch\\\"\");\n-\tmy %co = git_read_commit($hash);\n \tmy %ad = date_str($co{'author_epoch'}, $co{'author_tz'});\n \tmy $comment = $co{'comment'};\n \tprint \"From: $co{'author'}\\n\" .\n-- \n1.4.1.gfd699\n"}]}