* [PATCH] gitweb: ignore lines from diff-tree which do not match the expected format
@ 2006-08-06 15:55 Matthias Lederhofer
2006-08-06 15:59 ` [PATCH] gitweb: Skip nonmatching lines in difftree output, consistently Jakub Narebski
0 siblings, 1 reply; 4+ messages in thread
From: Matthias Lederhofer @ 2006-08-06 15:55 UTC (permalink / raw)
To: git
The sha1 on the first line of git diff-tree -r --root sha1 does not
match the expected format and produces warnings.
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
gitweb/gitweb.perl | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 1f4b0f5..b0da0ea 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1772,7 +1772,9 @@ sub git_tree {
my $alternate = 0;
foreach my $line (@entries) {
#'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
- $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
+ if (!($line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/)) {
+ next;
+ }
my $t_mode = $1;
my $t_type = $2;
my $t_hash = $3;
@@ -2163,7 +2165,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;
--
1.4.1.gfd699
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] gitweb: Skip nonmatching lines in difftree output, consistently
2006-08-06 15:55 [PATCH] gitweb: ignore lines from diff-tree which do not match the expected format Matthias Lederhofer
@ 2006-08-06 15:59 ` Jakub Narebski
2006-08-06 16:01 ` Jakub Narebski
2006-08-06 17:24 ` [PATCH] gitweb: fix commitdiff_plain for root commits Matthias Lederhofer
0 siblings, 2 replies; 4+ messages in thread
From: Jakub Narebski @ 2006-08-06 15:59 UTC (permalink / raw)
To: git; +Cc: Jakub Narebski
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] gitweb: Skip nonmatching lines in difftree output, consistently
2006-08-06 15:59 ` [PATCH] gitweb: Skip nonmatching lines in difftree output, consistently Jakub Narebski
@ 2006-08-06 16:01 ` Jakub Narebski
2006-08-06 17:24 ` [PATCH] gitweb: fix commitdiff_plain for root commits Matthias Lederhofer
1 sibling, 0 replies; 4+ messages in thread
From: Jakub Narebski @ 2006-08-06 16:01 UTC (permalink / raw)
To: git
Jakub Narebski wrote:
> This fixes error for commitdiff on root commit (without parents).
>
> Noticed-by: Matthias Lederhofer (matled)
> Signed-off-by: Jakub Narebski <jnareb@gmail.com>
This is an alternate patch.
--
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] gitweb: fix commitdiff_plain for root commits
2006-08-06 15:59 ` [PATCH] gitweb: Skip nonmatching lines in difftree output, consistently Jakub Narebski
2006-08-06 16:01 ` Jakub Narebski
@ 2006-08-06 17:24 ` Matthias Lederhofer
1 sibling, 0 replies; 4+ messages in thread
From: Matthias Lederhofer @ 2006-08-06 17:24 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
See [PATCH] gitweb: fix commitdiff for root commits from Jakub:
> No checking for empty $hash_parent in git_commitdiff_plain -- we
> rely on gitweb to give correct parameters for commitdiff_plain
> action.
I think we should always check the input and prevent any warnings.
This patch is on top of Jakubs patch, mine just did the if (!($line =~
m/..)) { next; } to be consistent with the other ifs.
---
gitweb/gitweb.perl | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index d9648a0..b3bfc6b 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2200,6 +2200,13 @@ sub git_commitdiff {
sub git_commitdiff_plain {
mkdir($git_temp, 0700);
+ my %co = git_read_commit($hash);
+ if (!%co) {
+ die_error(undef, "Unknown commit object");
+ }
+ if (!defined $hash_parent) {
+ $hash_parent = $co{'parent'} || '--root';
+ }
open my $fd, "-|", $GIT, "diff-tree", '-r', $hash_parent, $hash
or die_error(undef, "Open git-diff-tree failed");
my @difftree = map { chomp; $_ } <$fd>;
@@ -2221,7 +2228,6 @@ sub git_commitdiff_plain {
}
print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\"");
- my %co = git_read_commit($hash);
my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
my $comment = $co{'comment'};
print "From: $co{'author'}\n" .
--
1.4.1.gfd699
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-08-06 17:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-06 15:55 [PATCH] gitweb: ignore lines from diff-tree which do not match the expected format Matthias Lederhofer
2006-08-06 15:59 ` [PATCH] gitweb: Skip nonmatching lines in difftree output, consistently Jakub Narebski
2006-08-06 16:01 ` Jakub Narebski
2006-08-06 17:24 ` [PATCH] gitweb: fix commitdiff_plain for root commits Matthias Lederhofer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).