From 161332a521fe10c41979bcd493d95e2ac562b7ff Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 19:49:46 +0200 Subject: first working version --- gitweb.pl | 320 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 320 insertions(+) create mode 100755 gitweb.pl diff --git a/gitweb.pl b/gitweb.pl new file mode 100755 index 0000000000..ab4623db35 --- /dev/null +++ b/gitweb.pl @@ -0,0 +1,320 @@ +#!/usr/bin/perl + +# This file is licensed under the GPL v2, or a later version +# (C) 2005, Kay Sievers +# (C) 2005, Christian Gierke + +use strict; +use warnings; +use CGI qw(:standard :escapeHTML); +use CGI::Carp qw(fatalsToBrowser); + +my $cgi = new CGI; +my $gitbin = "/home/kay/bin"; +my $gitroot = "/home/kay/public_html"; +my $gittmp = "/tmp"; +my $myself = $cgi->url(-relative => 1); + +my $project = $cgi->param("project") || ""; +my $action = $cgi->param("action") || ""; +my $hash = $cgi->param("hash") || ""; +my $parent = $cgi->param("parent") || ""; +my $view_back = $cgi->param("view_back") || 60*60*24*2; +my $projectroot = "$gitroot/$project"; +$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/.git/objects"; + +$hash =~ s/[^0-9a-fA-F]//g; +$parent =~ s/[^0-9a-fA-F]//g; +$project =~ s/[^0-9a-zA-Z\-\._]//g; + +sub header { + print $cgi->header(-type => 'text/html; charset: utf-8'); +print < + + + GIT + + + +EOF + if ($project ne "") { + print "
\n"; + print "
" . $project . "
\n"; + print "
\n"; + print $cgi->a({-href => "$myself?project=$project&action=show_tree"}, "Browse Project") . "
\n"; + print "Show Log "; + print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24}, "day") . "\n"; + print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24*7}, "week") . "\n"; + print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24*30}, "month") . "\n"; + print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24*365}, "year") . "
\n"; + print "
\n"; + print "

\n"; + } +} + +sub footer { + print "
"; + print $cgi->end_html(); +} + +if ($project eq "") { + open my $fd, "-|", "ls", "-1", $gitroot; + my (@path) = map { chomp; $_ } <$fd>; + close $fd; + header(); + print "Projects:

\n"; + foreach my $line (@path) { + if (-e "$gitroot/$line/.git/HEAD") { + print $cgi->a({-href => "$myself?project=$line"}, $line) . "
\n"; + } + } + footer(); + exit; +} + +if ($action eq "") { + print $cgi->redirect("$myself?project=$project&action=show_log&view_back=$view_back"); + exit; +} + +if ($action eq "show_file") { + header(); + print "
\n";
+	open my $fd, "-|", "$gitbin/cat-file", "blob", $hash;
+	my $nr;
+	while (my $line = <$fd>) {
+		$nr++;
+		print "$nr\t" . escapeHTML($line);;
+	}
+	close $fd;
+	print "
\n"; + footer(); +} elsif ($action eq "show_tree") { + if ($hash eq "") { + open my $fd, "$projectroot/.git/HEAD"; + my $head = <$fd>; + chomp $head; + close $fd; + + open $fd, "-|", "$gitbin/cat-file", "commit", $head; + my $tree = <$fd>; + chomp $tree; + $tree =~ s/tree //; + close $fd; + $hash = $tree; + } + open my $fd, "-|", "$gitbin/ls-tree", $hash; + my (@entries) = map { chomp; $_ } <$fd>; + close $fd; + header(); + print "
\n";
+	foreach my $line (@entries) {
+		$line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
+		my $t_type = $2;
+		my $t_hash = $3;
+		my $t_name = $4;
+		if ($t_type eq "blob") {
+			print "FILE\t" . $cgi->a({-href => "$myself?project=$project&action=show_file&hash=$3"}, $4) . "\n";
+		} elsif ($t_type eq "tree") {
+			print "DIR\t" . $cgi->a({-href => "$myself?project=$project&action=show_tree&hash=$3"}, $4) . "\n";
+		}
+	}
+	print "
\n"; + footer(); +} elsif ($action eq "show_log") { + open my $fd, "$projectroot/.git/HEAD"; + my $head = <$fd>; + chomp $head; + close $fd; + open my $fd, "-|", "$gitbin/rev-tree", $head; + my (@revtree) = map { chomp; $_ } <$fd>; + close $fd; + header(); + print "\n"; + foreach my $rev (reverse sort @revtree) { + if (!($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/)) { + last; + } + my $time = $1; + my $commit = $2; + my $parent = $3; + my @parents; + my $author; + my $author_name; + my $author_time; + my $author_timezone; + my $committer; + my $committer_time; + my $committer_timezone; + my $tree; + my $comment; + my $shortlog; + open my $fd, "-|", "$gitbin/cat-file", "commit", $commit; + while (my $line = <$fd>) { + chomp($line); + if ($line eq "") { + last; + } + if ($line =~ m/^tree (.*)$/) { + $tree = $1; + } elsif ($line =~ m/^parent (.*)$/) { + push @parents, $1; + } elsif ($line =~ m/^committer (.*>) ([0-9]+) (.*)$/) { + $committer = $1; + $committer_time = $2; + $committer_timezone = $3; + } elsif ($line =~ m/^author (.*>) ([0-9]+) (.*)$/) { + $author = $1; + $author_time = $2; + $author_timezone = $3; + $author =~ m/^(.*) ; + $shortlog = escapeHTML($shortlog); + $comment = $shortlog . "
"; + while (my $line = <$fd>) { + chomp($line); + $comment .= escapeHTML($line) . "
\n"; + } + close $fd; + my $age = time-$author_time; + if ($view_back > 0 && $age > $view_back) { + last; + } + + my $age_string; + if ($age > 60*60*24*365*2) { + $age_string = int $age/60/60/24/365; + $age_string .= " years ago"; + } elsif ($age > 60*60*24*365/12*2) { + $age_string = int $age/60/60/24/365/12; + $age_string .= " months ago"; + } elsif ($age > 60*60*24*7*2) { + $age_string = int $age/60/60/24/7; + $age_string .= " weeks ago"; + } elsif ($age > 60*60*24*2) { + $age_string = int $age/60/60/24; + $age_string .= " days ago"; + } elsif ($age > 60*60*2) { + $age_string = int $age/60/60; + $age_string .= " hours ago"; + } elsif ($age > 60*2) { + $age_string = int $age/60; + $age_string .= " minutes ago"; + } + print "\n"; + print "\n"; + print ""; + print "\n"; + print "\n"; + print "\n"; + print ""; + print "\n"; + print "\n"; + print "\n"; + print ""; + print "\n"; + } + print "
" . $age_string . "" . $shortlog . "
\n"; + print "author    " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]
\n"; + print "committer " . escapeHTML($committer) . " [" . gmtime($committer_time) . " " . $committer_timezone . "]
\n"; + print "commit    $commit
\n"; + print "tree      $tree
\n"; + foreach my $par (@parents) { + print "parent    $par
\n"; + } + print "
\n"; + print "$comment

\n"; + print "
\n"; + footer(); +} elsif ($action eq "show_cset") { + open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; + my $tree = <$fd>; + chomp $tree; + $tree =~ s/tree //; + close $fd; + + open my $fd, "-|", "$gitbin/cat-file", "commit", $parent; + my $parent_tree = <$fd>; + chomp $parent_tree; + $parent_tree =~ s/tree //; + close $fd; + + open my $fd, "-|", "$gitbin/diff-tree", "-r", $parent_tree, $tree; + my (@difftree) = map { chomp; $_ } <$fd>; + close $fd; + + header(); + print "
\n";
+	foreach my $line (@difftree) {
+		$line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
+		my $op = $1;
+		my $mode = $2;
+		my $type = $3;
+		my $id = $4;
+		my $file = $5;
+		if ($type eq "blob") {
+			if ($op eq "+") {
+				print "NEW\t" . $cgi->a({-href => "$myself?project=$project&action=show_file&hash=$id"}, $file) . "\n";
+			} elsif ($op eq "-") {
+				print "DEL\t" . $cgi->a({-href => "$myself?project=$project&action=show_file&hash=$id"}, $file) . "\n";
+			} elsif ($op eq "*") {
+				$id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
+				my $old = $1;
+				my $new = $2;
+				print "DIFF\t" . $cgi->a({-href => "$myself?project=$project&action=show_diff&hash=$old&parent=$new"}, $file) . "\n";
+			}
+		}
+	}
+	print "
\n"; + footer(); +} elsif ($action eq "show_diff") { + open my $fd2, "> $gittmp/$hash"; + open my $fd, "-|", "$gitbin/cat-file", "blob", $hash; + while (my $line = <$fd>) { + print $fd2 $line; + } + close $fd2; + close $fd; + + open my $fd2, "> $gittmp/$parent"; + open my $fd, "-|", "$gitbin/cat-file", "blob", $parent; + while (my $line = <$fd>) { + print $fd2 $line; + } + close $fd2; + close $fd; + + header(); + print "
\n";
+	open my $fd, "-|", "/usr/bin/diff", "-L", "$hash", "-L", "$parent", "-u", "-p", "$gittmp/$hash", "$gittmp/$parent";
+	while (my $line = <$fd>) {
+		print escapeHTML($line);
+	}
+	close $fd;
+	unlink("$gittmp/$hash");
+	unlink("$gittmp/$parent");
+	print "
\n"; + footer(); +} else { + header(); + print "unknown action\n"; + footer(); +} -- cgit 1.2.3-korg From 4c02e3c56f95858f9e75fd102dbdf311431a6d10 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 19:52:52 +0200 Subject: v000 --- gitweb.pl | 253 ++++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 179 insertions(+), 74 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index ab4623db35..e1ca3f8c6b 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -19,7 +19,7 @@ my $project = $cgi->param("project") || ""; my $action = $cgi->param("action") || ""; my $hash = $cgi->param("hash") || ""; my $parent = $cgi->param("parent") || ""; -my $view_back = $cgi->param("view_back") || 60*60*24*2; +my $view_back = $cgi->param("view_back") || 60*60*24; my $projectroot = "$gitroot/$project"; $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/.git/objects"; @@ -27,7 +27,7 @@ $hash =~ s/[^0-9a-fA-F]//g; $parent =~ s/[^0-9a-fA-F]//g; $project =~ s/[^0-9a-zA-Z\-\._]//g; -sub header { +sub git_header { print $cgi->header(-type => 'text/html; charset: utf-8'); print < @@ -36,64 +36,127 @@ print <GIT EOF + print "
\n"; + print "
"; + print "\"git\""; + print $cgi->a({-href => "$myself"}, "projects"); if ($project ne "") { - print "
\n"; - print "
" . $project . "
\n"; - print "
\n"; - print $cgi->a({-href => "$myself?project=$project&action=show_tree"}, "Browse Project") . "
\n"; - print "Show Log "; - print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24}, "day") . "\n"; - print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24*7}, "week") . "\n"; - print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24*30}, "month") . "\n"; - print $cgi->a({-href => "$myself?project=$project&action=show_log&view_back=" . 60*60*24*365}, "year") . "
\n"; - print "
\n"; - print "

\n"; + print " / " . $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24}, $project); } + if ($action ne "") { + print " / " . $action . " " . $hash; + } + print "
\n"; } -sub footer { +sub git_footer { print "
"; print $cgi->end_html(); } +sub git_diff { + my $old_name = shift; + my $new_name = shift; + my $old = shift; + my $new = shift; + + my $label_old = "/dev/null"; + my $label_new = "/dev/null"; + my $tmp_old = "/dev/null"; + my $tmp_new = "/dev/null"; + + if ($old ne "") { + open my $fd2, "> $gittmp/$old"; + open my $fd, "-|", "$gitbin/cat-file", "blob", $old; + while (my $line = <$fd>) { + print $fd2 $line; + } + close $fd2; + close $fd; + $tmp_old = "$gittmp/$old"; + $label_old = "a/$old_name"; + } + + if ($new ne "") { + open my $fd2, "> $gittmp/$new"; + open my $fd, "-|", "$gitbin/cat-file", "blob", $new; + while (my $line = <$fd>) { + print $fd2 $line; + } + close $fd2; + close $fd; + $tmp_new = "$gittmp/$new"; + $label_new = "b/$new_name"; + } + + open my $fd, "-|", "/usr/bin/diff", "-L", $label_old, "-L", $label_new, "-u", "-p", $tmp_old, $tmp_new; + while (my $line = <$fd>) { + my $char = substr($line,0,1); + print '
' if $char eq '+'; + print '
' if $char eq '-'; + print '
' if $char eq '@'; + print escapeHTML($line); + print '
' if $char eq '+' or $char eq '-' or $char eq '@'; + } + close $fd; + #unlink("$gittmp/$new"); + #unlink("$gittmp/$old"); +} + if ($project eq "") { open my $fd, "-|", "ls", "-1", $gitroot; my (@path) = map { chomp; $_ } <$fd>; close $fd; - header(); - print "Projects:

\n"; + git_header(); + print "

\n"; foreach my $line (@path) { if (-e "$gitroot/$line/.git/HEAD") { print $cgi->a({-href => "$myself?project=$line"}, $line) . "
\n"; } } - footer(); + print "
"; + git_footer(); exit; } if ($action eq "") { - print $cgi->redirect("$myself?project=$project&action=show_log&view_back=$view_back"); + print $cgi->redirect("$myself?project=$project&action=log&view_back=$view_back"); exit; } -if ($action eq "show_file") { - header(); +if ($action eq "file") { + git_header(); + print "

\n"; print "
\n";
 	open my $fd, "-|", "$gitbin/cat-file", "blob", $hash;
 	my $nr;
@@ -103,14 +166,14 @@ if ($action eq "show_file") {
 	}
 	close $fd;
 	print "
\n"; - footer(); -} elsif ($action eq "show_tree") { + print "
"; + git_footer(); +} elsif ($action eq "tree") { if ($hash eq "") { open my $fd, "$projectroot/.git/HEAD"; my $head = <$fd>; chomp $head; close $fd; - open $fd, "-|", "$gitbin/cat-file", "commit", $head; my $tree = <$fd>; chomp $tree; @@ -121,7 +184,8 @@ if ($action eq "show_file") { open my $fd, "-|", "$gitbin/ls-tree", $hash; my (@entries) = map { chomp; $_ } <$fd>; close $fd; - header(); + git_header(); + print "

\n"; print "
\n";
 	foreach my $line (@entries) {
 		$line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
@@ -129,22 +193,32 @@ if ($action eq "show_file") {
 		my $t_hash = $3;
 		my $t_name = $4;
 		if ($t_type eq "blob") {
-			print "FILE\t" . $cgi->a({-href => "$myself?project=$project&action=show_file&hash=$3"}, $4) . "\n";
+			print "FILE\t" . $cgi->a({-href => "$myself?project=$project&action=file&hash=$3"}, $4) . "\n";
 		} elsif ($t_type eq "tree") {
-			print "DIR\t" . $cgi->a({-href => "$myself?project=$project&action=show_tree&hash=$3"}, $4) . "\n";
+			print "DIR\t" . $cgi->a({-href => "$myself?project=$project&action=tree&hash=$3"}, $4) . "\n";
 		}
 	}
 	print "
\n"; - footer(); -} elsif ($action eq "show_log") { + print "
"; + git_footer(); +} elsif ($action eq "log" || $action eq "show_log" ) { open my $fd, "$projectroot/.git/HEAD"; my $head = <$fd>; chomp $head; close $fd; - open my $fd, "-|", "$gitbin/rev-tree", $head; + open $fd, "-|", "$gitbin/rev-tree", $head; my (@revtree) = map { chomp; $_ } <$fd>; close $fd; - header(); + git_header(); + print "
\n"; + print "view "; + print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24}, "last day") . " | "; + print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24*7}, "week") . " | "; + print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24*30}, "month") . " | "; + print $cgi->a({-href => "$myself?project=$project&action=log&view_back=" . 60*60*24*365}, "year") . " | "; + print $cgi->a({-href => "$myself?project=$project&action=log&view_back=-1"}, "all") . "
\n"; + print "

\n"; + print "
\n"; print "\n"; foreach my $rev (reverse sort @revtree) { if (!($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/)) { @@ -221,15 +295,19 @@ if ($action eq "show_file") { } print "\n"; print "\n"; - print ""; + print ""; print "\n"; print "\n"; - print "\n"; + print "\n"; print "\n"; } print "
" . $age_string . "" . $shortlog . "" . $shortlog . "
"; + print $cgi->a({-href => "$myself?project=$project&action=diffs&hash=$commit&parent=$parent"}, "view diff") . "
\n"; + print $cgi->a({-href => "$myself?project=$project&action=commit&hash=$commit&parent=$parent"}, "view commit") . "
\n"; + print $cgi->a({-href => "$myself?project=$project&action=tree&hash=$tree"}, "view tree") . "
\n"; + print "
\n"; print "author    " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]
\n"; print "committer " . escapeHTML($committer) . " [" . gmtime($committer_time) . " " . $committer_timezone . "]
\n"; - print "commit    $commit
\n"; - print "tree      $tree
\n"; + print "commit    $commit
\n"; + print "tree      $tree
\n"; foreach my $par (@parents) { print "parent    $par
\n"; } @@ -243,25 +321,26 @@ if ($action eq "show_file") { print "
\n"; - footer(); -} elsif ($action eq "show_cset") { + git_footer(); +} elsif ($action eq "commit") { open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; my $tree = <$fd>; chomp $tree; $tree =~ s/tree //; close $fd; - open my $fd, "-|", "$gitbin/cat-file", "commit", $parent; + open $fd, "-|", "$gitbin/cat-file", "commit", $parent; my $parent_tree = <$fd>; chomp $parent_tree; $parent_tree =~ s/tree //; close $fd; - open my $fd, "-|", "$gitbin/diff-tree", "-r", $parent_tree, $tree; + open $fd, "-|", "$gitbin/diff-tree", "-r", $parent_tree, $tree; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; - header(); + git_header(); + print "

\n"; print "
\n";
 	foreach my $line (@difftree) {
 		$line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
@@ -272,49 +351,75 @@ if ($action eq "show_file") {
 		my $file = $5;
 		if ($type eq "blob") {
 			if ($op eq "+") {
-				print "NEW\t" . $cgi->a({-href => "$myself?project=$project&action=show_file&hash=$id"}, $file) . "\n";
+				print "NEW\t" . $cgi->a({-href => "$myself?project=$project&action=file&hash=$id"}, $file) . "\n";
 			} elsif ($op eq "-") {
-				print "DEL\t" . $cgi->a({-href => "$myself?project=$project&action=show_file&hash=$id"}, $file) . "\n";
+				print "DEL\t" . $cgi->a({-href => "$myself?project=$project&action=file&hash=$id"}, $file) . "\n";
 			} elsif ($op eq "*") {
 				$id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
 				my $old = $1;
 				my $new = $2;
-				print "DIFF\t" . $cgi->a({-href => "$myself?project=$project&action=show_diff&hash=$old&parent=$new"}, $file) . "\n";
+				print "DIFF\t" . $cgi->a({-href => "$myself?project=$project&action=diff&hash=$old&parent=$new"}, $file) . "\n";
 			}
 		}
 	}
 	print "
\n"; - footer(); -} elsif ($action eq "show_diff") { - open my $fd2, "> $gittmp/$hash"; - open my $fd, "-|", "$gitbin/cat-file", "blob", $hash; - while (my $line = <$fd>) { - print $fd2 $line; - } - close $fd2; + print "
"; + git_footer(); +} elsif ($action eq "diff") { + git_header(); + print "

\n"; + print "
\n";
+	git_diff($hash, $parent, $hash, $parent);
+	print "
\n"; + print "
"; + git_footer(); +} elsif ($action eq "diffs") { + open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; + my $tree = <$fd>; + chomp $tree; + $tree =~ s/tree //; close $fd; - open my $fd2, "> $gittmp/$parent"; - open my $fd, "-|", "$gitbin/cat-file", "blob", $parent; - while (my $line = <$fd>) { - print $fd2 $line; - } - close $fd2; + open $fd, "-|", "$gitbin/cat-file", "commit", $parent; + my $parent_tree = <$fd>; + chomp $parent_tree; + $parent_tree =~ s/tree //; + close $fd; + + open $fd, "-|", "$gitbin/diff-tree", "-r", $parent_tree, $tree; + my (@difftree) = map { chomp; $_ } <$fd>; close $fd; - header(); + git_header(); + print "

\n"; print "
\n";
-	open my $fd, "-|", "/usr/bin/diff", "-L", "$hash", "-L", "$parent", "-u", "-p", "$gittmp/$hash", "$gittmp/$parent";
-	while (my $line = <$fd>) {
-		print escapeHTML($line);
+	foreach my $line (@difftree) {
+		$line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
+		my $op = $1;
+		my $mode = $2;
+		my $type = $3;
+		my $id = $4;
+		my $file = $5;
+		if ($type eq "blob") {
+			if ($op eq "+") {
+				git_diff("", $file, "", $id);
+			} elsif ($op eq "-") {
+				git_diff($file, "", $id, "");
+			} elsif ($op eq "*") {
+				$id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
+				git_diff($file, $file, $1, $2);
+			}
+		}
+		print "
\n"; } - close $fd; - unlink("$gittmp/$hash"); - unlink("$gittmp/$parent"); print "
\n"; - footer(); + print "
"; + print "
"; + git_footer(); } else { - header(); + git_header(); + print "

\n"; print "unknown action\n"; - footer(); + print "
"; + git_footer(); } -- cgit 1.2.3-korg From ecb378f5b57b3b8eaa3cbccfb81f29bab8f4a1b7 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 19:53:54 +0200 Subject: v000 --- gitweb.pl | 140 ++++++++++++++++++++++++++++---------------------------------- 1 file changed, 63 insertions(+), 77 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index e1ca3f8c6b..fe44b188ca 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -10,7 +10,7 @@ use CGI qw(:standard :escapeHTML); use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $gitbin = "/home/kay/bin"; +my $gitbin = "/home/kay/bin/git"; my $gitroot = "/home/kay/public_html"; my $gittmp = "/tmp"; my $myself = $cgi->url(-relative => 1); @@ -33,7 +33,7 @@ print < - GIT + git - $project $action @@ -213,20 +218,21 @@ if ($project eq "") { my (@path) = grep(!/^\./, readdir($fd)); closedir($fd); git_header(); - print "

\n"; + print "
\n"; + print "

\n"; foreach my $line (@path) { if (-e "$projectroot/$defaultprojects/$line/.git/HEAD") { print $cgi->a({-href => "$myself/$defaultprojects/$line/log"}, $line) . "
\n"; } } - print "
"; + print "

"; git_footer(); exit; } if ($action eq "blob") { git_header(); - print "

\n"; + print "

\n"; print "
\n";
 	open my $fd, "-|", "$gitbin/cat-file", "blob", $hash;
 	my $nr;
@@ -236,7 +242,7 @@ if ($action eq "blob") {
 	}
 	close $fd;
 	print "
\n"; - print "
"; + print "
"; git_footer(); } elsif ($action eq "tree") { if ($hash eq "") { @@ -250,7 +256,7 @@ if ($action eq "blob") { my (@entries) = map { chomp; $_ } <$fd>; close $fd; git_header(); - print "

\n"; + print "

\n"; print "
\n";
 	foreach my $line (@entries) {
 		#'100644	blob	0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa	panic.c'
@@ -265,9 +271,9 @@ if ($action eq "blob") {
 		}
 	}
 	print "
\n"; - print "
"; + print "
"; git_footer(); -} elsif ($action eq "log") { +} elsif ($action eq "log" || $action eq "rss") { open my $fd, "$projectroot/$project/.git/HEAD"; my $head = <$fd>; chomp $head; @@ -275,20 +281,33 @@ if ($action eq "blob") { open $fd, "-|", "$gitbin/rev-tree", $head; my (@revtree) = reverse sort map { chomp; $_ } <$fd>; close $fd; - git_header(); - print "
\n"; - print "view "; - print $cgi->a({-href => "$myself/$project/log"}, "last day") . " | "; - print $cgi->a({-href => "$myself/$project/log/7"}, "week") . " | "; - print $cgi->a({-href => "$myself/$project/log/31"}, "month") . " | "; - print $cgi->a({-href => "$myself/$project/log/365"}, "year") . " | "; - print $cgi->a({-href => "$myself/$project/log/0"}, "all") . "
\n"; - print "

\n"; - print "
\n"; - print "\n"; + + if ($action eq "log") { + git_header(); + print "
\n"; + print "view "; + print $cgi->a({-href => "$myself/$project/log"}, "last day") . " | "; + print $cgi->a({-href => "$myself/$project/log/7"}, "week") . " | "; + print $cgi->a({-href => "$myself/$project/log/31"}, "month") . " | "; + print $cgi->a({-href => "$myself/$project/log/365"}, "year") . " | "; + print $cgi->a({-href => "$myself/$project/log/0"}, "all") . "
\n"; + print "

\n"; + print "
\n"; + print "
\n"; + } elsif ($action eq "rss") { + print $cgi->header(-type => 'text/xml; charset: utf-8'); + print "\n". + "\n"; + print "\n"; + print "$project\n". + " " . $cgi->url() . "/$project/log\n". + "$project log\n". + "en\n"; + } + for (my $i = 0; $i <= $#revtree; $i++) { my $rev = $revtree[$i]; - #foreach my $rev (@revtree) { + #foreach my $rev (@revtree) { # '1114106118 755e3010ee10dadf42a8a80770e1b115fb038d9b:1 2af17b4854036a1c2ec6c101d93c8dd1ed80d24e:1' last if !($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/); my $time = $1; @@ -319,6 +338,7 @@ if ($action eq "blob") { } } $shortlog = <$fd>; + chomp($shortlog); $shortlog = escapeHTML($shortlog); $comment = $shortlog . "
"; while (my $line = <$fd>) { @@ -352,43 +372,55 @@ if ($action eq "blob") { $age_string = int $age/60; $age_string .= " minutes ago"; } - if ($view_back > 0 && $age > $view_back*60*60*24) { - if ($i == 0) { + if ($action eq "log") { + if ($view_back > 0 && $age > $view_back*60*60*24) { + if ($i == 0) { + print "
\n"; + print "\n"; + print "\n"; + } + last; + } print "\n"; - print "\n"; + print "\n"; + print ""; print "\n"; + print "\n"; + print "\n"; + print ""; + print "\n"; + print "\n"; + print "\n"; + print ""; + print "\n"; + } elsif ($action eq "rss") { + if ($i < 12) { + print "\n\t$age_string: $shortlog\n"; + print "\t " . $cgi->url() . "/$project/commit/$commit\n"; + print "\n"; } - last; - } - print "\n"; - print "\n"; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ""; - print "\n"; } - print "
Last change $age_string.
Last change $age_string. " . $age_string . "" . $cgi->a({-href => "$myself/$project/commit/$commit"}, $shortlog) . "
"; + print $cgi->a({-href => "$myself/$project/commitdiff/$commit"}, "view diff") . "
\n"; + print $cgi->a({-href => "$myself/$project/commit/$commit"}, "view commit") . "
\n"; + print $cgi->a({-href => "$myself/$project/tree/$tree"}, "view tree") . "
\n"; + print "
\n"; + print "author    " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]
\n"; + print "committer " . escapeHTML($committer) . " [" . gmtime($committer_time) . " " . $committer_timezone . "]
\n"; + print "commit    $commit
\n"; + print "tree      $tree
\n"; + foreach my $par (@parents) { + print "parent    $par
\n"; + } + print "
\n"; + print "$comment

\n"; + print "
" . $age_string . "" . $cgi->a({-href => "$myself/$project/commit/$commit"}, $shortlog) . "
"; - print $cgi->a({-href => "$myself/$project/treediff/$commit"}, "view diff") . "
\n"; - print $cgi->a({-href => "$myself/$project/commit/$commit"}, "view commit") . "
\n"; - print $cgi->a({-href => "$myself/$project/tree/$tree"}, "view tree") . "
\n"; - print "
\n"; - print "author    " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]
\n"; - print "committer " . escapeHTML($committer) . " [" . gmtime($committer_time) . " " . $committer_timezone . "]
\n"; - print "commit    $commit
\n"; - print "tree      $tree
\n"; - foreach my $par (@parents) { - print "parent    $par
\n"; } - print "
\n"; - print "$comment

\n"; - print "
\n"; - git_footer(); + if ($action eq "log") { + print "\n"; + git_footer(); + } elsif ($action eq "rss") { + print ""; + } } elsif ($action eq "commit") { my $parent = ""; open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; @@ -408,8 +440,8 @@ if ($action eq "blob") { close $fd; git_header(); - print "
\n"; - print "view " . $cgi->a({-href => "$myself/$project/treediff/$hash"}, "diff") . "


\n"; + print "
\n"; + print "view " . $cgi->a({-href => "$myself/$project/commitdiff/$hash"}, "diff") . "


\n"; print "
$shortlog
\n"; print "
\n";
 	foreach my $line (@difftree) {
@@ -430,22 +462,22 @@ if ($action eq "blob") {
 				$id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
 				my $old = $1;
 				my $new = $2;
-				print "changed\t" . $cgi->a({-href => "$myself/$project/diff/$old/$new"}, $file) . "\n";
+				print "changed\t" . $cgi->a({-href => "$myself/$project/blobdiff/$old/$new"}, $file) . "\n";
 			}
 		}
 	}
 	print "
\n"; - print "
"; + print "
"; git_footer(); -} elsif ($action eq "diff") { +} elsif ($action eq "blobdiff") { git_header(); - print "

\n"; + print "

\n"; print "
\n";
 	git_diff($hash, $hash_parent, $hash, $hash_parent);
 	print "
\n"; - print "
"; + print "
"; git_footer(); -} elsif ($action eq "treediff") { +} elsif ($action eq "commitdiff") { my $parent = ""; open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; while (my $line = <$fd>) { @@ -464,8 +496,8 @@ if ($action eq "blob") { close $fd; git_header(); - print "
\n"; - print "view " . $cgi->a({-href => "$myself/$project/commit/$hash"}, "commit") . "


\n"; + print "
\n"; + print "view " . $cgi->a({-href => "$myself/$project/commit/$hash"}, "commit") . "


\n"; print "
$shortlog
\n"; print "
\n";
 	foreach my $line (@difftree) {
@@ -488,12 +520,6 @@ if ($action eq "blob") {
 		}
 	}
 	print "
\n"; - print "
"; - git_footer(); -} else { - git_header(); - print "

\n"; - print "unknown action\n"; - print "
"; + print "
"; git_footer(); } -- cgit 1.2.3-korg From 12a88f2f031d10a1a7b46a913e629e90531b08b6 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:02:47 +0200 Subject: v021 --- gitweb.pl | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index dd487c3d88..dd5fbdc2a8 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -90,7 +90,7 @@ $project =~ s#\/\.+##g; $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/.git/objects"; -sub git_header { +sub git_header_html { print $cgi->header(-type => 'text/html; charset: utf-8'); print < @@ -144,11 +144,19 @@ EOF print "
\n"; } -sub git_footer { +sub git_footer_html { print "
"; print $cgi->end_html(); } +sub git_head { + open my $fd, "$projectroot/$project/.git/HEAD"; + my $head = <$fd>; + close $fd; + chomp $head; + return $head; +} + sub git_diff { my $old_name = shift || "/dev/null"; my $new_name = shift || "/dev/null"; @@ -217,7 +225,7 @@ if ($project eq "") { opendir(my $fd, "$projectroot/$defaultprojects"); my (@path) = grep(!/^\./, readdir($fd)); closedir($fd); - git_header(); + git_header_html(); print "
\n"; print "

\n"; foreach my $line (@path) { @@ -226,12 +234,12 @@ if ($project eq "") { } } print "

"; - git_footer(); + git_footer_html(); exit; } if ($action eq "blob") { - git_header(); + git_header_html(); print "

\n"; print "
\n";
 	open my $fd, "-|", "$gitbin/cat-file", "blob", $hash;
@@ -243,19 +251,15 @@ if ($action eq "blob") {
 	close $fd;
 	print "
\n"; print "
"; - git_footer(); + git_footer_html(); } elsif ($action eq "tree") { if ($hash eq "") { - open my $fd, "$projectroot/$project/.git/HEAD"; - my $head = <$fd>; - chomp $head; - close $fd; - $hash = $head; + $hash = git_head(); } open my $fd, "-|", "$gitbin/ls-tree", $hash; my (@entries) = map { chomp; $_ } <$fd>; close $fd; - git_header(); + git_header_html(); print "

\n"; print "
\n";
 	foreach my $line (@entries) {
@@ -272,18 +276,14 @@ if ($action eq "blob") {
 	}
 	print "
\n"; print "
"; - git_footer(); + git_footer_html(); } elsif ($action eq "log" || $action eq "rss") { - open my $fd, "$projectroot/$project/.git/HEAD"; - my $head = <$fd>; - chomp $head; - close $fd; - open $fd, "-|", "$gitbin/rev-tree", $head; + open my $fd, "-|", "$gitbin/rev-tree", git_head(); my (@revtree) = reverse sort map { chomp; $_ } <$fd>; close $fd; if ($action eq "log") { - git_header(); + git_header_html(); print "
\n"; print "view "; print $cgi->a({-href => "$myself/$project/log"}, "last day") . " | "; @@ -417,7 +417,7 @@ if ($action eq "blob") { } if ($action eq "log") { print "\n"; - git_footer(); + git_footer_html(); } elsif ($action eq "rss") { print ""; } @@ -439,7 +439,7 @@ if ($action eq "blob") { my (@difftree) = map { chomp; $_ } <$fd>; close $fd; - git_header(); + git_header_html(); print "
\n"; print "view " . $cgi->a({-href => "$myself/$project/commitdiff/$hash"}, "diff") . "


\n"; print "
$shortlog
\n"; @@ -468,15 +468,15 @@ if ($action eq "blob") { } print "\n"; print "
"; - git_footer(); + git_footer_html(); } elsif ($action eq "blobdiff") { - git_header(); + git_header_html(); print "

\n"; print "
\n";
 	git_diff($hash, $hash_parent, $hash, $hash_parent);
 	print "
\n"; print "
"; - git_footer(); + git_footer_html(); } elsif ($action eq "commitdiff") { my $parent = ""; open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; @@ -495,7 +495,7 @@ if ($action eq "blob") { my (@difftree) = map { chomp; $_ } <$fd>; close $fd; - git_header(); + git_header_html(); print "
\n"; print "view " . $cgi->a({-href => "$myself/$project/commit/$hash"}, "commit") . "


\n"; print "
$shortlog
\n"; @@ -521,5 +521,5 @@ if ($action eq "blob") { } print "\n"; print "
"; - git_footer(); + git_footer_html(); } -- cgit 1.2.3-korg From 703ac7102fb66f748f9a636f57852909b4425496 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:03:14 +0200 Subject: v021 --- gitweb.pl | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index dd5fbdc2a8..6d604d732e 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -157,6 +157,47 @@ sub git_head { return $head; } +sub git_commit { + my $commit = shift; + my %co; + my @parents; + + open my $fd, "-|", "$gitbin/cat-file", "commit", $commit; + while (my $line = <$fd>) { + chomp($line); + last if $line eq ""; + if ($line =~ m/^tree (.*)$/) { + $co{'tree'} = $1; + } elsif ($line =~ m/^parent (.*)$/) { + push @parents, $1; + } elsif ($line =~ m/^committer (.*>) ([0-9]+) (.*)$/) { + $co{'committer'} = $1; + $co{'committer_time'} = $2; + $co{'committer_timezone'} = $3; + } elsif ($line =~ m/^author (.*>) ([0-9]+) (.*)$/) { + $co{'$author'} = $1; + $co{'$author_time'} = $2; + $co{'$author_timezone'} = $3; + } + } + my $shortlog = <$fd>; + chomp($shortlog); + $co{'shortlog'} = escapeHTML($shortlog); + my $comment = $shortlog . "
"; + while (my $line = <$fd>) { + chomp($line); + if ($line =~ m/signed-off-by:/i) { + $comment .= '
' . escapeHTML($line) . "
\n"; + } else { + $comment .= escapeHTML($line) . "
\n"; + } + } + $co{'comment'} = $comment; + close $fd; + + return %co; +} + sub git_diff { my $old_name = shift || "/dev/null"; my $new_name = shift || "/dev/null"; @@ -408,11 +449,10 @@ if ($action eq "blob") { print ""; print "\n"; } elsif ($action eq "rss") { - if ($i < 12) { - print "\n\t$age_string: $shortlog\n"; - print "\t " . $cgi->url() . "/$project/commit/$commit\n"; - print "\n"; - } + last if ($i >= 12); + print "\n\t$age_string: $shortlog\n"; + print "\t " . $cgi->url() . "/$project/commit/$commit\n"; + print "\n"; } } if ($action eq "log") { -- cgit 1.2.3-korg From 3f714537ae72948a35db827d87363226200af646 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:03:52 +0200 Subject: v021 --- gitweb.pl | 103 ++++++++++++++++++++------------------------------------------ 1 file changed, 33 insertions(+), 70 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 6d604d732e..284a1588ea 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -109,7 +109,7 @@ print <) ([0-9]+) (.*)$/) { - $co{'$author'} = $1; - $co{'$author_time'} = $2; - $co{'$author_timezone'} = $3; + $co{'author'} = $1; + $co{'author_time'} = $2; + $co{'author_timezone'} = $3; } } - my $shortlog = <$fd>; - chomp($shortlog); - $co{'shortlog'} = escapeHTML($shortlog); - my $comment = $shortlog . "
"; - while (my $line = <$fd>) { - chomp($line); - if ($line =~ m/signed-off-by:/i) { - $comment .= '
' . escapeHTML($line) . "
\n"; - } else { - $comment .= escapeHTML($line) . "
\n"; - } - } - $co{'comment'} = $comment; + $co{'parents'} = \@parents; + my (@comment) = map { chomp; $_ } <$fd>; + $co{'comment'} = \@comment; + $co{'title'} = $comment[0]; close $fd; - return %co; } @@ -354,45 +344,9 @@ if ($action eq "blob") { my $time = $1; my $commit = $2; my $parent = $3; - my @parents; - my ($author, $author_time, $author_timezone); - my ($committer, $committer_time, $committer_timezone); - my $tree; - my $comment; - my $shortlog; - open my $fd, "-|", "$gitbin/cat-file", "commit", $commit; - while (my $line = <$fd>) { - chomp($line); - last if $line eq ""; - if ($line =~ m/^tree (.*)$/) { - $tree = $1; - } elsif ($line =~ m/^parent (.*)$/) { - push @parents, $1; - } elsif ($line =~ m/^committer (.*>) ([0-9]+) (.*)$/) { - $committer = $1; - $committer_time = $2; - $committer_timezone = $3; - } elsif ($line =~ m/^author (.*>) ([0-9]+) (.*)$/) { - $author = $1; - $author_time = $2; - $author_timezone = $3; - } - } - $shortlog = <$fd>; - chomp($shortlog); - $shortlog = escapeHTML($shortlog); - $comment = $shortlog . "
"; - while (my $line = <$fd>) { - chomp($line); - if ($line =~ m/signed-off-by:/i) { - $comment .= '
' . escapeHTML($line) . "
\n"; - } else { - $comment .= escapeHTML($line) . "
\n"; - } - } - close $fd; - my $age = time-$committer_time; + my %co = git_commit($commit); + my $age = time - $co{'committer_time'}; my $age_string; if ($age > 60*60*24*365*2) { $age_string = int $age/60/60/24/365; @@ -424,20 +378,21 @@ if ($action eq "blob") { } print "\n"; print "" . $age_string . "\n"; - print "" . $cgi->a({-href => "$myself/$project/commit/$commit"}, $shortlog) . ""; + print "" . $cgi->a({-href => "$myself/$project/commit/$commit"}, $co{'title'}) . ""; print "\n"; print "\n"; print ""; print $cgi->a({-href => "$myself/$project/commitdiff/$commit"}, "view diff") . "
\n"; print $cgi->a({-href => "$myself/$project/commit/$commit"}, "view commit") . "
\n"; - print $cgi->a({-href => "$myself/$project/tree/$tree"}, "view tree") . "
\n"; + print $cgi->a({-href => "$myself/$project/tree/$co{'tree'}"}, "view tree") . "
\n"; print "\n"; print "\n"; - print "author    " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]
\n"; - print "committer " . escapeHTML($committer) . " [" . gmtime($committer_time) . " " . $committer_timezone . "]
\n"; + print "author    " . escapeHTML($co{'author'}) . " [" . gmtime($co{'author_time'}) . " " . $co{'author_timezone'} . "]
\n"; + print "committer " . escapeHTML($co{'committer'}) . " [" . gmtime($co{'committer_time'}) . " " . $co{'committer_timezone'} . "]
\n"; print "commit    $commit
\n"; - print "tree      $tree
\n"; - foreach my $par (@parents) { + print "tree      $co{'tree'}
\n"; + my $parents = $co{'parents'}; + foreach my $par (@$parents) { print "parent    $par
\n"; } print ""; @@ -445,12 +400,20 @@ if ($action eq "blob") { print "\n"; print "\n"; print "\n"; - print "$comment

\n"; + my $comment = $co{'comment'}; + foreach my $line (@$comment) { + if ($line =~ m/signed-off-by:/i) { + print '
' . escapeHTML($line) . "
\n"; + } else { + print escapeHTML($line) . "
\n"; + } + } + print "

\n"; print ""; print "\n"; } elsif ($action eq "rss") { last if ($i >= 12); - print "\n\t$age_string: $shortlog\n"; + print "\n\t$age_string: " . escapeHTML($co{'title'}) . "\n"; print "\t " . $cgi->url() . "/$project/commit/$commit\n"; print "\n"; } @@ -471,8 +434,8 @@ if ($action eq "blob") { $parent = $1; } } - my $shortlog = <$fd>; - $shortlog = escapeHTML($shortlog); + my $title = <$fd>; + $title = escapeHTML($title); close $fd; open $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash; @@ -482,7 +445,7 @@ if ($action eq "blob") { git_header_html(); print "
\n"; print "view " . $cgi->a({-href => "$myself/$project/commitdiff/$hash"}, "diff") . "


\n"; - print "
$shortlog
\n"; + print "
$title
\n"; print "
\n";
 	foreach my $line (@difftree) {
 		# '*100644->100644	blob	9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596	net/ipv4/route.c'
@@ -527,8 +490,8 @@ if ($action eq "blob") {
 			$parent = $1;
 		}
 	}
-	my $shortlog = <$fd>;
-	$shortlog = escapeHTML($shortlog);
+	my $title = <$fd>;
+	$title = escapeHTML($title);
 	close $fd;
 
 	open $fd, "-|", "$gitbin/diff-tree", "-r", $parent, $hash;
@@ -538,7 +501,7 @@ if ($action eq "blob") {
 	git_header_html();
 	print "
\n"; print "view " . $cgi->a({-href => "$myself/$project/commit/$hash"}, "commit") . "


\n"; - print "
$shortlog
\n"; + print "
$title
\n"; print "
\n";
 	foreach my $line (@difftree) {
 		# '*100644->100644	blob	8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154	Makefile'
-- 
cgit 1.2.3-korg


From 3e029299d8c6608298c3a2fc1f02af6b2cef0f29 Mon Sep 17 00:00:00 2001
From: Kay Sievers 
Date: Sun, 7 Aug 2005 20:05:15 +0200
Subject: v025

---
 gitweb.pl | 187 ++++++++++++++++++++++++++++++++++----------------------------
 1 file changed, 102 insertions(+), 85 deletions(-)

diff --git a/gitweb.pl b/gitweb.pl
index 284a1588ea..a2ec30db10 100755
--- a/gitweb.pl
+++ b/gitweb.pl
@@ -2,7 +2,7 @@
 
 # gitweb.pl - simple web interface to track changes in git repositories
 #
-# Version 021
+# Version 025
 #
 # (C) 2005, Kay Sievers 
 # (C) 2005, Christian Gierke 
@@ -14,57 +14,59 @@ use warnings;
 use CGI qw(:standard :escapeHTML);
 use CGI::Carp qw(fatalsToBrowser);
 
+my $cgi = new CGI;
+
 my $projectroot =	"/home/kay/public_html";
 my $defaultprojects =	".";
 my $gitbin =		"/home/kay/bin/git";
 my $gittmp =		"/tmp";
+my $my_url =		$cgi->url();
+my $my_uri =		$cgi->url(-absolute => 1);
+my $my_url_parm =	$cgi->url(-path => 1);
+$my_url_parm =~ s/.*$my_uri//;
 
-my $cgi = new CGI;
 my $project = "";
 my $action = "";
 my $hash = "";
 my $hash_parent = "";
-my $view_back;
-my $myself = $cgi->url(-absolute => 1);
-my $url_parm = $cgi->url(-path => 1);
-$url_parm =~ s/.*$myself//;
+my $view_back = 1;
 
 # get values from url
-if ($url_parm =~ m#/(.+)/commit/([0-9a-fA-F]+)$#) {
+if ($my_url_parm =~ m#/(.+)/commit/([0-9a-fA-F]+)$#) {
 	$project = $1;
 	$action = "commit";
 	$hash = $2;
-} elsif ($url_parm =~ m#/(.+)/commitdiff/([0-9a-fA-F]+)$#) {
+} elsif ($my_url_parm =~ m#/(.+)/commitdiff/([0-9a-fA-F]+)$#) {
 	$project = $1;
 	$action = "commitdiff";
 	$hash = $2;
-} elsif ($url_parm =~ m#/(.+)/blobdiff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) {
+} elsif ($my_url_parm =~ m#/(.+)/blobdiff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) {
 	$project = $1;
 	$action = "blobdiff";
 	$hash = $2;
 	$hash_parent = $3;
-} elsif ($url_parm =~ m#/(.+)/blob/([0-9a-fA-F]+)$#) {
+} elsif ($my_url_parm =~ m#/(.+)/blob/([0-9a-fA-F]+)$#) {
 	$project = $1;
 	$action = "blob";
 	$hash = $2;
-} elsif ($url_parm =~ m#/(.+)/tree/([0-9a-fA-F]+)$#) {
+} elsif ($my_url_parm =~ m#/(.+)/tree/([0-9a-fA-F]+)$#) {
 	$project = $1;
 	$action = "tree";
 	$hash = $2;
-} elsif ($url_parm =~ m#/(.+)/log/([0-9]+)$#) {
+} elsif ($my_url_parm =~ m#/(.+)/log/([0-9]+)$#) {
 	$project = $1;
 	$action = "log";
 	$view_back = $2;
-} elsif ($url_parm =~ m#/(.+)/log$#) {
+} elsif ($my_url_parm =~ m#/(.+)/log$#) {
 	$project = $1;
 	$action = "log";
 	$view_back = 1;
-} elsif ($url_parm =~ m#/(.+)/rss$#) {
+} elsif ($my_url_parm =~ m#/(.+)/rss$#) {
 	$project = $1;
 	$action = "rss";
 	$view_back = 1;
-} elsif ($url_parm =~ m#/git-logo.png$#) {
-	print $cgi->header(-type => 'image/png');
+} elsif ($my_url_parm =~ m#/git-logo.png$#) {
+	print $cgi->header(-type => 'image/png', -expires => '+1d');
 	print	"\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122".
 		"\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324".
 		"\055\000\000\000\030\120\114\124\105\377\377\377\140\140\135\260".
@@ -79,7 +81,7 @@ if ($url_parm =~ m#/(.+)/commit/([0-9a-fA-F]+)$#) {
 		"\047\101\202\100\205\301\105\211\040\160\001\000\244\075\041\305".
 		"\022\034\232\376\000\000\000\000\111\105\116\104\256\102\140\202";
 	exit;
-} elsif ($url_parm =~ m#/(.+)$#) {
+} elsif ($my_url_parm =~ m#/(.+)$#) {
 	$project = $1;
 	$action = "log";
 	$view_back = 1;
@@ -91,13 +93,13 @@ $project =~ s#\/\.+##g;
 $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/.git/objects";
 
 sub git_header_html {
-	print $cgi->header(-type => 'text/html; charset: utf-8');
+	print $cgi->header(-type => 'text/html', -charset => 'utf-8');
 print <
 
 
 	git - $project $action
-  
+	
 	
 
 
 EOF
-	print "
\n"; - print "
"; + print "
"; print "" . "\"git\""; if ($defaultprojects ne "") { @@ -99,7 +87,12 @@ EOF } sub git_footer_html { - print "
\n"; + print "
"; + print ""; + if ($project ne '') { + print "XML"; + } + print "
"; print "\n"; } @@ -275,31 +268,30 @@ if ($project eq "") { my (@path) = sort grep(!/^\./, readdir($fd)); closedir($fd); git_header_html(); - print "
\n"; + print "
\n"; print "

\n"; foreach my $line (@path) { if (-e "$projectroot/$defaultprojects/$line/.git/HEAD") { print $cgi->a({-href => "$my_uri?p=$defaultprojects/$line;a=log"}, "$defaultprojects/$line") . "
\n"; } } - print "

"; + print "
"; git_footer_html(); exit; } if ($action eq "blob") { git_header_html(); - print "

\n"; - print "
\n";
+	print "


\n"; open my $fd, "-|", "$gitbin/cat-file", "blob", $hash; my $nr; while (my $line = <$fd>) { $nr++; - printf "%3i\t%s", $nr, escapeHTML($line);; + printf "%4i\t%s", $nr, escapeHTML($line);; } close $fd; - print "
\n"; - print "
"; + print "

\n"; + print "
"; git_footer_html(); } elsif ($action eq "tree") { if ($hash eq "") { @@ -309,8 +301,8 @@ if ($action eq "blob") { my (@entries) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); - print "

\n"; - print "
\n";
+	print "
\n"; + print "
\n";
 	foreach my $line (@entries) {
 		#'100644	blob	0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa	panic.c'
 		$line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
@@ -325,7 +317,7 @@ if ($action eq "blob") {
 		}
 	}
 	print "
\n"; - print "
"; + print "
"; git_footer_html(); } elsif ($action eq "log" || $action eq "rss") { open my $fd, "-|", "$gitbin/rev-list", git_head($project); @@ -334,7 +326,7 @@ if ($action eq "blob") { if ($action eq "log") { git_header_html(); - print "
\n"; + print "
\n"; print "view "; print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | "; print $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | "; @@ -343,7 +335,6 @@ if ($action eq "blob") { print $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "
\n"; print "

\n"; print "
\n"; - print "\n"; } elsif ($action eq "rss") { print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); print "\n". @@ -383,28 +374,22 @@ if ($action eq "blob") { if ($action eq "log") { if ($time_back > 0 && $age > $time_back*60*60*24) { if ($i == 0) { - print "\n"; - print "\n"; - print "\n"; + print "
Last change $age_string.

\n"; } last; } - print "\n"; - print "\n"; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ""; - print "\n"; + print ""; } elsif ($action eq "rss") { last if ($i >= 20); print "\n\t" . $ad{'mday-time'} . " - " . escapeHTML($co{'title'}) . "\n"; @@ -430,7 +414,6 @@ if ($action eq "blob") { } } if ($action eq "log") { - print "
Last change $age_string.
" . $age_string . "" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, $co{'title'}) . "
"; + print ""; + print "
" . $age_string . "
\n"; + print $co{'title'}; + print "
\n"; + print "
\n"; + print "
"; print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "view commit") . "
\n"; print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "view diff") . "
\n"; - print "
\n"; + print "\n"; print escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]
\n"; - print "
\n"; + print ""; + print "
\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { if ($line =~ m/^(signed-off|acked)-by:/i) { @@ -414,8 +399,7 @@ if ($action eq "blob") { } } print "

\n"; - print "
\n"; git_footer_html(); } elsif ($action eq "rss") { print ""; @@ -444,17 +427,14 @@ if ($action eq "blob") { close $fd; git_header_html(); - print "
view\n"; + print "
view\n"; print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | "; print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff"); - print "


\n"; - print "
" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, $co{'title'}) . "
\n"; - print "\n"; - print "\n"; - print ""; - print "\n"; - print "\n"; - print ""; - print "\n"; - print "
"; + print "

\n"; + print "$co{'title'}\n"; + print "
"; print "author    " . escapeHTML($co{'author'}) . " [" . $ad{'rfc2822'} . "]
\n"; if ($ad{'hour'} < 7 ) { print ""; } - print "localtime " . $ad{'rfc2822_local'} . "
\n"; if ($ad{'hour'} < 7 ) { print "
"; } print "committer " . escapeHTML($co{'committer'}) . " [" . $cd{'rfc2822'} . "]
\n"; print "commit    $hash
\n"; @@ -463,10 +443,8 @@ if ($action eq "blob") { foreach my $par (@$parents) { print "parent    " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$par"}, $par) . "
\n"; } - print "
\n"; + print ""; + print "
\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { if ($line =~ m/(signed-off|acked)-by:/i) { @@ -476,10 +454,6 @@ if ($action eq "blob") { } } print "

\n"; - print "
"; - print "
\n";
 	foreach my $line (@difftree) {
 		# '*100644->100644	blob	9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596	net/ipv4/route.c'
@@ -506,15 +480,15 @@ if ($action eq "blob") {
 		}
 	}
 	print "
\n"; - print "
"; + print "
"; git_footer_html(); } elsif ($action eq "blobdiff") { git_header_html(); - print "

\n"; + print "


\n"; print "
\n";
 	git_diff_html($hash_parent, $hash, $hash_parent, $hash);
 	print "
\n"; - print "
"; + print "
"; git_footer_html(); } elsif ($action eq "commitdiff") { my %co = git_commit($hash); @@ -523,11 +497,12 @@ if ($action eq "blob") { close $fd; git_header_html(); - print "
view\n"; + print "
view\n"; print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | "; print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff"); - print "


\n"; - print "
" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, $co{'title'}) . "
\n"; + print "

\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, $co{'title'}) ."\n"; + print "
\n"; print "
\n";
 	foreach my $line (@difftree) {
 		# '*100644->100644	blob	8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154	Makefile'
@@ -548,8 +523,8 @@ if ($action eq "blob") {
 			}
 		}
 	}
-	print "
\n"; - print "
"; + print "
\n"; + print "
"; git_footer_html(); } else { git_header_html(); -- cgit 1.2.3-korg From ff7669a5b9922e86831e59398e89bad1372dc581 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:13:02 +0200 Subject: v048 --- gitweb.pl | 185 ++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 102 insertions(+), 83 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index cdf0e3d752..643787f182 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "043"; +my $version = "048"; my $projectroot = "/"; my $defaultprojects = "home/kay/public_html"; my $gitbin = "/home/kay/bin/git"; @@ -26,7 +26,10 @@ my $project = $cgi->param('p'); my $action = $cgi->param('a'); my $hash = $cgi->param('h'); my $hash_parent = $cgi->param('hp'); -my $time_back = $cgi->param('t') || 1; +my $time_back = $cgi->param('t'); +if (!(defined($time_back))) { + $time_back = 1; +} $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/.git/objects"; # sanitize input @@ -53,26 +56,33 @@ print < EOF - print "
"; - print "" . + print "
\n" . + "" . "\"git\""; if ($defaultprojects ne "") { print $cgi->a({-href => "$my_uri"}, "projects") . " / "; @@ -89,9 +99,9 @@ EOF sub git_footer_html { print "
"; print ""; - if ($project ne '') { - print "XML"; - } + if ($project ne '') { + print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "XML") . "\n"; + } print "
"; print "\n"; } @@ -110,7 +120,7 @@ sub git_commit { my %co; my @parents; - open my $fd, "-|", "$gitbin/cat-file", "commit", $commit; + open my $fd, "-|", "$gitbin/cat-file commit $commit"; while (my $line = <$fd>) { chomp($line); last if $line eq ""; @@ -153,11 +163,11 @@ sub git_diff_html { my $to_label = "/dev/null"; my $pid = $$; - # create temp from-file + # create tmp from-file if ($from ne "") { $from_tmp = "$gittmp/gitweb_" . $$ . "_from"; open my $fd2, "> $from_tmp"; - open my $fd, "-|", "$gitbin/cat-file", "blob", $from; + open my $fd, "-|", "$gitbin/cat-file blob $from"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -169,7 +179,7 @@ sub git_diff_html { if ($to ne "") { $to_tmp = "$gittmp/gitweb_" . $$ . "_to"; open my $fd2, "> $to_tmp"; - open my $fd, "-|", "$gitbin/cat-file", "blob", $to; + open my $fd, "-|", "$gitbin/cat-file blob $to"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -177,7 +187,7 @@ sub git_diff_html { $to_label = "b/$to_name"; } - open my $fd, "-|", "/usr/bin/diff", "-L", $from_label, "-L", $to_label, "-u", "-p", $from_tmp, $to_tmp; + open my $fd, "-|", "/usr/bin/diff -u -p -L $from_label -L $to_label $from_tmp $to_tmp"; print "===== "; if ($from ne "") { print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from"}, $from); @@ -234,6 +244,10 @@ sub date_str { my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch); $date{'hour'} = $hour; + $date{'minute'} = $min; + $date{'mday'} = $mday; + $date{'day'} = $days[$wday]; + $date{'month'} = $months[$mon]; $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec; $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min; @@ -280,10 +294,14 @@ if ($project eq "") { exit; } +if ($action eq "") { + $action = "log"; +} + if ($action eq "blob") { git_header_html(); print "


\n"; - open my $fd, "-|", "$gitbin/cat-file", "blob", $hash; + open my $fd, "-|", "$gitbin/cat-file blob $hash"; my $nr; while (my $line = <$fd>) { $nr++; @@ -297,7 +315,7 @@ if ($action eq "blob") { if ($hash eq "") { $hash = git_head($project); } - open my $fd, "-|", "$gitbin/ls-tree", $hash; + open my $fd, "-|", "$gitbin/ls-tree $hash"; my (@entries) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); @@ -320,7 +338,7 @@ if ($action eq "blob") { print "
"; git_footer_html(); } elsif ($action eq "log" || $action eq "rss") { - open my $fd, "-|", "$gitbin/rev-list", git_head($project); + open my $fd, "-|", "$gitbin/rev-list " . git_head($project); my (@revtree) = map { chomp; $_ } <$fd>; close $fd; @@ -328,13 +346,13 @@ if ($action eq "blob") { git_header_html(); print "
\n"; print "view "; - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | "; - print $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | "; - print $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | "; - print $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | "; - print $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "
\n"; - print "

\n"; - print "
\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "
\n"; + print "

\n" . + "
\n"; } elsif ($action eq "rss") { print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); print "\n". @@ -372,24 +390,23 @@ if ($action eq "blob") { $age_string .= " minutes ago"; } if ($action eq "log") { - if ($time_back > 0 && $age > $time_back*60*60*24) { + if ($time_back > 0 && $age > $time_back*60*60*24) { if ($i == 0) { print "
Last change $age_string.

\n"; } last; } - print ""; - print "
" . $age_string . "
\n"; - print $co{'title'}; - print "
\n"; - print "
\n"; - print "
"; - print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "view commit") . "
\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "view diff") . "
\n"; - print "
\n"; - print escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]
\n"; - print "
"; - print "
\n"; + print "\n"; + print "
\n" . + "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "view commit") . "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "view diff") . "
\n" . + "
\n" . + escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]
\n" . + "
\n" . + "
\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { if ($line =~ m/^(signed-off|acked)-by:/i) { @@ -398,19 +415,20 @@ if ($action eq "blob") { print escapeHTML($line) . "
\n"; } } - print "

\n"; - print "
"; + print "

\n" . + "
\n"; } elsif ($action eq "rss") { last if ($i >= 20); - print "\n\t" . $ad{'mday-time'} . " - " . escapeHTML($co{'title'}) . "\n"; - print "\t " . $my_url . "/$project/commit/$commit\n"; - print "\t"; + print "\n" . + "\t" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "\n" . + "\t " . $my_url . "?p=$project;a==commit;h=$commit\n" . + "\t"; my $comment = $co{'comment'}; foreach my $line (@$comment) { print escapeHTML($line) . "\n"; } - print "\t\n"; - print "\n"; + print "\t\n" . + "\n"; } } if ($action eq "log") { @@ -422,28 +440,28 @@ if ($action eq "blob") { my %co = git_commit($hash); my %ad = date_str($co{'author_time_epoch'}, $co{'author_time_zone'}); my %cd = date_str($co{'committer_time_epoch'}, $co{'committer_time_zone'}); - open my $fd, "-|", "$gitbin/diff-tree", "-r", $co{'parent'}, $hash; + open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); - print "
view\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | "; - print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff"); - print "

\n"; + print "
view\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" . + "

\n"; print "$co{'title'}\n"; - print "
"; - print "author    " . escapeHTML($co{'author'}) . " [" . $ad{'rfc2822'} . "]
\n"; + print "
" . + "author    " . escapeHTML($co{'author'}) . " [" . $ad{'rfc2822'} . "]
\n"; if ($ad{'hour'} < 7 ) { print ""; } if ($ad{'hour'} < 7 ) { print ""; } - print "committer " . escapeHTML($co{'committer'}) . " [" . $cd{'rfc2822'} . "]
\n"; - print "commit    $hash
\n"; - print "tree      " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "
\n"; + print "committer " . escapeHTML($co{'committer'}) . " [" . $cd{'rfc2822'} . "]
\n" . + "commit    $hash
\n" . + "tree      " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "
\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { - print "parent    " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$par"}, $par) . "
\n"; + print "parent    " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "
\n"; } - print "
"; + print "
\n"; print "
\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { @@ -479,31 +497,31 @@ if ($action eq "blob") { } } } - print "
\n"; - print "
"; + print "\n" . + "
"; git_footer_html(); } elsif ($action eq "blobdiff") { git_header_html(); - print "


\n"; - print "
\n";
+	print "


\n" . + "
\n";
 	git_diff_html($hash_parent, $hash, $hash_parent, $hash);
-	print "
\n"; - print "
"; + print "
\n" . + "
"; git_footer_html(); } elsif ($action eq "commitdiff") { my %co = git_commit($hash); - open my $fd, "-|", "$gitbin/diff-tree", "-r", $co{'parent'}, $hash; + open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); - print "
view\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | "; - print $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff"); - print "

\n"; + print "
view\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" . + "

\n"; print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, $co{'title'}) ."\n"; - print "
\n"; - print "
\n";
+	print "
\n" . + "
\n";
 	foreach my $line (@difftree) {
 		# '*100644->100644	blob	8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154	Makefile'
 		$line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
@@ -528,8 +546,9 @@ if ($action eq "blob") {
 	git_footer_html();
 } else {
 	git_header_html();
-	print "
\n"; - print "unknown action"; - print "


\n"; + print "
\n" . + "

\n"; + print "unknown action\n"; + print "
\n"; git_footer_html(); } -- cgit 1.2.3-korg From 185f09e5ba4031f689659045a7f840a14b5ab909 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:13:11 +0200 Subject: v049 --- gitweb.pl | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/gitweb.pl b/gitweb.pl index 643787f182..096786b932 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "048"; +my $version = "049"; my $projectroot = "/"; my $defaultprojects = "home/kay/public_html"; my $gitbin = "/home/kay/bin/git"; @@ -130,14 +130,14 @@ sub git_commit { push @parents, $1; } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) { $co{'author'} = $1; - $co{'author_time_epoch'} = $2; - $co{'author_timezone'} = $3; + $co{'author_epoch'} = $2; + $co{'author_tz'} = $3; $co{'author_name'} = $co{'author'}; $co{'author_name'} =~ s/ <.*//; } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) { $co{'committer'} = $1; - $co{'committer_time_epoch'} = $2; - $co{'committer_timezone'} = $3; + $co{'committer_epoch'} = $2; + $co{'committer_tz'} = $3; $co{'committer_name'} = $co{'committer'}; $co{'committer_name'} =~ s/ <.*//; } @@ -254,7 +254,9 @@ sub date_str { $tz =~ m/((-|\+)[0-9][0-9])([0-9][0-9])/; my $local = $epoch + (($1 + ($2/60)) * 3600); ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local); - $date{'rfc2822_local'} = sprintf "%s, %d %s %4d %02d:%02d:%02d %s", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec, $tz; + $date{'hour_local'} = $hour; + $date{'minute_local'} = $min; + $date{'tz_local'} = $tz; return %date; } @@ -367,8 +369,8 @@ if ($action eq "blob") { for (my $i = 0; $i <= $#revtree; $i++) { my $commit = $revtree[$i]; my %co = git_commit($commit); - my %ad = date_str($co{'author_time_epoch'}); - my $age = time - $co{'committer_time_epoch'}; + my %ad = date_str($co{'author_epoch'}); + my $age = time - $co{'committer_epoch'}; my $age_string; if ($age > 60*60*24*365*2) { $age_string = int $age/60/60/24/365; @@ -438,8 +440,8 @@ if ($action eq "blob") { } } elsif ($action eq "commit") { my %co = git_commit($hash); - my %ad = date_str($co{'author_time_epoch'}, $co{'author_time_zone'}); - my %cd = date_str($co{'committer_time_epoch'}, $co{'committer_time_zone'}); + my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); + my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -450,16 +452,22 @@ if ($action eq "blob") { $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" . "

\n"; print "$co{'title'}\n"; - print "
" . - "author    " . escapeHTML($co{'author'}) . " [" . $ad{'rfc2822'} . "]
\n"; - if ($ad{'hour'} < 7 ) { print ""; } - if ($ad{'hour'} < 7 ) { print ""; } - print "committer " . escapeHTML($co{'committer'}) . " [" . $cd{'rfc2822'} . "]
\n" . - "commit    $hash
\n" . - "tree      " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "
\n"; + print "
\n"; + print "author      " . escapeHTML($co{'author'}) . "
\n"; + print "author-time " . $ad{'rfc2822'}; + if ($ad{'hour_local'} < 6) { print ""; } + printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); + if ($ad{'hour_local'} < 6 ) { print ""; } + print "
\n"; + print "committer   " . escapeHTML($co{'committer'}) . "
\n"; + print "commit-time " . $ad{'rfc2822'}; + printf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}); + print "
\n"; + print "commit      $hash
\n"; + print "tree        " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "
\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { - print "parent    " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "
\n"; + print "parent      " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "
\n"; } print "
\n"; print "
\n"; -- cgit 1.2.3-korg From 2ad9331e15fba4476cb734f46b845638ee82222e Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:14:48 +0200 Subject: v053 rename gitweb.pl to gitweb.cgi --- gitweb.cgi | 589 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gitweb.pl | 562 ---------------------------------------------------------- 2 files changed, 589 insertions(+), 562 deletions(-) create mode 100755 gitweb.cgi delete mode 100755 gitweb.pl diff --git a/gitweb.cgi b/gitweb.cgi new file mode 100755 index 0000000000..017664b8f4 --- /dev/null +++ b/gitweb.cgi @@ -0,0 +1,589 @@ +#!/usr/bin/perl + +# gitweb.pl - simple web interface to track changes in git repositories +# +# (C) 2005, Kay Sievers +# (C) 2005, Christian Gierke +# +# This file is licensed under the GPL v2, or a later version + +use strict; +use warnings; +use CGI qw(:standard :escapeHTML); +use CGI::Carp qw(fatalsToBrowser); + +my $cgi = new CGI; + +my $version = "053"; +my $projectroot = "/pub/scm"; +my $defaultprojects = "linux/kernel/git"; +my $gitbin = "/usr/bin"; +my $gittmp = "/tmp/gitweb"; +my $giturl = "/pub/software/scm/cogito"; +my $my_url = $cgi->url(); +my $my_uri = $cgi->url(-absolute => 1); + +mkdir($gittmp, 0700); + +my $project = $cgi->param('p'); +my $action = $cgi->param('a'); +my $hash = $cgi->param('h'); +my $hash_parent = $cgi->param('hp'); +my $time_back = $cgi->param('t'); +if (!(defined($time_back))) { + $time_back = 1; +} +$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; + +# sanitize input +$action =~ s/[^0-9a-zA-Z\.\-]//g; +$hash =~ s/[^0-9a-fA-F]//g; +$hash_parent =~ s/[^0-9a-fA-F]//g; +$time_back =~ s/[^0-9]+//g; +if (defined($project) && $project =~ /(^|\/)(|\.|\.\.)($|\/)/) { + print $cgi->header(-type=>'text/plain', -status=>'403 Permission denied'); + print "Malformed query, file missing or permission denied\n"; + exit 0; +} +$project =~ s/|//g; + +sub git_header_html { + print $cgi->header(-type => 'text/html', -charset => 'utf-8'); +print < + + + git - $project $action + + + + +EOF + print "
\n" . + "" . + "\"git\""; + if ($defaultprojects ne "") { + print $cgi->a({-href => "$my_uri"}, "projects") . " / "; + } + if ($project ne "") { + print $cgi->a({-href => "$my_uri?p=$project;a=log"}, $project); + } + if ($action ne "") { + print " / $action"; + } + print "
\n"; +} + +sub git_footer_html { + print "
"; + print ""; + if ($project ne '') { + print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "XML") . "\n"; + } + print "
"; + print "\n"; +} + +sub git_head { + my $path = shift; + open my $fd, "$projectroot/$path/HEAD"; + my $head = <$fd>; + close $fd; + chomp $head; + return $head; +} + +sub git_commit { + my $commit = shift; + my %co; + my @parents; + + open my $fd, "-|", "$gitbin/cat-file commit $commit"; + while (my $line = <$fd>) { + chomp($line); + last if $line eq ""; + if ($line =~ m/^tree (.*)$/) { + $co{'tree'} = $1; + } elsif ($line =~ m/^parent (.*)$/) { + push @parents, $1; + } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) { + $co{'author'} = $1; + $co{'author_epoch'} = $2; + $co{'author_tz'} = $3; + $co{'author_name'} = $co{'author'}; + $co{'author_name'} =~ s/ <.*//; + } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) { + $co{'committer'} = $1; + $co{'committer_epoch'} = $2; + $co{'committer_tz'} = $3; + $co{'committer_name'} = $co{'committer'}; + $co{'committer_name'} =~ s/ <.*//; + } + } + $co{'parents'} = \@parents; + $co{'parent'} = $parents[0]; + my (@comment) = map { chomp; $_ } <$fd>; + $co{'comment'} = \@comment; + $co{'title'} = $comment[0]; + close $fd; + return %co; +} + +sub git_diff_html { + my $from_name = shift || "/dev/null"; + my $to_name = shift || "/dev/null"; + my $from = shift; + my $to = shift; + + my $from_tmp = "/dev/null"; + my $to_tmp = "/dev/null"; + my $from_label = "/dev/null"; + my $to_label = "/dev/null"; + my $pid = $$; + + # create tmp from-file + if ($from ne "") { + $from_tmp = "$gittmp/gitweb_" . $$ . "_from"; + open my $fd2, "> $from_tmp"; + open my $fd, "-|", "$gitbin/cat-file blob $from"; + my @file = <$fd>; + print $fd2 @file; + close $fd2; + close $fd; + $from_label = "a/$from_name"; + } + + # create tmp to-file + if ($to ne "") { + $to_tmp = "$gittmp/gitweb_" . $$ . "_to"; + open my $fd2, "> $to_tmp"; + open my $fd, "-|", "$gitbin/cat-file blob $to"; + my @file = <$fd>; + print $fd2 @file; + close $fd2; + close $fd; + $to_label = "b/$to_name"; + } + + open my $fd, "-|", "/usr/bin/diff -u -p -L $from_label -L $to_label $from_tmp $to_tmp"; + print "===== "; + if ($from ne "") { + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from"}, $from); + } else { + print $from_name; + } + print " vs "; + if ($to ne "") { + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to"}, $to); + } else { + print $to_name; + } + print " =====\n"; + while (my $line = <$fd>) { + my $char = substr($line,0,1); + print '' if $char eq '+'; + print '' if $char eq '-'; + print '' if $char eq '@'; + print escapeHTML($line); + print '' if $char eq '+' or $char eq '-' or $char eq '@'; + } + close $fd; + + if ($from ne "") { + unlink("$from_tmp"); + } + if ($to ne "") { + unlink("$to_tmp"); + } +} + +sub mode_str { + my $perms = oct shift; + my $modestr; + if ($perms & 040000) { + $modestr .= 'drwxrwxr-x'; + } else { + # git cares only about the executable bit + if ($perms & 0100) { + $modestr .= '-rwxrwxr-x'; + } else { + $modestr .= '-rw-rw-r--'; + }; + } + return $modestr; +} + +sub date_str { + my $epoch = shift; + my $tz = shift || "-0000"; + + my %date; + my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); + my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch); + $date{'hour'} = $hour; + $date{'minute'} = $min; + $date{'mday'} = $mday; + $date{'day'} = $days[$wday]; + $date{'month'} = $months[$mon]; + $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec; + $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min; + + $tz =~ m/((-|\+)[0-9][0-9])([0-9][0-9])/; + my $local = $epoch + (($1 + ($2/60)) * 3600); + ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local); + $date{'hour_local'} = $hour; + $date{'minute_local'} = $min; + $date{'tz_local'} = $tz; + return %date; +} + +if ($action eq "git-logo.png") { + print $cgi->header(-type => 'image/png', -expires => '+1d'); + print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122". + "\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324". + "\055\000\000\000\030\120\114\124\105\377\377\377\140\140\135\260". + "\257\252\000\200\000\316\315\307\300\000\000\350\350\346\367\367". + "\366\225\014\247\107\000\000\000\163\111\104\101\124\050\317\143". + "\110\147\040\004\112\134\030\012\010\052\142\123\141\040\002\010". + "\015\151\105\254\241\241\001\060\014\223\140\066\046\122\221\261". + "\001\021\326\341\125\144\154\154\314\154\154\014\242\014\160\052". + "\142\006\052\301\142\035\263\001\002\123\244\010\350\000\003\030". + "\046\126\021\324\341\040\227\033\340\264\016\065\044\161\051\202". + "\231\060\270\223\012\021\271\105\210\301\215\240\242\104\041\006". + "\047\101\202\100\205\301\105\211\040\160\001\000\244\075\041\305". + "\022\034\232\376\000\000\000\000\111\105\116\104\256\102\140\202"; + exit; +} + +# show list of default projects +if ($project eq "") { + opendir(my $fd, "$projectroot/$defaultprojects"); + my (@users) = sort grep(!/^\./, readdir($fd)); + closedir($fd); + git_header_html(); + print "
\n"; + print "

\n"; + foreach my $user (@users) { + opendir($fd, "$projectroot/$defaultprojects/$user"); + my (@repos) = sort grep(/\.git$/, readdir($fd)); + closedir($fd); + foreach my $repo (@repos) { + if (-e "$projectroot/$defaultprojects/$user/$repo/HEAD") { + print $cgi->a({-href => "$my_uri?p=$defaultprojects/$user/$repo;a=log"}, "$defaultprojects/$user/$repo") . "
\n"; + } + } + } + print "
"; + git_footer_html(); + exit; +} + +if ($action eq "") { + $action = "log"; +} + +if ($action eq "blob") { + git_header_html(); + print "


\n"; + open my $fd, "-|", "$gitbin/cat-file blob $hash"; + my $nr; + while (my $line = <$fd>) { + $nr++; + printf "%4i\t%s", $nr, escapeHTML($line);; + } + close $fd; + print "

\n"; + print "
"; + git_footer_html(); +} elsif ($action eq "tree") { + if ($hash eq "") { + $hash = git_head($project); + } + open my $fd, "-|", "$gitbin/ls-tree $hash"; + my (@entries) = map { chomp; $_ } <$fd>; + close $fd; + git_header_html(); + print "
\n"; + print "
\n";
+	foreach my $line (@entries) {
+		#'100644	blob	0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa	panic.c'
+		$line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
+		my $t_mode = $1;
+		my $t_type = $2;
+		my $t_hash = $3;
+		my $t_name = $4;
+		if ($t_type eq "blob") {
+			print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name) . "\n";
+		} elsif ($t_type eq "tree") {
+			print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, $t_name) . "\n";
+		}
+	}
+	print "
\n"; + print "
"; + git_footer_html(); +} elsif ($action eq "log" || $action eq "rss") { + open my $fd, "-|", "$gitbin/rev-list " . git_head($project); + my (@revtree) = map { chomp; $_ } <$fd>; + close $fd; + + if ($action eq "log") { + git_header_html(); + print "
\n"; + print "view "; + print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "
\n"; + print "

\n" . + "
\n"; + } elsif ($action eq "rss") { + print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); + print "\n". + "\n"; + print "\n"; + print "$project\n". + " " . $my_url . "/$project/log\n". + "$project log\n". + "en\n"; + } + + for (my $i = 0; $i <= $#revtree; $i++) { + my $commit = $revtree[$i]; + my %co = git_commit($commit); + my %ad = date_str($co{'author_epoch'}); + my $age = time - $co{'committer_epoch'}; + my $age_string; + if ($age > 60*60*24*365*2) { + $age_string = int $age/60/60/24/365; + $age_string .= " years ago"; + } elsif ($age > 60*60*24*365/12*2) { + $age_string = int $age/60/60/24/365/12; + $age_string .= " months ago"; + } elsif ($age > 60*60*24*7*2) { + $age_string = int $age/60/60/24/7; + $age_string .= " weeks ago"; + } elsif ($age > 60*60*24*2) { + $age_string = int $age/60/60/24; + $age_string .= " days ago"; + } elsif ($age > 60*60*2) { + $age_string = int $age/60/60; + $age_string .= " hours ago"; + } elsif ($age > 60*2) { + $age_string = int $age/60; + $age_string .= " minutes ago"; + } + if ($action eq "log") { + if ($time_back > 0 && $age > $time_back*60*60*24) { + if ($i == 0) { + print "
Last change $age_string.

\n"; + } + last; + } + print "\n"; + print "
\n" . + "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "view commit") . "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "view diff") . "
\n" . + "
\n" . + escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]
\n" . + "
\n" . + "
\n"; + my $comment = $co{'comment'}; + foreach my $line (@$comment) { + if ($line =~ m/^(signed-off|acked)-by:/i) { + print '
' . escapeHTML($line) . "
\n"; + } else { + print escapeHTML($line) . "
\n"; + } + } + print "

\n" . + "
\n"; + } elsif ($action eq "rss") { + last if ($i >= 20); + print "\n" . + "\t" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "\n" . + "\t " . $my_url . "?p=$project;a==commit;h=$commit\n" . + "\t"; + my $comment = $co{'comment'}; + foreach my $line (@$comment) { + print escapeHTML($line) . "\n"; + } + print "\t\n" . + "\n"; + } + } + if ($action eq "log") { + git_footer_html(); + } elsif ($action eq "rss") { + print "
"; + } +} elsif ($action eq "commit") { + my %co = git_commit($hash); + my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); + my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); + open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; + my (@difftree) = map { chomp; $_ } <$fd>; + close $fd; + + git_header_html(); + print "
view\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" . + "

\n"; + print "$co{'title'}\n"; + print "
\n"; + print "author      " . escapeHTML($co{'author'}) . "
\n"; + print "author-time " . $ad{'rfc2822'}; + if ($ad{'hour_local'} < 6) { print ""; } + printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); + if ($ad{'hour_local'} < 6 ) { print ""; } + print "
\n"; + print "committer   " . escapeHTML($co{'committer'}) . "
\n"; + print "commit-time " . $ad{'rfc2822'}; + printf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}); + print "
\n"; + print "commit      $hash
\n"; + print "tree        " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "
\n"; + my $parents = $co{'parents'}; + foreach my $par (@$parents) { + print "parent      " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "
\n"; + } + print "
\n"; + print "
\n"; + my $comment = $co{'comment'}; + foreach my $line (@$comment) { + if ($line =~ m/(signed-off|acked)-by:/i) { + print '
' . escapeHTML($line) . "
\n"; + } else { + print escapeHTML($line) . "
\n"; + } + } + print "

\n"; + print "
\n";
+	foreach my $line (@difftree) {
+		# '*100644->100644	blob	9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596	net/ipv4/route.c'
+		# '+100644	blob	4a83ab6cd565d21ab0385bac6643826b83c2fcd4	arch/arm/lib/bitops.h'
+		$line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
+		my $op = $1;
+		my $mode = $2;
+		my $type = $3;
+		my $id = $4;
+		my $file = $5;
+		$mode =~ m/^([0-7]{6})/;
+		my $modestr = mode_str($1);
+		if ($type eq "blob") {
+			if ($op eq "+") {
+				print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$id"}, $file) . " (new)\n";
+			} elsif ($op eq "-") {
+				print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;hp=$id"}, $file) . " (removed)\n";
+			} elsif ($op eq "*") {
+				$id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
+				my $from = $1;
+				my $to = $2;
+				print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, $file) . "\n";
+			}
+		}
+	}
+	print "
\n" . + "
\n"; + git_footer_html(); +} elsif ($action eq "blobdiff") { + git_header_html(); + print "


\n" . + "
\n";
+	git_diff_html($hash_parent, $hash, $hash_parent, $hash);
+	print "
\n" . + "
"; + git_footer_html(); +} elsif ($action eq "commitdiff") { + my %co = git_commit($hash); + open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; + my (@difftree) = map { chomp; $_ } <$fd>; + close $fd; + + git_header_html(); + print "
view\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" . + "

\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, $co{'title'}) ."\n"; + print "
\n" . + "
\n";
+	foreach my $line (@difftree) {
+		# '*100644->100644	blob	8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154	Makefile'
+		$line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
+		my $op = $1;
+		my $mode = $2;
+		my $type = $3;
+		my $id = $4;
+		my $file = $5;
+		if ($type eq "blob") {
+			if ($op eq "+") {
+				git_diff_html("", $file, "", $id);
+			} elsif ($op eq "-") {
+				git_diff_html($file, "", $id, "");
+			} elsif ($op eq "*") {
+				$id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
+				git_diff_html($file, $file, $1, $2);
+			}
+		}
+	}
+	print "
\n"; + print "
"; + git_footer_html(); +} else { + git_header_html(); + print "
\n" . + "

\n"; + print "unknown action\n"; + print "
\n"; + git_footer_html(); +} diff --git a/gitweb.pl b/gitweb.pl deleted file mode 100755 index 096786b932..0000000000 --- a/gitweb.pl +++ /dev/null @@ -1,562 +0,0 @@ -#!/usr/bin/perl - -# gitweb.pl - simple web interface to track changes in git repositories -# -# (C) 2005, Kay Sievers -# (C) 2005, Christian Gierke -# -# This file is licensed under the GPL v2, or a later version - -use strict; -use warnings; -use CGI qw(:standard :escapeHTML); -use CGI::Carp qw(fatalsToBrowser); - -my $cgi = new CGI; - -my $version = "049"; -my $projectroot = "/"; -my $defaultprojects = "home/kay/public_html"; -my $gitbin = "/home/kay/bin/git"; -my $gittmp = "/tmp"; -my $my_url = $cgi->url(); -my $my_uri = $cgi->url(-absolute => 1); - -my $project = $cgi->param('p'); -my $action = $cgi->param('a'); -my $hash = $cgi->param('h'); -my $hash_parent = $cgi->param('hp'); -my $time_back = $cgi->param('t'); -if (!(defined($time_back))) { - $time_back = 1; -} -$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/.git/objects"; - -# sanitize input -$action =~ s/[^0-9a-zA-Z\.\-]//g; -$project =~ s/\/\.//g; -$project =~ s/^\/+//g; -$project =~ s/\/+$//g; -$project =~ s/|//g; -$hash =~ s/[^0-9a-fA-F]//g; -$hash_parent =~ s/[^0-9a-fA-F]//g; -$time_back =~ s/[^0-9]+//g; - -sub git_header_html { - print $cgi->header(-type => 'text/html', -charset => 'utf-8'); -print < - - - git - $project $action - - - - -EOF - print "
\n" . - "" . - "\"git\""; - if ($defaultprojects ne "") { - print $cgi->a({-href => "$my_uri"}, "projects") . " / "; - } - if ($project ne "") { - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, $project); - } - if ($action ne "") { - print " / $action"; - } - print "
\n"; -} - -sub git_footer_html { - print "
"; - print ""; - if ($project ne '') { - print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "XML") . "\n"; - } - print "
"; - print "\n"; -} - -sub git_head { - my $path = shift; - open my $fd, "$projectroot/$path/.git/HEAD"; - my $head = <$fd>; - close $fd; - chomp $head; - return $head; -} - -sub git_commit { - my $commit = shift; - my %co; - my @parents; - - open my $fd, "-|", "$gitbin/cat-file commit $commit"; - while (my $line = <$fd>) { - chomp($line); - last if $line eq ""; - if ($line =~ m/^tree (.*)$/) { - $co{'tree'} = $1; - } elsif ($line =~ m/^parent (.*)$/) { - push @parents, $1; - } elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) { - $co{'author'} = $1; - $co{'author_epoch'} = $2; - $co{'author_tz'} = $3; - $co{'author_name'} = $co{'author'}; - $co{'author_name'} =~ s/ <.*//; - } elsif ($line =~ m/^committer (.*) ([0-9]+) (.*)$/) { - $co{'committer'} = $1; - $co{'committer_epoch'} = $2; - $co{'committer_tz'} = $3; - $co{'committer_name'} = $co{'committer'}; - $co{'committer_name'} =~ s/ <.*//; - } - } - $co{'parents'} = \@parents; - $co{'parent'} = $parents[0]; - my (@comment) = map { chomp; $_ } <$fd>; - $co{'comment'} = \@comment; - $co{'title'} = $comment[0]; - close $fd; - return %co; -} - -sub git_diff_html { - my $from_name = shift || "/dev/null"; - my $to_name = shift || "/dev/null"; - my $from = shift; - my $to = shift; - - my $from_tmp = "/dev/null"; - my $to_tmp = "/dev/null"; - my $from_label = "/dev/null"; - my $to_label = "/dev/null"; - my $pid = $$; - - # create tmp from-file - if ($from ne "") { - $from_tmp = "$gittmp/gitweb_" . $$ . "_from"; - open my $fd2, "> $from_tmp"; - open my $fd, "-|", "$gitbin/cat-file blob $from"; - my @file = <$fd>; - print $fd2 @file; - close $fd2; - close $fd; - $from_label = "a/$from_name"; - } - - # create tmp to-file - if ($to ne "") { - $to_tmp = "$gittmp/gitweb_" . $$ . "_to"; - open my $fd2, "> $to_tmp"; - open my $fd, "-|", "$gitbin/cat-file blob $to"; - my @file = <$fd>; - print $fd2 @file; - close $fd2; - close $fd; - $to_label = "b/$to_name"; - } - - open my $fd, "-|", "/usr/bin/diff -u -p -L $from_label -L $to_label $from_tmp $to_tmp"; - print "===== "; - if ($from ne "") { - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from"}, $from); - } else { - print $from_name; - } - print " vs "; - if ($to ne "") { - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to"}, $to); - } else { - print $to_name; - } - print " =====\n"; - while (my $line = <$fd>) { - my $char = substr($line,0,1); - print '' if $char eq '+'; - print '' if $char eq '-'; - print '' if $char eq '@'; - print escapeHTML($line); - print '' if $char eq '+' or $char eq '-' or $char eq '@'; - } - close $fd; - - if ($from ne "") { - unlink("$from_tmp"); - } - if ($to ne "") { - unlink("$to_tmp"); - } -} - -sub mode_str { - my $perms = oct shift; - my $modestr; - if ($perms & 040000) { - $modestr .= 'drwxrwxr-x'; - } else { - # git cares only about the executable bit - if ($perms & 0100) { - $modestr .= '-rwxrwxr-x'; - } else { - $modestr .= '-rw-rw-r--'; - }; - } - return $modestr; -} - -sub date_str { - my $epoch = shift; - my $tz = shift || "-0000"; - - my %date; - my @months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); - my @days = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); - my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($epoch); - $date{'hour'} = $hour; - $date{'minute'} = $min; - $date{'mday'} = $mday; - $date{'day'} = $days[$wday]; - $date{'month'} = $months[$mon]; - $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec; - $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min; - - $tz =~ m/((-|\+)[0-9][0-9])([0-9][0-9])/; - my $local = $epoch + (($1 + ($2/60)) * 3600); - ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local); - $date{'hour_local'} = $hour; - $date{'minute_local'} = $min; - $date{'tz_local'} = $tz; - return %date; -} - -if ($action eq "git-logo.png") { - print $cgi->header(-type => 'image/png', -expires => '+1d'); - print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122". - "\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324". - "\055\000\000\000\030\120\114\124\105\377\377\377\140\140\135\260". - "\257\252\000\200\000\316\315\307\300\000\000\350\350\346\367\367". - "\366\225\014\247\107\000\000\000\163\111\104\101\124\050\317\143". - "\110\147\040\004\112\134\030\012\010\052\142\123\141\040\002\010". - "\015\151\105\254\241\241\001\060\014\223\140\066\046\122\221\261". - "\001\021\326\341\125\144\154\154\314\154\154\014\242\014\160\052". - "\142\006\052\301\142\035\263\001\002\123\244\010\350\000\003\030". - "\046\126\021\324\341\040\227\033\340\264\016\065\044\161\051\202". - "\231\060\270\223\012\021\271\105\210\301\215\240\242\104\041\006". - "\047\101\202\100\205\301\105\211\040\160\001\000\244\075\041\305". - "\022\034\232\376\000\000\000\000\111\105\116\104\256\102\140\202"; - exit; -} - -# show list of default projects -if ($project eq "") { - opendir(my $fd, "$projectroot/$defaultprojects"); - my (@path) = sort grep(!/^\./, readdir($fd)); - closedir($fd); - git_header_html(); - print "
\n"; - print "

\n"; - foreach my $line (@path) { - if (-e "$projectroot/$defaultprojects/$line/.git/HEAD") { - print $cgi->a({-href => "$my_uri?p=$defaultprojects/$line;a=log"}, "$defaultprojects/$line") . "
\n"; - } - } - print "
"; - git_footer_html(); - exit; -} - -if ($action eq "") { - $action = "log"; -} - -if ($action eq "blob") { - git_header_html(); - print "


\n"; - open my $fd, "-|", "$gitbin/cat-file blob $hash"; - my $nr; - while (my $line = <$fd>) { - $nr++; - printf "%4i\t%s", $nr, escapeHTML($line);; - } - close $fd; - print "

\n"; - print "
"; - git_footer_html(); -} elsif ($action eq "tree") { - if ($hash eq "") { - $hash = git_head($project); - } - open my $fd, "-|", "$gitbin/ls-tree $hash"; - my (@entries) = map { chomp; $_ } <$fd>; - close $fd; - git_header_html(); - print "
\n"; - print "
\n";
-	foreach my $line (@entries) {
-		#'100644	blob	0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa	panic.c'
-		$line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
-		my $t_mode = $1;
-		my $t_type = $2;
-		my $t_hash = $3;
-		my $t_name = $4;
-		if ($t_type eq "blob") {
-			print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name) . "\n";
-		} elsif ($t_type eq "tree") {
-			print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, $t_name) . "\n";
-		}
-	}
-	print "
\n"; - print "
"; - git_footer_html(); -} elsif ($action eq "log" || $action eq "rss") { - open my $fd, "-|", "$gitbin/rev-list " . git_head($project); - my (@revtree) = map { chomp; $_ } <$fd>; - close $fd; - - if ($action eq "log") { - git_header_html(); - print "
\n"; - print "view "; - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "
\n"; - print "

\n" . - "
\n"; - } elsif ($action eq "rss") { - print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); - print "\n". - "\n"; - print "\n"; - print "$project\n". - " " . $my_url . "/$project/log\n". - "$project log\n". - "en\n"; - } - - for (my $i = 0; $i <= $#revtree; $i++) { - my $commit = $revtree[$i]; - my %co = git_commit($commit); - my %ad = date_str($co{'author_epoch'}); - my $age = time - $co{'committer_epoch'}; - my $age_string; - if ($age > 60*60*24*365*2) { - $age_string = int $age/60/60/24/365; - $age_string .= " years ago"; - } elsif ($age > 60*60*24*365/12*2) { - $age_string = int $age/60/60/24/365/12; - $age_string .= " months ago"; - } elsif ($age > 60*60*24*7*2) { - $age_string = int $age/60/60/24/7; - $age_string .= " weeks ago"; - } elsif ($age > 60*60*24*2) { - $age_string = int $age/60/60/24; - $age_string .= " days ago"; - } elsif ($age > 60*60*2) { - $age_string = int $age/60/60; - $age_string .= " hours ago"; - } elsif ($age > 60*2) { - $age_string = int $age/60; - $age_string .= " minutes ago"; - } - if ($action eq "log") { - if ($time_back > 0 && $age > $time_back*60*60*24) { - if ($i == 0) { - print "
Last change $age_string.

\n"; - } - last; - } - print "\n"; - print "
\n" . - "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "view commit") . "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "view diff") . "
\n" . - "
\n" . - escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]
\n" . - "
\n" . - "
\n"; - my $comment = $co{'comment'}; - foreach my $line (@$comment) { - if ($line =~ m/^(signed-off|acked)-by:/i) { - print '
' . escapeHTML($line) . "
\n"; - } else { - print escapeHTML($line) . "
\n"; - } - } - print "

\n" . - "
\n"; - } elsif ($action eq "rss") { - last if ($i >= 20); - print "\n" . - "\t" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "\n" . - "\t " . $my_url . "?p=$project;a==commit;h=$commit\n" . - "\t"; - my $comment = $co{'comment'}; - foreach my $line (@$comment) { - print escapeHTML($line) . "\n"; - } - print "\t\n" . - "\n"; - } - } - if ($action eq "log") { - git_footer_html(); - } elsif ($action eq "rss") { - print "
"; - } -} elsif ($action eq "commit") { - my %co = git_commit($hash); - my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); - my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); - open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; - my (@difftree) = map { chomp; $_ } <$fd>; - close $fd; - - git_header_html(); - print "
view\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" . - "

\n"; - print "$co{'title'}\n"; - print "
\n"; - print "author      " . escapeHTML($co{'author'}) . "
\n"; - print "author-time " . $ad{'rfc2822'}; - if ($ad{'hour_local'} < 6) { print ""; } - printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); - if ($ad{'hour_local'} < 6 ) { print ""; } - print "
\n"; - print "committer   " . escapeHTML($co{'committer'}) . "
\n"; - print "commit-time " . $ad{'rfc2822'}; - printf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}); - print "
\n"; - print "commit      $hash
\n"; - print "tree        " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "
\n"; - my $parents = $co{'parents'}; - foreach my $par (@$parents) { - print "parent      " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "
\n"; - } - print "
\n"; - print "
\n"; - my $comment = $co{'comment'}; - foreach my $line (@$comment) { - if ($line =~ m/(signed-off|acked)-by:/i) { - print '
' . escapeHTML($line) . "
\n"; - } else { - print escapeHTML($line) . "
\n"; - } - } - print "

\n"; - print "
\n";
-	foreach my $line (@difftree) {
-		# '*100644->100644	blob	9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596	net/ipv4/route.c'
-		# '+100644	blob	4a83ab6cd565d21ab0385bac6643826b83c2fcd4	arch/arm/lib/bitops.h'
-		$line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
-		my $op = $1;
-		my $mode = $2;
-		my $type = $3;
-		my $id = $4;
-		my $file = $5;
-		$mode =~ m/^([0-7]{6})/;
-		my $modestr = mode_str($1);
-		if ($type eq "blob") {
-			if ($op eq "+") {
-				print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$id"}, $file) . " (new)\n";
-			} elsif ($op eq "-") {
-				print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;hp=$id"}, $file) . " (removed)\n";
-			} elsif ($op eq "*") {
-				$id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
-				my $from = $1;
-				my $to = $2;
-				print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, $file) . "\n";
-			}
-		}
-	}
-	print "
\n" . - "
"; - git_footer_html(); -} elsif ($action eq "blobdiff") { - git_header_html(); - print "


\n" . - "
\n";
-	git_diff_html($hash_parent, $hash, $hash_parent, $hash);
-	print "
\n" . - "
"; - git_footer_html(); -} elsif ($action eq "commitdiff") { - my %co = git_commit($hash); - open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; - my (@difftree) = map { chomp; $_ } <$fd>; - close $fd; - - git_header_html(); - print "
view\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" . - "

\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, $co{'title'}) ."\n"; - print "
\n" . - "
\n";
-	foreach my $line (@difftree) {
-		# '*100644->100644	blob	8e5f9bbdf4de94a1bc4b4da8cb06677ce0a57716->8da3a306d0c0c070d87048d14a033df02f40a154	Makefile'
-		$line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
-		my $op = $1;
-		my $mode = $2;
-		my $type = $3;
-		my $id = $4;
-		my $file = $5;
-		if ($type eq "blob") {
-			if ($op eq "+") {
-				git_diff_html("", $file, "", $id);
-			} elsif ($op eq "-") {
-				git_diff_html($file, "", $id, "");
-			} elsif ($op eq "*") {
-				$id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
-				git_diff_html($file, $file, $1, $2);
-			}
-		}
-	}
-	print "
\n"; - print "
"; - git_footer_html(); -} else { - git_header_html(); - print "
\n" . - "

\n"; - print "unknown action\n"; - print "
\n"; - git_footer_html(); -} -- cgit 1.2.3-korg From a59d4afd69e497193ac63c8633431f9b32211b4d Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:15:44 +0200 Subject: v055 --- gitweb.cgi | 66 ++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 017664b8f4..8c46a3a04b 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,42 +14,45 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "053"; -my $projectroot = "/pub/scm"; +my $version = "055"; +my $projectroot = "/home/kay/public_html/pub/scm"; my $defaultprojects = "linux/kernel/git"; -my $gitbin = "/usr/bin"; -my $gittmp = "/tmp/gitweb"; -my $giturl = "/pub/software/scm/cogito"; +my $gitbin = "/home/kay/bin/git"; +my $gittmp = "/tmp"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); -mkdir($gittmp, 0700); - my $project = $cgi->param('p'); my $action = $cgi->param('a'); my $hash = $cgi->param('h'); my $hash_parent = $cgi->param('hp'); my $time_back = $cgi->param('t'); -if (!(defined($time_back))) { - $time_back = 1; -} $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; -# sanitize input -$action =~ s/[^0-9a-zA-Z\.\-]//g; -$hash =~ s/[^0-9a-fA-F]//g; -$hash_parent =~ s/[^0-9a-fA-F]//g; -$time_back =~ s/[^0-9]+//g; +# validate input if (defined($project) && $project =~ /(^|\/)(|\.|\.\.)($|\/)/) { - print $cgi->header(-type=>'text/plain', -status=>'403 Permission denied'); - print "Malformed query, file missing or permission denied\n"; - exit 0; + error_page("403 Permission denied", "Invalid project parameter."); +} +if (defined($action) && !$action =~ m/^[0-9a-zA-Z\.\-]+$/) { + error_page("403 Permission denied", "Invalid action parameter."); +} +if (defined($hash) && !($hash =~ m/^[0-9a-fA-F]{40}$/)) { + error_page("403 Permission denied", "Invalid hash parameter."); +} +if (defined($hash_parent) && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) { + error_page("403 Permission denied", "Invalid parent hash parameter."); +} +if (defined($time_back) && !($time_back =~ m/^[0-9]+$/)) { + error_page("403 Permission denied", "Invalid time parameter."); +} else { + $time_back = 1; } -$project =~ s/|//g; sub git_header_html { - print $cgi->header(-type => 'text/html', -charset => 'utf-8'); -print <header(-type=>'text/html', -charset => 'utf-8', -status=> $status); + print < @@ -104,7 +107,7 @@ print < EOF print "
\n" . - "" . + "" . "\"git\""; if ($defaultprojects ne "") { print $cgi->a({-href => "$my_uri"}, "projects") . " / "; @@ -128,6 +131,18 @@ sub git_footer_html { print "\n"; } +sub error_page { + my $status = shift || "403 Permission denied"; + my $error = shift || "Malformed query, file missing or permission denied"; + git_header_html($status); + print "
\n" . + "

\n"; + print "$error\n"; + print "
\n"; + git_footer_html(); + exit 0; +} + sub git_head { my $path = shift; open my $fd, "$projectroot/$path/HEAD"; @@ -580,10 +595,5 @@ if ($action eq "blob") { print "
"; git_footer_html(); } else { - git_header_html(); - print "
\n" . - "

\n"; - print "unknown action\n"; - print "
\n"; - git_footer_html(); + error_page("403 Forbidden", "unknown action"); } -- cgit 1.2.3-korg From 061cc7cdcfda9527f5afb986e0396e393ed0c9f5 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:15:57 +0200 Subject: v056 --- gitweb.cgi | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 8c46a3a04b..c702c9a2ef 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "055"; +my $version = "056"; my $projectroot = "/home/kay/public_html/pub/scm"; my $defaultprojects = "linux/kernel/git"; my $gitbin = "/home/kay/bin/git"; @@ -31,19 +31,19 @@ $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; # validate input if (defined($project) && $project =~ /(^|\/)(|\.|\.\.)($|\/)/) { - error_page("403 Permission denied", "Invalid project parameter."); + die_error("", "Invalid project parameter."); } if (defined($action) && !$action =~ m/^[0-9a-zA-Z\.\-]+$/) { - error_page("403 Permission denied", "Invalid action parameter."); + die_error("", "Invalid action parameter."); } if (defined($hash) && !($hash =~ m/^[0-9a-fA-F]{40}$/)) { - error_page("403 Permission denied", "Invalid hash parameter."); + die_error("", "Invalid hash parameter."); } if (defined($hash_parent) && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) { - error_page("403 Permission denied", "Invalid parent hash parameter."); + die_error("", "Invalid parent hash parameter."); } if (defined($time_back) && !($time_back =~ m/^[0-9]+$/)) { - error_page("403 Permission denied", "Invalid time parameter."); + die_error("", "Invalid time parameter."); } else { $time_back = 1; } @@ -131,8 +131,8 @@ sub git_footer_html { print "\n"; } -sub error_page { - my $status = shift || "403 Permission denied"; +sub die_error { + my $status = shift || "403 Forbidden"; my $error = shift || "Malformed query, file missing or permission denied"; git_header_html($status); print "
\n" . @@ -145,7 +145,7 @@ sub error_page { sub git_head { my $path = shift; - open my $fd, "$projectroot/$path/HEAD"; + open(my $fd, "$projectroot/$path/HEAD") || die_error("", "Invalid project directory.");; my $head = <$fd>; close $fd; chomp $head; @@ -179,6 +179,7 @@ sub git_commit { $co{'committer_name'} =~ s/ <.*//; } } + if (!defined($co{'tree'})) { die_error("", "Invalid commit object."); } $co{'parents'} = \@parents; $co{'parent'} = $parents[0]; my (@comment) = map { chomp; $_ } <$fd>; @@ -203,7 +204,7 @@ sub git_diff_html { # create tmp from-file if ($from ne "") { $from_tmp = "$gittmp/gitweb_" . $$ . "_from"; - open my $fd2, "> $from_tmp"; + open(my $fd2, "> $from_tmp"); open my $fd, "-|", "$gitbin/cat-file blob $from"; my @file = <$fd>; print $fd2 @file; @@ -317,7 +318,7 @@ if ($action eq "git-logo.png") { # show list of default projects if ($project eq "") { - opendir(my $fd, "$projectroot/$defaultprojects"); + opendir(my $fd, "$projectroot/$defaultprojects") || die_error("", "No projects found."); my (@users) = sort grep(!/^\./, readdir($fd)); closedir($fd); git_header_html(); @@ -345,7 +346,7 @@ if ($action eq "") { if ($action eq "blob") { git_header_html(); print "


\n"; - open my $fd, "-|", "$gitbin/cat-file blob $hash"; + open(my $fd, "-|", "$gitbin/cat-file blob $hash"); my $nr; while (my $line = <$fd>) { $nr++; @@ -595,5 +596,5 @@ if ($action eq "blob") { print "
"; git_footer_html(); } else { - error_page("403 Forbidden", "unknown action"); + die_error("", "unknown action"); } -- cgit 1.2.3-korg From d51e902a09f96029b01141b41e297ec7774f55c0 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:16:07 +0200 Subject: v057 --- gitweb.cgi | 54 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index c702c9a2ef..89c3df736f 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "056"; +my $version = "057"; my $projectroot = "/home/kay/public_html/pub/scm"; my $defaultprojects = "linux/kernel/git"; my $gitbin = "/home/kay/bin/git"; @@ -26,6 +26,7 @@ my $project = $cgi->param('p'); my $action = $cgi->param('a'); my $hash = $cgi->param('h'); my $hash_parent = $cgi->param('hp'); +my $file_name = $cgi->param('f'); my $time_back = $cgi->param('t'); $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; @@ -33,6 +34,9 @@ $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; if (defined($project) && $project =~ /(^|\/)(|\.|\.\.)($|\/)/) { die_error("", "Invalid project parameter."); } +if (defined($file_name) && $file_name =~ /(^|\/)(|\.|\.\.)($|\/)/) { + die_error("", "Invalid file parameter."); +} if (defined($action) && !$action =~ m/^[0-9a-zA-Z\.\-]+$/) { die_error("", "Invalid action parameter."); } @@ -44,8 +48,6 @@ if (defined($hash_parent) && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) { } if (defined($time_back) && !($time_back =~ m/^[0-9]+$/)) { die_error("", "Invalid time parameter."); -} else { - $time_back = 1; } sub git_header_html { @@ -339,10 +341,14 @@ if ($project eq "") { exit; } -if ($action eq "") { +if (!defined($action)) { $action = "log"; } +if (!defined($time_back)) { + $time_back = 1; +} + if ($action eq "blob") { git_header_html(); print "


\n"; @@ -384,7 +390,7 @@ if ($action eq "blob") { git_footer_html(); } elsif ($action eq "log" || $action eq "rss") { open my $fd, "-|", "$gitbin/rev-list " . git_head($project); - my (@revtree) = map { chomp; $_ } <$fd>; + my (@revlist) = map { chomp; $_ } <$fd>; close $fd; if ($action eq "log") { @@ -409,8 +415,8 @@ if ($action eq "blob") { "en\n"; } - for (my $i = 0; $i <= $#revtree; $i++) { - my $commit = $revtree[$i]; + for (my $i = 0; $i <= $#revlist; $i++) { + my $commit = $revlist[$i]; my %co = git_commit($commit); my %ad = date_str($co{'author_epoch'}); my $age = time - $co{'committer_epoch'}; @@ -466,7 +472,7 @@ if ($action eq "blob") { last if ($i >= 20); print "\n" . "\t" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "\n" . - "\t " . $my_url . "?p=$project;a==commit;h=$commit\n" . + "\t " . $my_url . "?p=$project;a=commit;h=$commit\n" . "\t"; my $comment = $co{'comment'}; foreach my $line (@$comment) { @@ -544,7 +550,8 @@ if ($action eq "blob") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $from = $1; my $to = $2; - print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, $file) . "\n"; + print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, $file) . " (" . + $cgi->a({-href => "$my_uri?p=$project;a=filerevision;h=$hash;f=$file"}, "history") . ")\n"; } } } @@ -595,6 +602,35 @@ if ($action eq "blob") { print "
\n"; print "
"; git_footer_html(); +} elsif ($action eq "filerevision") { + open my $fd, "-|", "$gitbin/rev-list $hash"; + my (@revlist) = map { chomp; $_ } <$fd>; + close $fd; + + git_header_html(); + print "
\n" . + "
\n";
+	foreach my $rev (@revlist) {
+		my %co = git_commit($rev);
+		my $parents  = $co{'parents'};
+		foreach my $parent (@$parents) {
+			open $fd, "-|", "$gitbin/diff-tree -r $parent $rev $file_name";
+			my (@difftree) = map { chomp; $_ } <$fd>;
+			close $fd;
+
+			foreach my $line (@difftree) {
+				$line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
+				my $file = $5;
+				if ($file eq $file_name) {
+					print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, $rev) . " (" . $co{'title'} .")\n";
+					last;
+				}
+			}
+		}
+	}
+	print "
\n"; + print "
"; + git_footer_html(); } else { die_error("", "unknown action"); } -- cgit 1.2.3-korg From 2ae100df543b8c287e72bcc470b3b3b1de70d3d7 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:17:00 +0200 Subject: v062 --- gitweb.cgi | 99 ++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 35 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 89c3df736f..045384d53b 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "057"; +my $version = "062"; my $projectroot = "/home/kay/public_html/pub/scm"; my $defaultprojects = "linux/kernel/git"; my $gitbin = "/home/kay/bin/git"; @@ -79,6 +79,10 @@ sub git_header_html { } div.page_footer_text { float:left; color:#888888; font-size:10px;} div.page_body { margin:0px 25px; padding:8px; clear:both; border: solid #d9d8d1; border-width:0px 1px; } + div.title { + display:block; margin:0px 25px; padding:8px; clear:both; + font-weight:bold; background-color: #d9d8d1; color:#000000; + } a.log_title { display:block; margin:0px 25px; padding:8px; clear:both; font-weight:bold; background-color: #d9d8d1; text-decoration:none; color:#000000; @@ -188,6 +192,28 @@ sub git_commit { $co{'comment'} = \@comment; $co{'title'} = $comment[0]; close $fd; + + my $age = time - $co{'committer_epoch'}; + $co{'age'} = $age; + if ($age > 60*60*24*365*2) { + $co{'age_string'} = (int $age/60/60/24/365); + $co{'age_string'} .= " years ago"; + } elsif ($age > 60*60*24*365/12*2) { + $co{'age_string'} = int $age/60/60/24/365/12; + $co{'age_string'} .= " months ago"; + } elsif ($age > 60*60*24*7*2) { + $co{'age_string'} = int $age/60/60/24/7; + $co{'age_string'} .= " weeks ago"; + } elsif ($age > 60*60*24*2) { + $co{'age_string'} = int $age/60/60/24; + $co{'age_string'} .= " days ago"; + } elsif ($age > 60*60*2) { + $co{'age_string'} = int $age/60/60; + $co{'age_string'} .= " hours ago"; + } elsif ($age > 60*2) { + $co{'age_string'} = int $age/60; + $co{'age_string'} .= " minutes ago"; + } return %co; } @@ -351,6 +377,9 @@ if (!defined($time_back)) { if ($action eq "blob") { git_header_html(); + print "
\n"; + print "

\n"; + print "
$hash
\n"; print "


\n"; open(my $fd, "-|", "$gitbin/cat-file blob $hash"); my $nr; @@ -370,6 +399,9 @@ if ($action eq "blob") { my (@entries) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); + print "
\n"; + print "

\n"; + print "
$hash
\n"; print "
\n"; print "
\n";
 	foreach my $line (@entries) {
@@ -380,9 +412,9 @@ if ($action eq "blob") {
 		my $t_hash = $3;
 		my $t_name = $4;
 		if ($t_type eq "blob") {
-			print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name) . "\n";
+			print mode_str($t_mode). " $t_name (" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, "view") . ")\n";
 		} elsif ($t_type eq "tree") {
-			print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, $t_name) . "\n";
+			print mode_str($t_mode). " $t_name (" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, "view") . ")\n";
 		}
 	}
 	print "
\n"; @@ -419,36 +451,15 @@ if ($action eq "blob") { my $commit = $revlist[$i]; my %co = git_commit($commit); my %ad = date_str($co{'author_epoch'}); - my $age = time - $co{'committer_epoch'}; - my $age_string; - if ($age > 60*60*24*365*2) { - $age_string = int $age/60/60/24/365; - $age_string .= " years ago"; - } elsif ($age > 60*60*24*365/12*2) { - $age_string = int $age/60/60/24/365/12; - $age_string .= " months ago"; - } elsif ($age > 60*60*24*7*2) { - $age_string = int $age/60/60/24/7; - $age_string .= " weeks ago"; - } elsif ($age > 60*60*24*2) { - $age_string = int $age/60/60/24; - $age_string .= " days ago"; - } elsif ($age > 60*60*2) { - $age_string = int $age/60/60; - $age_string .= " hours ago"; - } elsif ($age > 60*2) { - $age_string = int $age/60; - $age_string .= " minutes ago"; - } if ($action eq "log") { - if ($time_back > 0 && $age > $time_back*60*60*24) { + if ($time_back > 0 && $co{'age'} > $time_back*60*60*24) { if ($i == 0) { - print "
Last change $age_string.

\n"; + print "
Last change " . $co{'age_string'} . ".

\n"; } last; } print "
\n" . - "" . $age_string . "\n" . escapeHTML($co{'title'}) . "\n" . + "" . $co{'age_string'} . "\n" . escapeHTML($co{'title'}) . "\n" . "
\n"; print "
\n" . "
\n" . @@ -498,7 +509,7 @@ if ($action eq "blob") { git_header_html(); print "
view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . "\n" . "

\n"; print "$co{'title'}\n"; print "
\n"; @@ -543,15 +554,19 @@ if ($action eq "blob") { my $modestr = mode_str($1); if ($type eq "blob") { if ($op eq "+") { - print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$id"}, $file) . " (new)\n"; + print "$modestr $file" . "[new] " . + "(" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "view") . ")\n"; } elsif ($op eq "-") { - print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;hp=$id"}, $file) . " (removed)\n"; + print "$modestr $file" . "[removed] " . + "(" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "view") . ")\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; my $from = $1; my $to = $2; - print "$modestr " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, $file) . " (" . - $cgi->a({-href => "$my_uri?p=$project;a=filerevision;h=$hash;f=$file"}, "history") . ")\n"; + print "$modestr $file " . + "(" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to"}, "view") . ")" . + "(" . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, "diff") . ")" . + "(" . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . ")\n"; } } } @@ -560,6 +575,9 @@ if ($action eq "blob") { git_footer_html(); } elsif ($action eq "blobdiff") { git_header_html(); + print "
\n"; + print "

\n"; + print "
$hash vs $hash_parent
\n"; print "


\n" . "
\n";
 	git_diff_html($hash_parent, $hash, $hash_parent, $hash);
@@ -575,7 +593,7 @@ if ($action eq "blob") {
 	git_header_html();
 	print "
view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diff") . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . "\n" . "

\n"; print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, $co{'title'}) ."\n"; print "
\n" . @@ -602,17 +620,24 @@ if ($action eq "blob") { print "
\n"; print "
"; git_footer_html(); -} elsif ($action eq "filerevision") { +} elsif ($action eq "history") { + if (!(defined($hash))) { + $hash = git_head($project); + } open my $fd, "-|", "$gitbin/rev-list $hash"; my (@revlist) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); + print "
\n"; + print "

\n"; + print "
$file_name
\n"; print "
\n" . "
\n";
 	foreach my $rev (@revlist) {
 		my %co = git_commit($rev);
 		my $parents  = $co{'parents'};
+		my $found = 0;
 		foreach my $parent (@$parents) {
 			open $fd, "-|", "$gitbin/diff-tree -r $parent $rev $file_name";
 			my (@difftree) = map { chomp; $_ } <$fd>;
@@ -622,11 +647,15 @@ if ($action eq "blob") {
 				$line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/;
 				my $file = $5;
 				if ($file eq $file_name) {
-					print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, $rev) . " (" . $co{'title'} .")\n";
+					$found = 1;
 					last;
 				}
 			}
 		}
+		if ($found) {
+			print $co{'age_string'} . "\t " . $co{'author_name'} . "  - " . $co{'title'} .
+			      " (" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "view") .")\n";
+		}
 	}
 	print "
\n"; print "
"; -- cgit 1.2.3-korg From b51103f3cd4f1a08f5c26f5f6cd835dd2e6ead13 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:17:09 +0200 Subject: v063 --- gitweb.cgi | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 045384d53b..4b891fd827 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,14 +14,16 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "062"; -my $projectroot = "/home/kay/public_html/pub/scm"; +my $version = "063"; +my $projectroot = "/pub/scm"; my $defaultprojects = "linux/kernel/git"; -my $gitbin = "/home/kay/bin/git"; -my $gittmp = "/tmp"; +my $gitbin = "/usr/bin"; +my $gittmp = "/tmp/gitweb"; +my $giturl = "/pub/software/scm/cogito"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); +mkdir($gittmp, 0700); my $project = $cgi->param('p'); my $action = $cgi->param('a'); my $hash = $cgi->param('h'); @@ -113,7 +115,7 @@ sub git_header_html { EOF print "
\n" . - "" . + "" . "\"git\""; if ($defaultprojects ne "") { print $cgi->a({-href => "$my_uri"}, "projects") . " / "; -- cgit 1.2.3-korg From 664f4cc5eba8c6fab56e6ab112f295d5ef26316e Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:17:19 +0200 Subject: v064 --- gitweb.cgi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 4b891fd827..61fc23f060 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "063"; +my $version = "064"; my $projectroot = "/pub/scm"; my $defaultprojects = "linux/kernel/git"; my $gitbin = "/usr/bin"; @@ -142,6 +142,9 @@ sub git_footer_html { sub die_error { my $status = shift || "403 Forbidden"; my $error = shift || "Malformed query, file missing or permission denied"; + + $project = ""; + $action = ""; git_header_html($status); print "
\n" . "

\n"; @@ -522,7 +525,7 @@ if ($action eq "blob") { if ($ad{'hour_local'} < 6 ) { print ""; } print "
\n"; print "committer   " . escapeHTML($co{'committer'}) . "
\n"; - print "commit-time " . $ad{'rfc2822'}; + print "commit-time " . $cd{'rfc2822'}; printf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}); print "
\n"; print "commit      $hash
\n"; -- cgit 1.2.3-korg From 9cd3d988730949f7d1cc6f6c96417bf5aa845110 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:17:42 +0200 Subject: v070 --- gitweb.cgi | 211 +++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 115 insertions(+), 96 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 61fc23f060..80a883d80f 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,15 +14,21 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "064"; +my $version = "070"; my $projectroot = "/pub/scm"; -my $defaultprojects = "linux/kernel/git"; +my $home_link = "/git"; my $gitbin = "/usr/bin"; my $gittmp = "/tmp/gitweb"; -my $giturl = "/pub/software/scm/cogito"; +my $logo_link = "/pub/software/scm/cogito"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); +# remove # +my $projectroot = "/home/kay/public_html/pub/scm"; +my $home_link = "/~kay/git"; +my $logo_link = "/~kay/pub/software/scm/cogito"; +# remove # + mkdir($gittmp, 0700); my $project = $cgi->param('p'); my $action = $cgi->param('a'); @@ -33,8 +39,13 @@ my $time_back = $cgi->param('t'); $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; # validate input -if (defined($project) && $project =~ /(^|\/)(|\.|\.\.)($|\/)/) { - die_error("", "Invalid project parameter."); +if (defined($project)) { + if ($project =~ /(^|\/)(|\.|\.\.)($|\/)/) { + die_error("", "Invalid project parameter."); + } + if (!(-d "$projectroot/$project")) { + die_error("", "No such project."); + } } if (defined($file_name) && $file_name =~ /(^|\/)(|\.|\.\.)($|\/)/) { die_error("", "Invalid file parameter."); @@ -80,26 +91,18 @@ sub git_header_html { clear:both; background-color: #d9d8d1; } div.page_footer_text { float:left; color:#888888; font-size:10px;} - div.page_body { margin:0px 25px; padding:8px; clear:both; border: solid #d9d8d1; border-width:0px 1px; } + div.page_body { margin:0px 25px; padding:8px; clear:both; border:solid #d9d8d1; border-width:0px 1px; } div.title { display:block; margin:0px 25px; padding:8px; clear:both; font-weight:bold; background-color: #d9d8d1; color:#000000; } a.log_title { - display:block; margin:0px 25px; padding:8px; clear:both; + display:block; margin:0px 25px; padding:6px; clear:both; font-weight:bold; background-color: #d9d8d1; text-decoration:none; color:#000000; } a.log_title:hover { background-color: #c9c8c1; } - a.xml_logo { float:right; border:1px solid; - line-height:15px; - border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; - color:#ffffff; background-color:#ff6600; - font-weight:bold; font-family:sans-serif; text-align:center; - font-size:11px; display:block; text-decoration:none; - } - a.xml_logo:hover { background-color:#ee5500; } div.log_head { - margin:0px 25px; min-height: 30px; padding:8px; clear:both; + margin:0px 25px; padding:8px; clear:both; border: solid #d9d8d1; border-width:0px 1px; font-family:monospace; background-color: #edece6; } @@ -108,18 +111,28 @@ sub git_header_html { border:solid #d9d8d1; border-width:0px 1px; } span.log_age { position:relative; float:left; width:142px; } - div.log_functions { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } - div.signed_off { color: #a9a8a1; } + div.log_link { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } + div.list { + display:block; margin:0px 25px; padding:2px 8px; border:solid #d9d8d1; border-width:0px 1px; + font-family:monospace; background-color: #edece6; + } + div.link { margin:0px 25px; padding:4px 8px; border:solid #d9d8d1; border-width:0px 1px; font-family:sans-serif; font-size:10px; } + a.xml_logo { float:right; border:1px solid; + line-height:15px; + border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; + color:#ffffff; background-color:#ff6600; + font-weight:bold; font-family:sans-serif; text-align:center; + font-size:11px; display:block; text-decoration:none; + } + a.xml_logo:hover { background-color:#ee5500; } EOF print "
\n" . - "" . + "" . "\"git\""; - if ($defaultprojects ne "") { - print $cgi->a({-href => "$my_uri"}, "projects") . " / "; - } + print $cgi->a({-href => "$my_uri"}, "projects") . " / "; if ($project ne "") { print $cgi->a({-href => "$my_uri?p=$project;a=log"}, $project); } @@ -135,8 +148,9 @@ sub git_footer_html { if ($project ne '') { print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "XML") . "\n"; } - print "
"; - print "\n"; + print "
" . + "" . + ""; } sub die_error { @@ -168,7 +182,7 @@ sub git_commit { my %co; my @parents; - open my $fd, "-|", "$gitbin/cat-file commit $commit"; + open my $fd, "-|", "$gitbin/git-cat-file commit $commit"; while (my $line = <$fd>) { chomp($line); last if $line eq ""; @@ -238,7 +252,7 @@ sub git_diff_html { if ($from ne "") { $from_tmp = "$gittmp/gitweb_" . $$ . "_from"; open(my $fd2, "> $from_tmp"); - open my $fd, "-|", "$gitbin/cat-file blob $from"; + open my $fd, "-|", "$gitbin/git-cat-file blob $from"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -250,7 +264,7 @@ sub git_diff_html { if ($to ne "") { $to_tmp = "$gittmp/gitweb_" . $$ . "_to"; open my $fd2, "> $to_tmp"; - open my $fd, "-|", "$gitbin/cat-file blob $to"; + open my $fd, "-|", "$gitbin/git-cat-file blob $to"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -294,13 +308,13 @@ sub mode_str { my $perms = oct shift; my $modestr; if ($perms & 040000) { - $modestr .= 'drwxrwxr-x'; + $modestr .= 'drwxr-xr-x'; } else { # git cares only about the executable bit if ($perms & 0100) { - $modestr .= '-rwxrwxr-x'; + $modestr .= '-rwxr-xr-x'; } else { - $modestr .= '-rw-rw-r--'; + $modestr .= '-rw-r--r--'; }; } return $modestr; @@ -349,26 +363,8 @@ if ($action eq "git-logo.png") { exit; } -# show list of default projects -if ($project eq "") { - opendir(my $fd, "$projectroot/$defaultprojects") || die_error("", "No projects found."); - my (@users) = sort grep(!/^\./, readdir($fd)); - closedir($fd); - git_header_html(); - print "
\n"; - print "

\n"; - foreach my $user (@users) { - opendir($fd, "$projectroot/$defaultprojects/$user"); - my (@repos) = sort grep(/\.git$/, readdir($fd)); - closedir($fd); - foreach my $repo (@repos) { - if (-e "$projectroot/$defaultprojects/$user/$repo/HEAD") { - print $cgi->a({-href => "$my_uri?p=$defaultprojects/$user/$repo;a=log"}, "$defaultprojects/$user/$repo") . "
\n"; - } - } - } - print "
"; - git_footer_html(); +if (!defined($project)) { + print $cgi->redirect($home_link); exit; } @@ -385,22 +381,22 @@ if ($action eq "blob") { print "
\n"; print "

\n"; print "
$hash
\n"; - print "


\n"; - open(my $fd, "-|", "$gitbin/cat-file blob $hash"); + print "
\n";
+	open(my $fd, "-|", "$gitbin/git-cat-file blob $hash");
 	my $nr;
 	while (my $line = <$fd>) {
 		$nr++;
 		printf "%4i\t%s", $nr, escapeHTML($line);;
 	}
 	close $fd;
-	print "

\n"; + print "
\n"; print "
"; git_footer_html(); } elsif ($action eq "tree") { if ($hash eq "") { $hash = git_head($project); } - open my $fd, "-|", "$gitbin/ls-tree $hash"; + open my $fd, "-|", "$gitbin/git-ls-tree $hash"; my (@entries) = map { chomp; $_ } <$fd>; close $fd; git_header_html(); @@ -417,16 +413,16 @@ if ($action eq "blob") { my $t_hash = $3; my $t_name = $4; if ($t_type eq "blob") { - print mode_str($t_mode). " $t_name (" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, "view") . ")\n"; + print mode_str($t_mode). " $t_name " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash", -class => "link"}, "view") . "\n"; } elsif ($t_type eq "tree") { - print mode_str($t_mode). " $t_name (" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, "view") . ")\n"; + print mode_str($t_mode). " $t_name " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash", -class => "link"}, "view") . "\n"; } } print "
\n"; print "
"; git_footer_html(); } elsif ($action eq "log" || $action eq "rss") { - open my $fd, "-|", "$gitbin/rev-list " . git_head($project); + open my $fd, "-|", "$gitbin/git-rev-list " . git_head($project); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; @@ -463,26 +459,24 @@ if ($action eq "blob") { } last; } - print "
\n" . - "" . $co{'age_string'} . "\n" . escapeHTML($co{'title'}) . "\n" . + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "log_title"}, + "" . $co{'age_string'} . "" . escapeHTML($co{'title'})) . "\n" . "
\n"; print "
\n" . - "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "view commit") . "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "view diff") . "
\n" . + "
\n" . + "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . "
\n" . "
\n" . escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]
\n" . "
\n" . "
\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { - if ($line =~ m/^(signed-off|acked)-by:/i) { - print '
' . escapeHTML($line) . "
\n"; - } else { - print escapeHTML($line) . "
\n"; - } + last if ($line =~ m/^(signed-off|acked)-by:/i); + print escapeHTML($line) . "
\n"; } - print "

\n" . + print "
\n" . "
\n"; } elsif ($action eq "rss") { last if ($i >= 20); @@ -507,7 +501,7 @@ if ($action eq "blob") { my %co = git_commit($hash); my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); - open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; + open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -516,7 +510,9 @@ if ($action eq "blob") { $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . "\n" . "

\n"; - print "$co{'title'}\n"; + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . + "
\n"; print "
\n"; print "author      " . escapeHTML($co{'author'}) . "
\n"; print "author-time " . $ad{'rfc2822'}; @@ -539,51 +535,70 @@ if ($action eq "blob") { my $comment = $co{'comment'}; foreach my $line (@$comment) { if ($line =~ m/(signed-off|acked)-by:/i) { - print '
' . escapeHTML($line) . "
\n"; + print "" . escapeHTML($line) . "
\n"; } else { print escapeHTML($line) . "
\n"; } } - print "

\n"; - print "
\n";
+	print "

\n" . + "
\n"; foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h' + # '*100664->100644 blob b1a8e3dd5556b61dd771d32307c6ee5d7150fa43->b1a8e3dd5556b61dd771d32307c6ee5d7150fa43 show-files.c' + # '*100664->100644 blob d08e895238bac36d8220586fdc28c27e1a7a76d3->d08e895238bac36d8220586fdc28c27e1a7a76d3 update-cache.c' $line =~ m/^(.)(.*)\t(.*)\t(.*)\t(.*)$/; my $op = $1; my $mode = $2; my $type = $3; my $id = $4; my $file = $5; - $mode =~ m/^([0-7]{6})/; - my $modestr = mode_str($1); + my $mode_chng = ""; if ($type eq "blob") { if ($op eq "+") { - print "$modestr $file" . "[new] " . - "(" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "view") . ")\n"; + print "
\n" . + "$file [new]\n" . + "
"; + print "
\n" . + "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "

\n" . + "
\n"; } elsif ($op eq "-") { - print "$modestr $file" . "[removed] " . - "(" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "view") . ")\n"; + print "
\n" . + "$file [removed]\n" . + "
"; + print "
\n" . + "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "

\n" . + "
\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; - my $from = $1; - my $to = $2; - print "$modestr $file " . - "(" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to"}, "view") . ")" . - "(" . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to;hp=$from"}, "diff") . ")" . - "(" . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . ")\n"; + my $from_id = $1; + my $to_id = $2; + $mode =~ m/^([0-7]{6})->([0-7]{6})$/; + my $from_mode = $1; + my $to_mode = $2; + print "
\n"; + print $file; + if ($from_mode != $to_mode) { + print " [chmod $mode]"; + } + print "\n
\n"; + print "
\n" . + "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, "file") . " | "; + if ($to_id ne $from_id) { + print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id"}, "diff") . " | "; + } + print $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "

\n" . + "
\n"; } } } - print "
\n" . - "
\n"; git_footer_html(); } elsif ($action eq "blobdiff") { git_header_html(); print "
\n"; print "

\n"; print "
$hash vs $hash_parent
\n"; - print "


\n" . + print "
\n" . "
\n";
 	git_diff_html($hash_parent, $hash, $hash_parent, $hash);
 	print "
\n" . @@ -591,7 +606,7 @@ if ($action eq "blob") { git_footer_html(); } elsif ($action eq "commitdiff") { my %co = git_commit($hash); - open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; + open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -600,7 +615,9 @@ if ($action eq "blob") { $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . "\n" . "

\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, $co{'title'}) ."\n"; + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . + "
\n"; print "
\n" . "
\n";
 	foreach my $line (@difftree) {
@@ -618,7 +635,9 @@ if ($action eq "blob") {
 				git_diff_html($file, "", $id, "");
 			} elsif ($op eq "*") {
 				$id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
-				git_diff_html($file, $file, $1, $2);
+				if ($1 ne $2) {
+					git_diff_html($file, $file, $1, $2);
+				}
 			}
 		}
 	}
@@ -629,14 +648,14 @@ if ($action eq "blob") {
 	if (!(defined($hash))) {
 		$hash = git_head($project);
 	}
-	open my $fd, "-|", "$gitbin/rev-list $hash";
+	open my $fd, "-|", "$gitbin/git-rev-list $hash";
 	my (@revlist) = map { chomp; $_ } <$fd>;
 	close $fd;
 
 	git_header_html();
 	print "
\n"; print "

\n"; - print "
$file_name
\n"; + print "
". escapeHTML($file_name) . "
\n"; print "
\n" . "
\n";
 	foreach my $rev (@revlist) {
@@ -644,7 +663,7 @@ if ($action eq "blob") {
 		my $parents  = $co{'parents'};
 		my $found = 0;
 		foreach my $parent (@$parents) {
-			open $fd, "-|", "$gitbin/diff-tree -r $parent $rev $file_name";
+			open $fd, "-|", "$gitbin/git-diff-tree -r $parent $rev $file_name";
 			my (@difftree) = map { chomp; $_ } <$fd>;
 			close $fd;
 
@@ -658,8 +677,8 @@ if ($action eq "blob") {
 			}
 		}
 		if ($found) {
-			print $co{'age_string'} . "\t " . $co{'author_name'} . "  - " . $co{'title'} .
-			      " (" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "view") .")\n";
+			print $co{'age_string'} . "\t " . $co{'author_name'} . "  - " . $co{'title'} . " " .
+			      $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev", -class => "link"}, "view") ."\n";
 		}
 	}
 	print "
\n"; -- cgit 1.2.3-korg From 820e4f6b6b4141b779c140d08e46fde0aa30117c Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:17:50 +0200 Subject: v071 --- gitweb.cgi | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 80a883d80f..4363621f91 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "070"; +my $version = "071"; my $projectroot = "/pub/scm"; my $home_link = "/git"; my $gitbin = "/usr/bin"; @@ -657,7 +657,8 @@ if ($action eq "blob") { print "

\n"; print "
". escapeHTML($file_name) . "
\n"; print "
\n" . - "
\n";
+	      "
\n" . + "
\n"; foreach my $rev (@revlist) { my %co = git_commit($rev); my $parents = $co{'parents'}; @@ -677,12 +678,16 @@ if ($action eq "blob") { } } if ($found) { - print $co{'age_string'} . "\t " . $co{'author_name'} . " - " . $co{'title'} . " " . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev", -class => "link"}, "view") ."\n"; + print "
\n" . + $co{'age_string'} . "" . $co{'title'} . "\n" . + "
"; + print "
\n" . + "view " . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "commit") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$rev"}, "tree") . "

\n" . + "
\n"; } } - print "
\n"; - print "
"; git_footer_html(); } else { die_error("", "unknown action"); -- cgit 1.2.3-korg From 1207151d40bec83569fb5bb67c0aee6a1a36c353 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:18:01 +0200 Subject: v073 --- gitweb.cgi | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 4363621f91..fbe3a48b49 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "071"; +my $version = "073"; my $projectroot = "/pub/scm"; my $home_link = "/git"; my $gitbin = "/usr/bin"; @@ -112,17 +112,18 @@ sub git_header_html { } span.log_age { position:relative; float:left; width:142px; } div.log_link { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } - div.list { - display:block; margin:0px 25px; padding:2px 8px; border:solid #d9d8d1; border-width:0px 1px; - font-family:monospace; background-color: #edece6; + a.list { + display:block; margin:0px 25px; padding:4px; border:solid #d9d8d1; border-width:0px 1px; + font-weight:bold; background-color: #edece6; text-decoration:none; color:#000000; } + a.list:hover { background-color: #d9d8d1; } div.link { margin:0px 25px; padding:4px 8px; border:solid #d9d8d1; border-width:0px 1px; font-family:sans-serif; font-size:10px; } a.xml_logo { float:right; border:1px solid; line-height:15px; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; color:#ffffff; background-color:#ff6600; font-weight:bold; font-family:sans-serif; text-align:center; - font-size:11px; display:block; text-decoration:none; + font-size:10px; display:block; text-decoration:none; } a.xml_logo:hover { background-color:#ee5500; } @@ -413,9 +414,9 @@ if ($action eq "blob") { my $t_hash = $3; my $t_name = $4; if ($t_type eq "blob") { - print mode_str($t_mode). " $t_name " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash", -class => "link"}, "view") . "\n"; + print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name) . "\n"; } elsif ($t_type eq "tree") { - print mode_str($t_mode). " $t_name " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash", -class => "link"}, "view") . "\n"; + print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, $t_name) . "\n"; } } print "\n"; @@ -508,7 +509,8 @@ if ($action eq "blob") { git_header_html(); print "
view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . "

\n"; print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . @@ -557,17 +559,20 @@ if ($action eq "blob") { if ($type eq "blob") { if ($op eq "+") { print "
\n" . - "$file [new]\n" . + "$file [new]\n" . "
"; print "
\n" . - "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "

\n" . + "view " . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "

\n" . "
\n"; } elsif ($op eq "-") { print "
\n" . "$file [removed]\n" . "
"; print "
\n" . - "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "

\n" . + "view " . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "

\n" . "
\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; @@ -576,18 +581,19 @@ if ($action eq "blob") { $mode =~ m/^([0-7]{6})->([0-7]{6})$/; my $from_mode = $1; my $to_mode = $2; - print "
\n"; - print $file; + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id", -class => "list"}, $file) . "\n"; if ($from_mode != $to_mode) { print " [chmod $mode]"; } print "\n
\n"; print "
\n" . - "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, "file") . " | "; + "view "; if ($to_id ne $from_id) { print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id"}, "diff") . " | "; } - print $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "

\n" . + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, "file") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "

\n" . "
\n"; } } @@ -613,7 +619,8 @@ if ($action eq "blob") { git_header_html(); print "
view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . "

\n"; print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . @@ -678,9 +685,10 @@ if ($action eq "blob") { } } if ($found) { - print "
\n" . - $co{'age_string'} . "" . $co{'title'} . "\n" . - "
"; + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev", -class => "list"}, + "" . $co{'age_string'} . "" . escapeHTML($co{'title'})) . "\n" . + "
\n"; print "
\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "commit") . " | " . -- cgit 1.2.3-korg From d63577da05b8994f97bba210aa5816848c1c03a5 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:18:13 +0200 Subject: v077 --- gitweb.cgi | 101 +++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 65 insertions(+), 36 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index fbe3a48b49..f96013fd80 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "073"; +my $version = "078"; my $projectroot = "/pub/scm"; my $home_link = "/git"; my $gitbin = "/usr/bin"; @@ -81,43 +81,45 @@ sub git_header_html { a:active { color:#880000; } div.page_header { margin:15px 25px 0px; height:25px; padding:8px; - font-size:18px; clear:both; font-weight:bold; background-color: #d9d8d1; + font-size:18px; font-weight:bold; background-color:#d9d8d1; } div.page_header a:visited { color:#0000cc; } - div.page_nav { margin:0px 25px; padding:8px; clear:both; border:solid #d9d8d1; border-width:0px 1px; } + div.page_header a:hover { color:#880000; } + div.page_nav { margin:0px 25px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } div.page_nav a:visited { color:#0000cc; } div.page_footer { margin:0px 25px 15px; height:17px; padding:4px; padding-left:8px; - clear:both; background-color: #d9d8d1; + background-color: #d9d8d1; } div.page_footer_text { float:left; color:#888888; font-size:10px;} - div.page_body { margin:0px 25px; padding:8px; clear:both; border:solid #d9d8d1; border-width:0px 1px; } + div.page_body { margin:0px 25px; padding:8px; border:solid #d9d8d1; border-width:0px 1px; } div.title { - display:block; margin:0px 25px; padding:8px; clear:both; - font-weight:bold; background-color: #d9d8d1; color:#000000; + display:block; margin:0px 25px; padding:8px; + font-weight:bold; background-color:#d9d8d1; color:#000000; } a.log_title { - display:block; margin:0px 25px; padding:6px; clear:both; - font-weight:bold; background-color: #d9d8d1; text-decoration:none; color:#000000; + display:block; margin:0px 25px; padding:6px; + font-weight:bold; background-color:#d9d8d1; text-decoration:none; color:#000000; } a.log_title:hover { background-color: #c9c8c1; } div.log_head { - margin:0px 25px; padding:8px; clear:both; + margin:0px 25px; padding:8px; border: solid #d9d8d1; border-width:0px 1px; font-family:monospace; background-color: #edece6; } div.log_body { - margin:0px 25px; padding:8px; padding-left:150px; clear:both; + margin:0px 25px; padding:8px; padding-left:150px; border:solid #d9d8d1; border-width:0px 1px; } span.log_age { position:relative; float:left; width:142px; } div.log_link { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } - a.list { - display:block; margin:0px 25px; padding:4px; border:solid #d9d8d1; border-width:0px 1px; - font-weight:bold; background-color: #edece6; text-decoration:none; color:#000000; + div.list { + display:block; margin:0px 25px; padding:2px 8px 0px; border:solid #d9d8d1; border-width:1px 1px 0px 1px; + font-weight:bold; text-decoration:none; color:#000000; } - a.list:hover { background-color: #d9d8d1; } - div.link { margin:0px 25px; padding:4px 8px; border:solid #d9d8d1; border-width:0px 1px; font-family:sans-serif; font-size:10px; } + div.list a { color:#000000; text-decoration:none; } + div.link { font-weight:normal; font-family:sans-serif; font-size:10px; border:solid #d9d8d1; border-width:1px 1px 0px 1px; } + a.view { display:inline; font-size:24px; } a.xml_logo { float:right; border:1px solid; line-height:15px; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; @@ -135,7 +137,7 @@ EOF "\"git\""; print $cgi->a({-href => "$my_uri"}, "projects") . " / "; if ($project ne "") { - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, $project); + print $cgi->a({-href => "$my_uri?p=$project;a=log"}, escapeHTML($project)); } if ($action ne "") { print " / $action"; @@ -205,7 +207,9 @@ sub git_commit { $co{'committer_name'} =~ s/ <.*//; } } - if (!defined($co{'tree'})) { die_error("", "Invalid commit object."); } + if (!defined($co{'tree'})) { + return; + } $co{'parents'} = \@parents; $co{'parent'} = $parents[0]; my (@comment) = map { chomp; $_ } <$fd>; @@ -400,10 +404,23 @@ if ($action eq "blob") { open my $fd, "-|", "$gitbin/git-ls-tree $hash"; my (@entries) = map { chomp; $_ } <$fd>; close $fd; + git_header_html(); - print "
\n"; - print "

\n"; - print "
$hash
\n"; + my %co = git_commit($hash); + if (defined(%co)) { + print "
view\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . + "

\n"; + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . + "
\n"; + } else { + print "
\n"; + print "

\n"; + print "
$hash
\n"; + } print "
\n"; print "
\n";
 	foreach my $line (@entries) {
@@ -500,6 +517,9 @@ if ($action eq "blob") {
 	}
 } elsif ($action eq "commit") {
 	my %co = git_commit($hash);
+	if (!defined(%co)) {
+		die_error("", "Unknown commit object.");
+	}
 	my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
 	my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'});
 	open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash";
@@ -527,7 +547,7 @@ if ($action eq "blob") {
 	printf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'});
 	print "
\n"; print "commit      $hash
\n"; - print "tree        " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'}"}, $co{'tree'}) . "
\n"; + print "tree        " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, $co{'tree'}) . "
\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { print "parent      " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "
\n"; @@ -558,16 +578,18 @@ if ($action eq "blob") { my $mode_chng = ""; if ($type eq "blob") { if ($op eq "+") { - print "
\n" . - "$file [new]\n" . + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id", -class => "list"}, + escapeHTML($file) . " [new]") . "\n" . "
"; print "
\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "

\n" . "
\n"; } elsif ($op eq "-") { - print "
\n" . - "$file [removed]\n" . + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id", -class => "list"}, + escapeHTML($file) . " [removed]") . "\n" . "
"; print "
\n" . "view " . @@ -581,12 +603,14 @@ if ($action eq "blob") { $mode =~ m/^([0-7]{6})->([0-7]{6})$/; my $from_mode = $1; my $to_mode = $2; - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id", -class => "list"}, $file) . "\n"; + my $mode_chnge = ""; if ($from_mode != $to_mode) { - print " [chmod $mode]"; + $mode_chnge = " [chmod $mode]\n"; } - print "\n
\n"; + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id", -class => "list"}, + escapeHTML($file) . $mode_chnge) . "\n" . + "
\n"; print "
\n" . "view "; if ($to_id ne $from_id) { @@ -612,6 +636,9 @@ if ($action eq "blob") { git_footer_html(); } elsif ($action eq "commitdiff") { my %co = git_commit($hash); + if (!defined(%co)) { + die_error("", "Unknown commit object."); + } open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -662,7 +689,9 @@ if ($action eq "blob") { git_header_html(); print "
\n"; print "

\n"; - print "
". escapeHTML($file_name) . "
\n"; + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, escapeHTML($file_name)) . "\n" . + "
\n"; print "
\n" . "
\n" . "
\n"; @@ -685,14 +714,14 @@ if ($action eq "blob") { } } if ($found) { - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev", -class => "list"}, + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "" . $co{'age_string'} . "" . escapeHTML($co{'title'})) . "\n" . - "
\n"; - print "
\n" . + "
\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$rev"}, "tree") . "

\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$rev"}, "tree") . "

\n" . + "
\n" . "
\n"; } } -- cgit 1.2.3-korg From 334538f11d30024de28b4490ed6b006d82fadb80 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:18:30 +0200 Subject: v078 --- gitweb.cgi | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index f96013fd80..fdc018533a 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -113,13 +113,12 @@ sub git_header_html { } span.log_age { position:relative; float:left; width:142px; } div.log_link { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } - div.list { - display:block; margin:0px 25px; padding:2px 8px 0px; border:solid #d9d8d1; border-width:1px 1px 0px 1px; - font-weight:bold; text-decoration:none; color:#000000; + a.list { + display:block; margin:0px 25px; padding:4px; border:solid #d9d8d1; border-width:0px 1px; + font-weight:bold; background-color: #edece6; text-decoration:none; color:#000000; } - div.list a { color:#000000; text-decoration:none; } - div.link { font-weight:normal; font-family:sans-serif; font-size:10px; border:solid #d9d8d1; border-width:1px 1px 0px 1px; } - a.view { display:inline; font-size:24px; } + a.list:hover { background-color: #d9d8d1; } + div.link { margin:0px 25px; padding:4px 8px; border:solid #d9d8d1; border-width:0px 1px; font-family:sans-serif; font-size:10px; } a.xml_logo { float:right; border:1px solid; line-height:15px; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; @@ -580,7 +579,7 @@ if ($action eq "blob") { if ($op eq "+") { print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id", -class => "list"}, - escapeHTML($file) . " [new]") . "\n" . + escapeHTML($file) . " [new]") . "\n" . "
"; print "
\n" . "view " . @@ -589,7 +588,7 @@ if ($action eq "blob") { } elsif ($op eq "-") { print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id", -class => "list"}, - escapeHTML($file) . " [removed]") . "\n" . + escapeHTML($file) . " [removed]") . "\n" . "
"; print "
\n" . "view " . @@ -714,14 +713,14 @@ if ($action eq "blob") { } } if ($found) { - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev", -class => "list"}, "" . $co{'age_string'} . "" . escapeHTML($co{'title'})) . "\n" . - "
\n" . + "
\n"; + print "
\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$rev"}, "tree") . "

\n" . - "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$rev"}, "tree") . "

\n" . "
\n"; } } -- cgit 1.2.3-korg From 927dcec4805b32b1f7252e0c4dea341df166deb0 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:18:44 +0200 Subject: v080 --- gitweb.cgi | 110 +++++++++++++++++++++++++++++++------------------------------ 1 file changed, 56 insertions(+), 54 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index fdc018533a..fa2ba70aad 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "078"; +my $version = "080"; my $projectroot = "/pub/scm"; my $home_link = "/git"; my $gitbin = "/usr/bin"; @@ -97,28 +97,29 @@ sub git_header_html { display:block; margin:0px 25px; padding:8px; font-weight:bold; background-color:#d9d8d1; color:#000000; } - a.log_title { - display:block; margin:0px 25px; padding:6px; - font-weight:bold; background-color:#d9d8d1; text-decoration:none; color:#000000; + a.title { + display:block; margin:0px 25px; padding:6px 8px; + font-weight:bold; background-color:#edece6; text-decoration:none; color:#000000; } - a.log_title:hover { background-color: #c9c8c1; } - div.log_head { - margin:0px 25px; padding:8px; - border: solid #d9d8d1; border-width:0px 1px; font-family:monospace; - background-color: #edece6; + a.title:hover { background-color: #d9d8d1; } + div.title2 { + margin:0px 25px; padding:6px 8px; + border: solid #d9d8d1; border-width:0px 1px 1px; } div.log_body { margin:0px 25px; padding:8px; padding-left:150px; border:solid #d9d8d1; border-width:0px 1px; } - span.log_age { position:relative; float:left; width:142px; } - div.log_link { font-size:10px; font-family:sans-serif; position:relative; float:left; width:142px; } - a.list { - display:block; margin:0px 25px; padding:4px; border:solid #d9d8d1; border-width:0px 1px; - font-weight:bold; background-color: #edece6; text-decoration:none; color:#000000; + span.log_age { position:relative; float:left; width:142px; font-style:italic; } + div.log_link { font-size:10px; font-family:sans-serif; font-style:normal; position:relative; float:left; width:142px; } + div.list { + display:block; margin:0px 25px; padding:4px 6px 0px; border:solid #d9d8d1; border-width:1px 1px 0px; + font-weight:bold; } - a.list:hover { background-color: #d9d8d1; } - div.link { margin:0px 25px; padding:4px 8px; border:solid #d9d8d1; border-width:0px 1px; font-family:sans-serif; font-size:10px; } + div.list a { text-decoration:none; color:#000000; } + div.list a:hover { color:#880000; } + div.link { margin:0px 25px; padding:0px 6px; border:solid #d9d8d1; border-width:0px 1px; font-family:sans-serif; font-size:10px; } + td.key { padding-right:10px; } a.xml_logo { float:right; border:1px solid; line-height:15px; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; @@ -413,7 +414,7 @@ if ($action eq "blob") { $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . "

\n"; print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "
\n"; } else { print "
\n"; @@ -477,15 +478,15 @@ if ($action eq "blob") { last; } print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "log_title"}, + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, "" . $co{'age_string'} . "" . escapeHTML($co{'title'})) . "\n" . "
\n"; - print "
\n" . + print "
\n" . "
\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . "
\n" . "
\n" . - escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]
\n" . + "" . escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]
\n" . "
\n" . "
\n"; my $comment = $co{'comment'}; @@ -532,37 +533,41 @@ if ($action eq "blob") { $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . "

\n"; print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "
\n"; - print "
\n"; - print "author      " . escapeHTML($co{'author'}) . "
\n"; - print "author-time " . $ad{'rfc2822'}; - if ($ad{'hour_local'} < 6) { print ""; } + print "
\n" . + ""; + print "\n"; + print "\n"; + print "\n"; + print "\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { - print "parent      " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "
\n"; + print "\n"; } - print "\n"; + print "
author" . escapeHTML($co{'author'}) . "
" . + " " . $ad{'rfc2822'}; + if ($ad{'hour_local'} < 6) { + print ""; + } printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); - if ($ad{'hour_local'} < 6 ) { print ""; } - print "
\n"; - print "committer   " . escapeHTML($co{'committer'}) . "
\n"; - print "commit-time " . $cd{'rfc2822'}; - printf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}); - print "
\n"; - print "commit      $hash
\n"; - print "tree        " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, $co{'tree'}) . "
\n"; + if ($ad{'hour_local'} < 6 ) { + print ""; + } + print "\n" . + "
committer" . escapeHTML($co{'committer'}) . "
" . + " " . $cd{'rfc2822'} . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "\n" . + "
commit$hash
tree" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, $co{'tree'}) . "
parent" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$par"}, $par) . "
\n"; print "
\n"; my $comment = $co{'comment'}; foreach my $line (@$comment) { if ($line =~ m/(signed-off|acked)-by:/i) { - print "" . escapeHTML($line) . "
\n"; + print "" . escapeHTML($line) . "
\n"; } else { print escapeHTML($line) . "
\n"; } } - print "

\n" . - "
\n"; + print "
\n"; foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h' @@ -577,18 +582,18 @@ if ($action eq "blob") { my $mode_chng = ""; if ($type eq "blob") { if ($op eq "+") { - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id", -class => "list"}, - escapeHTML($file) . " [new]") . "\n" . + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, + escapeHTML($file) . " [new]") . "\n" . "
"; print "
\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "

\n" . "
\n"; } elsif ($op eq "-") { - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id", -class => "list"}, - escapeHTML($file) . " [removed]") . "\n" . + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, + escapeHTML($file) . " [removed]") . "\n" . "
"; print "
\n" . "view " . @@ -604,10 +609,10 @@ if ($action eq "blob") { my $to_mode = $2; my $mode_chnge = ""; if ($from_mode != $to_mode) { - $mode_chnge = " [chmod $mode]\n"; + $mode_chnge = " [chmod $mode]\n"; } - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id", -class => "list"}, + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id"}, escapeHTML($file) . $mode_chnge) . "\n" . "
\n"; print "
\n" . @@ -649,7 +654,7 @@ if ($action eq "blob") { $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . "

\n"; print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "
\n"; print "
\n" . "
\n";
@@ -689,10 +694,7 @@ if ($action eq "blob") {
 	print "
\n"; print "

\n"; print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "log_title"}, escapeHTML($file_name)) . "\n" . - "
\n"; - print "
\n" . - "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($file_name)) . "\n" . "
\n"; foreach my $rev (@revlist) { my %co = git_commit($rev); @@ -713,8 +715,8 @@ if ($action eq "blob") { } } if ($found) { - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev", -class => "list"}, + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$rev"}, "" . $co{'age_string'} . "" . escapeHTML($co{'title'})) . "\n" . "
\n"; print "
\n" . -- cgit 1.2.3-korg From 2bb7c6d4179ca7cd5cfd353400866ef0aed16777 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:19:45 +0200 Subject: v082 --- gitweb.cgi | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index fa2ba70aad..15bb123b21 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "080"; +my $version = "082"; my $projectroot = "/pub/scm"; my $home_link = "/git"; my $gitbin = "/usr/bin"; @@ -23,12 +23,6 @@ my $logo_link = "/pub/software/scm/cogito"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); -# remove # -my $projectroot = "/home/kay/public_html/pub/scm"; -my $home_link = "/~kay/git"; -my $logo_link = "/~kay/pub/software/scm/cogito"; -# remove # - mkdir($gittmp, 0700); my $project = $cgi->param('p'); my $action = $cgi->param('a'); @@ -185,7 +179,7 @@ sub git_commit { my %co; my @parents; - open my $fd, "-|", "$gitbin/git-cat-file commit $commit"; + open my $fd, "-|", "$gitbin/cat-file commit $commit"; while (my $line = <$fd>) { chomp($line); last if $line eq ""; @@ -257,7 +251,7 @@ sub git_diff_html { if ($from ne "") { $from_tmp = "$gittmp/gitweb_" . $$ . "_from"; open(my $fd2, "> $from_tmp"); - open my $fd, "-|", "$gitbin/git-cat-file blob $from"; + open my $fd, "-|", "$gitbin/cat-file blob $from"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -269,7 +263,7 @@ sub git_diff_html { if ($to ne "") { $to_tmp = "$gittmp/gitweb_" . $$ . "_to"; open my $fd2, "> $to_tmp"; - open my $fd, "-|", "$gitbin/git-cat-file blob $to"; + open my $fd, "-|", "$gitbin/cat-file blob $to"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -387,7 +381,7 @@ if ($action eq "blob") { print "

\n"; print "
$hash
\n"; print "
\n";
-	open(my $fd, "-|", "$gitbin/git-cat-file blob $hash");
+	open(my $fd, "-|", "$gitbin/cat-file blob $hash");
 	my $nr;
 	while (my $line = <$fd>) {
 		$nr++;
@@ -401,7 +395,7 @@ if ($action eq "blob") {
 	if ($hash eq "") {
 		$hash = git_head($project);
 	}
-	open my $fd, "-|", "$gitbin/git-ls-tree $hash";
+	open my $fd, "-|", "$gitbin/ls-tree $hash";
 	my (@entries) = map { chomp; $_ } <$fd>;
 	close $fd;
 
@@ -440,7 +434,7 @@ if ($action eq "blob") {
 	print "
"; git_footer_html(); } elsif ($action eq "log" || $action eq "rss") { - open my $fd, "-|", "$gitbin/git-rev-list " . git_head($project); + open my $fd, "-|", "$gitbin/rev-list " . git_head($project); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; @@ -522,7 +516,7 @@ if ($action eq "blob") { } my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); - open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; + open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -611,10 +605,16 @@ if ($action eq "blob") { if ($from_mode != $to_mode) { $mode_chnge = " [chmod $mode]\n"; } - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id"}, - escapeHTML($file) . $mode_chnge) . "\n" . - "
\n"; + print "
\n"; + if ($to_id ne $from_id) { + print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id"}, + escapeHTML($file) . $mode_chnge) . "\n" . + "
\n"; + } else { + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, + escapeHTML($file) . $mode_chnge) . "\n" . + "
\n"; + } print "
\n" . "view "; if ($to_id ne $from_id) { @@ -643,7 +643,7 @@ if ($action eq "blob") { if (!defined(%co)) { die_error("", "Unknown commit object."); } - open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; + open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -686,7 +686,7 @@ if ($action eq "blob") { if (!(defined($hash))) { $hash = git_head($project); } - open my $fd, "-|", "$gitbin/git-rev-list $hash"; + open my $fd, "-|", "$gitbin/rev-list $hash"; my (@revlist) = map { chomp; $_ } <$fd>; close $fd; @@ -701,7 +701,7 @@ if ($action eq "blob") { my $parents = $co{'parents'}; my $found = 0; foreach my $parent (@$parents) { - open $fd, "-|", "$gitbin/git-diff-tree -r $parent $rev $file_name"; + open $fd, "-|", "$gitbin/diff-tree -r $parent $rev $file_name"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -728,5 +728,5 @@ if ($action eq "blob") { } git_footer_html(); } else { - die_error("", "unknown action"); + die_error("", "Unknown action."); } -- cgit 1.2.3-korg From 6191f8e1ddbc03dd2b5db2f6d433f7a1da93c4af Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:19:56 +0200 Subject: v085 --- gitweb.cgi | 213 ++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 119 insertions(+), 94 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 15bb123b21..4ad3ce4dcb 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "082"; +my $version = "085"; my $projectroot = "/pub/scm"; my $home_link = "/git"; my $gitbin = "/usr/bin"; @@ -22,107 +22,116 @@ my $gittmp = "/tmp/gitweb"; my $logo_link = "/pub/software/scm/cogito"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); +my $rss_link = ""; -mkdir($gittmp, 0700); my $project = $cgi->param('p'); -my $action = $cgi->param('a'); -my $hash = $cgi->param('h'); -my $hash_parent = $cgi->param('hp'); -my $file_name = $cgi->param('f'); -my $time_back = $cgi->param('t'); -$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; - -# validate input if (defined($project)) { if ($project =~ /(^|\/)(|\.|\.\.)($|\/)/) { + $project = ""; die_error("", "Invalid project parameter."); } if (!(-d "$projectroot/$project")) { + $project = ""; die_error("", "No such project."); } + $rss_link = ""; } + +my $file_name = $cgi->param('f'); if (defined($file_name) && $file_name =~ /(^|\/)(|\.|\.\.)($|\/)/) { + $file_name = ""; die_error("", "Invalid file parameter."); } -if (defined($action) && !$action =~ m/^[0-9a-zA-Z\.\-]+$/) { + +my $action = $cgi->param('a'); +if (defined($action) && $action =~ m/[^0-9a-zA-Z\.\-]+$/) { + $action = ""; die_error("", "Invalid action parameter."); } + +my $hash = $cgi->param('h'); if (defined($hash) && !($hash =~ m/^[0-9a-fA-F]{40}$/)) { + $hash = ""; die_error("", "Invalid hash parameter."); } + +my $hash_parent = $cgi->param('hp'); if (defined($hash_parent) && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) { + $hash_parent = ""; die_error("", "Invalid parent hash parameter."); } + +my $time_back = $cgi->param('t'); if (defined($time_back) && !($time_back =~ m/^[0-9]+$/)) { + $time_back = ""; die_error("", "Invalid time parameter."); } +$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; +mkdir($gittmp, 0700); + sub git_header_html { my $status = shift || "200 OK"; print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status); print < + - git - $project $action - - +git - $project +$rss_link + EOF @@ -140,13 +149,18 @@ EOF } sub git_footer_html { - print "
"; - print ""; - if ($project ne '') { + print "
\n"; + if ($project ne "") { + if (-e "$projectroot/$project/description") { + open(my $fd, "$projectroot/$project/description"); + my $descr = <$fd>; + print "\n"; + close $fd; + } print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "XML") . "\n"; } - print "
" . - "" . + print "
\n" . + "\n" . ""; } @@ -154,12 +168,10 @@ sub die_error { my $status = shift || "403 Forbidden"; my $error = shift || "Malformed query, file missing or permission denied"; - $project = ""; - $action = ""; git_header_html($status); print "
\n" . "

\n"; - print "$error\n"; + print "$status - $error\n"; print "
\n"; git_footer_html(); exit 0; @@ -167,7 +179,7 @@ sub die_error { sub git_head { my $path = shift; - open(my $fd, "$projectroot/$path/HEAD") || die_error("", "Invalid project directory.");; + open(my $fd, "$projectroot/$path/HEAD") || die_error("", "Invalid project directory."); my $head = <$fd>; close $fd; chomp $head; @@ -403,10 +415,11 @@ if ($action eq "blob") { my %co = git_commit($hash); if (defined(%co)) { print "
view\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . - "

\n"; + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . + "

\n" . + "
\n"; print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "
\n"; @@ -442,10 +455,10 @@ if ($action eq "blob") { git_header_html(); print "
\n"; print "view "; - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | \n" . + print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "
\n"; print "

\n" . "
\n"; @@ -475,7 +488,7 @@ if ($action eq "blob") { $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, "" . $co{'age_string'} . "" . escapeHTML($co{'title'})) . "\n" . "
\n"; - print "
\n" . + print "
\n" . "
\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . "
\n" . @@ -516,10 +529,18 @@ if ($action eq "blob") { } my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); - open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; - my (@difftree) = map { chomp; $_ } <$fd>; - close $fd; + my @difftree; + if (defined($co{'parent'})) { + open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; + @difftree = map { chomp; $_ } <$fd>; + close $fd; + } else { + # fake git-diff-tree output for initial revision + open my $fd, "-|", "$gitbin/ls-tree -r $hash"; + @difftree = map { chomp; "+" . $_ } <$fd>; + close $fd; + } git_header_html(); print "
view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . @@ -529,7 +550,7 @@ if ($action eq "blob") { print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "
\n"; - print "
\n" . + print "
\n" . ""; print "\n"; print "\n"; print "\n"; + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=" . $hash}, $co{'tree'}) . "\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { print "\n"; print "\n"; - print "\n"; + print "\n"; print "\n"; print "\n"; @@ -864,7 +882,7 @@ sub git_commit { } else { $empty = 0; } - if ($line =~ m/(signed.off|acked).by/i) { + if ($line =~ m/^(signed[ \-]off[\-]by[ :]|acked[\-]by[ \:]|cc[ :])/i) { $signed = 1; print "" . escapeHTML($line) . "
\n"; } else { @@ -900,8 +918,7 @@ sub git_commit { escapeHTML($file) . " [new " . file_type($mode) . $mode_chng . "]") . "\n" . ""; print "
\n" . - "view " . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "file") . "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . "
\n" . "
\n"; } elsif ($op eq "-") { print "
\n" . @@ -909,8 +926,7 @@ sub git_commit { escapeHTML($file) . " [deleted " . file_type($mode) . "]") . "\n" . "
"; print "
\n" . - "view " . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "file") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "
\n" . "
\n"; } elsif ($op eq "*") { @@ -945,12 +961,11 @@ sub git_commit { escapeHTML($file) . $mode_chnge) . "\n" . "\n"; } - print "
\n" . - "view "; + print "
\n"; if ($to_id ne $from_id) { print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff") . " | "; } - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "file") . " | " . + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "blob") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "
\n" . "
\n"; } @@ -963,9 +978,9 @@ sub git_blobdiff { mkdir($gittmp, 0700); git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { - print "
view\n" . + print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "diffs") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree"); if (defined $file_name) { print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history"); @@ -1009,9 +1024,9 @@ sub git_commitdiff { close $fd || die_error(undef, "Reading diff-tree failed."); git_header_html(); - print "
view\n" . + print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . " | \n" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "\n" . "

\n"; print "
\n" . @@ -1070,9 +1085,9 @@ sub git_history { die_error(undef, "Unknown commit object."); } git_header_html(); - print "
view\n" . + print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "

\n" . "
\n"; @@ -1104,11 +1119,15 @@ sub git_history { "" . $co{'age_string'} . "" . escapeHTML($co{'title'})) . "\n" . "
\n"; print "
\n" . - "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=" . $file}, "file") . - "

\n" . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=" . $file}, "blob"); + my $blob = git_get_hash_by_path($hash, $file_name); + my $blob_parent = git_get_hash_by_path($commit, $file_name); + if (defined $blob && defined $blob_parent && $blob ne $blob_parent) { + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=" . $file}, "diff"); + } + print "
\n" . "
\n"; undef $commit; } -- cgit 1.2.3-korg From c07ad4b97128d26949ed34a2fd4a3a7039278fe8 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:22:44 +0200 Subject: v133 --- gitweb.cgi | 180 +++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 103 insertions(+), 77 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 534edeaa8f..619db534a3 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "125"; +my $version = "133"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -29,6 +29,7 @@ my $gitbin = "/usr/bin"; my $gittmp = "/tmp/gitweb"; # target of the home link on top of all pages +#my $home_link = $my_uri; my $home_link = "/git"; # source of projects list @@ -163,51 +164,47 @@ sub git_header_html { $title $rss_link @@ -901,6 +905,20 @@ sub git_project_list { git_footer_html(); } +sub read_info_ref { + my %refs; + # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11 + # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{} + open my $fd, "$projectroot/$project/info/refs" or return; + while (my $line = <$fd>) { + if ($line =~ m/^([0-9a-fA-F]{40})\t.*\/([^\^]+)/) { + $refs{$1} = $2; + } + } + close $fd or return; + return \%refs; +} + sub git_read_refs { my $ref_dir = shift; my @reflist; @@ -989,6 +1007,7 @@ sub git_summary { $owner = get_file_owner("$projectroot/$project"); } + my $refs = read_info_ref(); git_header_html(); print "
\n" . "summary". @@ -1034,6 +1053,9 @@ sub git_summary { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "" . esc_html($co{'title'}) . ""); } + if (defined $refs->{$commit}) { + print " $refs->{$commit}"; + } print "\n" . "
\n"; } else { @@ -2079,7 +2106,7 @@ sub git_history { print "\n" . "\n" . "\n" . + esc_html(chop_str($co{'title'}, 50)) . "") . "$ref\n" . "\n" . "\n" . "\n" . "\n" . "\n" . "\n" . "\n" . + esc_html(chop_str($co{'title'}, 50)) . "$ref") . "\n" . "\n" . "\n" . "\n" . @@ -1417,6 +1417,11 @@ sub git_tree { close $fd or die_error(undef, "Reading tree failed."); $/ = "\n"; + my $refs = read_info_ref(); + my $ref = ""; + if (defined $refs->{$hash_base}) { + $ref = " " . esc_html($refs->{$hash_base}) . ""; + } git_header_html(); my $base_key = ""; my $base = ""; @@ -1432,7 +1437,7 @@ sub git_tree { "

\n" . "\n"; print "
\n" . - $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'}) . $ref) . "\n" . "
\n"; } else { print "
\n"; @@ -1629,7 +1634,7 @@ sub git_log { my $commit = $revlist[$i]; my $ref = ""; if (defined $refs->{$commit}) { - $ref = " $refs->{$commit}"; + $ref = " " . esc_html($refs->{$commit}) . ""; } my %co = git_read_commit($commit); next if !%co; @@ -1695,6 +1700,11 @@ sub git_commit { if ($hash =~ m/^[0-9a-fA-F]{40}$/) { $expires = "+1d"; } + my $refs = read_info_ref(); + my $ref = ""; + if (defined $refs->{$hash}) { + $ref = " " . esc_html($refs->{$hash}) . ""; + } git_header_html(undef, $expires); print "
\n" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . @@ -1708,7 +1718,7 @@ sub git_commit { "

\n"; if (defined $co{'parent'}) { print "
\n" . - $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash"), -class => "title"}, esc_html($co{'title'}) . $ref) . "\n" . "
\n"; } else { print "
\n" . @@ -1932,6 +1942,11 @@ sub git_commitdiff { if ($hash =~ m/^[0-9a-fA-F]{40}$/) { $expires = "+1d"; } + my $refs = read_info_ref(); + my $ref = ""; + if (defined $refs->{$hash}) { + $ref = " " . esc_html($refs->{$hash}) . ""; + } git_header_html(undef, $expires); print "
\n" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . @@ -1943,7 +1958,7 @@ sub git_commitdiff { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "\n" . "
\n"; print "
\n" . - $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'}) . $ref) . "\n" . "
\n"; print "
\n"; my $comment = $co{'comment'}; @@ -2101,7 +2116,7 @@ sub git_history { } my $ref = ""; if (defined $refs->{$commit}) { - $ref = " $refs->{$commit}"; + $ref = " " . esc_html($refs->{$commit}) . ""; } if ($alternate) { print "
\n"; @@ -2330,7 +2345,7 @@ sub git_shortlog { my $commit = $revlist[$i]; my $ref = ""; if (defined $refs->{$commit}) { - $ref = " $refs->{$commit}"; + $ref = " " . esc_html($refs->{$commit}) . ""; } my %co = git_read_commit($commit); my %ad = date_str($co{'author_epoch'}); -- cgit 1.2.3-korg From c2488d064bb5225e8d816f9ca8e8ee904bf6eb92 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 7 Dec 2005 16:32:51 +0100 Subject: fix leading whitespace in commit text Signed-off-by: Kay Sievers --- gitweb.cgi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 1f5a409bf1..1c93192fc3 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -531,6 +531,7 @@ sub git_read_commit { }; foreach my $title (@commit_lines) { + $title =~ s/^ //; if ($title ne "") { $co{'title'} = chop_str($title, 80, 5); # remove leading stuff of merges to make the interesting part visible @@ -912,6 +913,7 @@ sub read_info_ref { # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{} open my $fd, "$projectroot/$project/info/refs" or return; while (my $line = <$fd>) { + chomp($line); if ($line =~ m/^([0-9a-fA-F]{40})\t.*$type\/([^\^]+)/) { if (defined $refs{$1}) { $refs{$1} .= " / $2"; @@ -2056,7 +2058,7 @@ sub git_commitdiff_plain { "\n"; foreach my $line (@$comment) {; - print " $line\n"; + print "$line\n"; } print "---\n\n"; -- cgit 1.2.3-korg From fdeb2fb6166904adc6396c6eeb5b89f6f81b5ef7 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 7 Dec 2005 16:33:08 +0100 Subject: v261 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 1c93192fc3..d025320027 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "260"; +my $version = "261"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; -- cgit 1.2.3-korg From 8240accb65872589f9721dab681708055adc3c1c Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Mon, 19 Dec 2005 04:09:02 +0100 Subject: define default colors Thanks to Kir Kolyshkin for pointing it out. Signed-off-by: Kay Sievers --- gitweb.cgi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index d025320027..63a0169395 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -260,7 +260,10 @@ sub git_header_html { $title $rss_link
author" . escapeHTML($co{'author'}) . "
" . " " . $ad{'rfc2822'}; @@ -562,6 +583,9 @@ if ($action eq "blob") { } } print "\n"; + if ($#difftree > 10) { + print "
" . ($#difftree + 1) . " files changed:
\n"; + } foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h' @@ -582,7 +606,7 @@ if ($action eq "blob") { ""; print "
\n" . "view " . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "

\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "
\n" . "
\n"; } elsif ($op eq "-") { print "
\n" . @@ -592,7 +616,7 @@ if ($action eq "blob") { print "
\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "

\n" . + $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "
\n" . "
\n"; } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; @@ -621,7 +645,7 @@ if ($action eq "blob") { print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id"}, "diff") . " | "; } print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, "file") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "

\n" . + $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "
\n" . "
\n"; } } @@ -728,5 +752,6 @@ if ($action eq "blob") { } git_footer_html(); } else { + $action = ""; die_error("", "Unknown action."); } -- cgit 1.2.3-korg From 034df39ef7c80bd7e41e244c39400019123273c1 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:20:07 +0200 Subject: v088 --- gitweb.cgi | 188 ++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 100 insertions(+), 88 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 4ad3ce4dcb..1e8565a8a7 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,12 +14,21 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -my $version = "085"; +# !! This devel-version uses a modified git-rev-list binary !! +# The git changes are expected to show up upstream soon. + +# begin config my $projectroot = "/pub/scm"; +$projectroot = "/home/kay/public_html/pub/scm"; my $home_link = "/git"; +$home_link = "/~kay/git"; my $gitbin = "/usr/bin"; my $gittmp = "/tmp/gitweb"; my $logo_link = "/pub/software/scm/cogito"; +$logo_link = "/~kay/pub/software/scm/cogito"; +# end config + +my $version = "088-devel"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -35,6 +44,7 @@ if (defined($project)) { die_error("", "No such project."); } $rss_link = ""; + $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; } my $file_name = $cgi->param('f'); @@ -67,7 +77,6 @@ if (defined($time_back) && !($time_back =~ m/^[0-9]+$/)) { die_error("", "Invalid time parameter."); } -$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$project/objects"; mkdir($gittmp, 0700); sub git_header_html { @@ -77,8 +86,8 @@ sub git_header_html { print < + - git - $project $rss_link @@ -157,7 +166,7 @@ sub git_footer_html { print "\n"; close $fd; } - print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "XML") . "\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "RSS") . "\n"; } print "\n" . "\n" . @@ -191,7 +200,7 @@ sub git_commit { my %co; my @parents; - open my $fd, "-|", "$gitbin/cat-file commit $commit"; + open my $fd, "-|", "$gitbin/git-cat-file commit $commit"; while (my $line = <$fd>) { chomp($line); last if $line eq ""; @@ -263,7 +272,7 @@ sub git_diff_html { if ($from ne "") { $from_tmp = "$gittmp/gitweb_" . $$ . "_from"; open(my $fd2, "> $from_tmp"); - open my $fd, "-|", "$gitbin/cat-file blob $from"; + open my $fd, "-|", "$gitbin/git-cat-file blob $from"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -275,7 +284,7 @@ sub git_diff_html { if ($to ne "") { $to_tmp = "$gittmp/gitweb_" . $$ . "_to"; open my $fd2, "> $to_tmp"; - open my $fd, "-|", "$gitbin/cat-file blob $to"; + open my $fd, "-|", "$gitbin/git-cat-file blob $to"; my @file = <$fd>; print $fd2 @file; close $fd2; @@ -347,8 +356,8 @@ sub date_str { $date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d +0000", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec; $date{'mday-time'} = sprintf "%d %s %02d:%02d", $mday, $months[$mon], $hour ,$min; - $tz =~ m/((-|\+)[0-9][0-9])([0-9][0-9])/; - my $local = $epoch + (($1 + ($2/60)) * 3600); + $tz =~ m/^([+\-][0-9][0-9])([0-9][0-9])$/; + my $local = $epoch + ((int $1 + ($2/60)) * 3600); ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($local); $date{'hour_local'} = $hour; $date{'minute_local'} = $min; @@ -356,7 +365,7 @@ sub date_str { return %date; } -if ($action eq "git-logo.png") { +if (defined($action) && $action eq "git-logo.png") { print $cgi->header(-type => 'image/png', -expires => '+1d'); print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122". "\000\000\000\110\000\000\000\033\004\003\000\000\000\055\331\324". @@ -393,7 +402,7 @@ if ($action eq "blob") { print "

\n"; print "
$hash
\n"; print "
\n";
-	open(my $fd, "-|", "$gitbin/cat-file blob $hash");
+	open(my $fd, "-|", "$gitbin/git-cat-file blob $hash");
 	my $nr;
 	while (my $line = <$fd>) {
 		$nr++;
@@ -407,13 +416,13 @@ if ($action eq "blob") {
 	if ($hash eq "") {
 		$hash = git_head($project);
 	}
-	open my $fd, "-|", "$gitbin/ls-tree $hash";
+	open my $fd, "-|", "$gitbin/git-ls-tree $hash";
 	my (@entries) = map { chomp; $_ } <$fd>;
 	close $fd;
 
 	git_header_html();
 	my %co = git_commit($hash);
-	if (defined(%co)) {
+	if (%co) {
 		print "
view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | " . @@ -446,85 +455,88 @@ if ($action eq "blob") { print "
\n"; print "
"; git_footer_html(); -} elsif ($action eq "log" || $action eq "rss") { - open my $fd, "-|", "$gitbin/rev-list " . git_head($project); +} elsif ($action eq "rss") { + open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_head($project); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; - if ($action eq "log") { - git_header_html(); - print "
\n"; - print "view "; - print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "
\n"; - print "

\n" . - "
\n"; - } elsif ($action eq "rss") { - print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); - print "\n". - "\n"; - print "\n"; - print "$project\n". - " " . $my_url . "/$project/log\n". - "$project log\n". - "en\n"; - } - - for (my $i = 0; $i <= $#revlist; $i++) { - my $commit = $revlist[$i]; + print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); + print "\n". + "\n"; + print "\n"; + print "$project\n". + " " . $my_url . "/$project/log\n". + "$project log\n". + "en\n"; + + foreach my $commit (@revlist) { my %co = git_commit($commit); my %ad = date_str($co{'author_epoch'}); - if ($action eq "log") { - if ($time_back > 0 && $co{'age'} > $time_back*60*60*24) { - if ($i == 0) { - print "
Last change " . $co{'age_string'} . ".

\n"; - } - last; - } - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, - "" . $co{'age_string'} . "" . escapeHTML($co{'title'})) . "\n" . - "
\n"; - print "
\n" . - "
\n" . - "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . "
\n" . - "
\n" . - "" . escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]
\n" . - "
\n" . - "
\n"; - my $comment = $co{'comment'}; - foreach my $line (@$comment) { - last if ($line =~ m/^(signed-off|acked)-by:/i); - print escapeHTML($line) . "
\n"; - } - print "
\n" . - "
\n"; - } elsif ($action eq "rss") { - last if ($i >= 20); - print "\n" . - "\t" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "\n" . - "\t " . $my_url . "?p=$project;a=commit;h=$commit\n" . - "\t"; - my $comment = $co{'comment'}; - foreach my $line (@$comment) { - print escapeHTML($line) . "\n"; - } - print "\t\n" . - "\n"; + print "\n" . + "\t" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "\n" . + "\t " . $my_url . "?p=$project;a=commit;h=$commit\n" . + "\t"; + my $comment = $co{'comment'}; + foreach my $line (@$comment) { + print escapeHTML($line) . "
\n"; } + print "\t
\n" . + "
\n"; + } + print "
"; +} elsif ($action eq "log") { + my $date = 0; + if ($time_back > 0) { + $date = time - $time_back*24*60*60; + } + my $head = git_head($project); + open my $fd, "-|", "$gitbin/git-rev-list --max-age=$date $head"; + my (@revlist) = map { chomp; $_ } <$fd>; + close $fd; + + git_header_html(); + print "
\n"; + print "view "; + print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last day") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=31"}, "month") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=365"}, "year") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=log;t=0"}, "all") . "
\n"; + print "

\n" . + "
\n"; + + if (!(@revlist)) { + my %co = git_commit($head); + print "
Last change " . $co{'age_string'} . ".

\n"; } - if ($action eq "log") { - git_footer_html(); - } elsif ($action eq "rss") { - print "
"; + + foreach my $commit (@revlist) { + my %co = git_commit($commit); + my %ad = date_str($co{'author_epoch'}); + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, + "" . $co{'age_string'} . "" . escapeHTML($co{'title'})) . "\n" . + "
\n"; + print "
\n" . + "
\n" . + "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . "
\n" . + "
\n" . + "" . escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]
\n" . + "
\n" . + "
\n"; + my $comment = $co{'comment'}; + foreach my $line (@$comment) { + last if ($line =~ m/^(signed-off|acked)-by:/i); + print escapeHTML($line) . "
\n"; + } + print "
\n" . + "
\n"; } + git_footer_html(); } elsif ($action eq "commit") { my %co = git_commit($hash); - if (!defined(%co)) { + if (!%co) { die_error("", "Unknown commit object."); } my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); @@ -532,12 +544,12 @@ if ($action eq "blob") { my @difftree; if (defined($co{'parent'})) { - open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; + open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; @difftree = map { chomp; $_ } <$fd>; close $fd; } else { # fake git-diff-tree output for initial revision - open my $fd, "-|", "$gitbin/ls-tree -r $hash"; + open my $fd, "-|", "$gitbin/git-ls-tree -r $hash"; @difftree = map { chomp; "+" . $_ } <$fd>; close $fd; } @@ -664,10 +676,10 @@ if ($action eq "blob") { git_footer_html(); } elsif ($action eq "commitdiff") { my %co = git_commit($hash); - if (!defined(%co)) { + if (!%co) { die_error("", "Unknown commit object."); } - open my $fd, "-|", "$gitbin/diff-tree -r " . $co{'parent'} . " $hash"; + open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; @@ -710,7 +722,7 @@ if ($action eq "blob") { if (!(defined($hash))) { $hash = git_head($project); } - open my $fd, "-|", "$gitbin/rev-list $hash"; + open my $fd, "-|", "$gitbin/git-rev-list $hash"; my (@revlist) = map { chomp; $_ } <$fd>; close $fd; @@ -725,7 +737,7 @@ if ($action eq "blob") { my $parents = $co{'parents'}; my $found = 0; foreach my $parent (@$parents) { - open $fd, "-|", "$gitbin/diff-tree -r $parent $rev $file_name"; + open $fd, "-|", "$gitbin/git-diff-tree -r $parent $rev $file_name"; my (@difftree) = map { chomp; $_ } <$fd>; close $fd; -- cgit 1.2.3-korg From 2735983d79172313359cdf57afce723cc89326fd Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:20:20 +0200 Subject: v089 --- gitweb.cgi | 127 ++++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 80 insertions(+), 47 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 1e8565a8a7..fa7a0f590b 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,9 +14,6 @@ use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; -# !! This devel-version uses a modified git-rev-list binary !! -# The git changes are expected to show up upstream soon. - # begin config my $projectroot = "/pub/scm"; $projectroot = "/home/kay/public_html/pub/scm"; @@ -28,7 +25,7 @@ my $logo_link = "/pub/software/scm/cogito"; $logo_link = "/~kay/pub/software/scm/cogito"; # end config -my $version = "088-devel"; +my $version = "089"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -97,7 +94,7 @@ a { color:#0000cc; } a:hover { color:#880000; } a:visited { color:#880000; } a:active { color:#880000; } -div.page_header { +div.page_header\{ margin:15px 25px 0px; height:25px; padding:8px; font-size:18px; font-weight:bold; background-color:#d9d8d1; } @@ -132,14 +129,15 @@ div.link { font-family:sans-serif; font-size:10px; } td.key { padding-right:10px; } -a.xml_logo { float:right; border:1px solid; +span.diff_info { color:#000099; background-color:#eeeeee; font-style:italic; } +a.rss_logo { float:right; border:1px solid; line-height:15px; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; width:35px; color:#ffffff; background-color:#ff6600; font-weight:bold; font-family:sans-serif; text-align:center; font-size:10px; display:block; text-decoration:none; } -a.xml_logo:hover { background-color:#ee5500; } +a.rss_logo:hover { background-color:#ee5500; } @@ -166,7 +164,7 @@ sub git_footer_html { print "\n"; close $fd; } - print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "xml_logo"}, "RSS") . "\n"; + print $cgi->a({-href => "$my_uri?p=$project;a=rss", -class => "rss_logo"}, "RSS") . "\n"; } print "\n" . "\n" . @@ -257,15 +255,13 @@ sub git_commit { } sub git_diff_html { - my $from_name = shift || "/dev/null"; - my $to_name = shift || "/dev/null"; my $from = shift; + my $from_name = shift; my $to = shift; + my $to_name = shift; my $from_tmp = "/dev/null"; my $to_tmp = "/dev/null"; - my $from_label = "/dev/null"; - my $to_label = "/dev/null"; my $pid = $$; # create tmp from-file @@ -277,7 +273,6 @@ sub git_diff_html { print $fd2 @file; close $fd2; close $fd; - $from_label = "a/$from_name"; } # create tmp to-file @@ -289,25 +284,14 @@ sub git_diff_html { print $fd2 @file; close $fd2; close $fd; - $to_label = "b/$to_name"; } - open my $fd, "-|", "/usr/bin/diff -u -p -L $from_label -L $to_label $from_tmp $to_tmp"; - print "===== "; - if ($from ne "") { - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from"}, $from); - } else { - print $from_name; - } - print " vs "; - if ($to ne "") { - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to"}, $to); - } else { - print $to_name; - } - print " =====\n"; + open my $fd, "-|", "/usr/bin/diff -u -p -L $from_name -L $to_name $from_tmp $to_tmp"; while (my $line = <$fd>) { my $char = substr($line,0,1); + # skip errors + next if $char eq '\\'; + # color the diff print '' if $char eq '+'; print '' if $char eq '-'; print '' if $char eq '@'; @@ -317,29 +301,50 @@ sub git_diff_html { close $fd; if ($from ne "") { - unlink("$from_tmp"); + unlink($from_tmp); } if ($to ne "") { - unlink("$to_tmp"); + unlink($to_tmp); } } sub mode_str { - my $perms = oct shift; + my $mode = oct shift; + my $modestr; - if ($perms & 040000) { - $modestr .= 'drwxr-xr-x'; - } else { + if (($mode & 00170000) == 0040000 ) { + $modestr = 'drwxr-xr-x'; + } elsif (($mode & 00170000) == 0120000 ) { + $modestr = 'lrwxrwxrwx'; + } elsif (($mode & 00170000) == 0100000 ) { # git cares only about the executable bit - if ($perms & 0100) { - $modestr .= '-rwxr-xr-x'; + if ($mode & 0100) { + $modestr = '-rwxr-xr-x'; } else { - $modestr .= '-rw-r--r--'; + $modestr = '-rw-r--r--'; }; } return $modestr; } +sub file_type { + my $mode = oct shift; + + if (($mode & 0170000) == 0040000 ) { + return "directory"; + } elsif (($mode & 0170000) == 0120000 ) { + return "symlink"; + } elsif (($mode & 0170000) == 0100000 ) { + if ($mode & 0100) { + return "executable file"; + } else { + return "file"; + } + } else { + return "unknown"; + } +} + sub date_str { my $epoch = shift; my $tz = shift || "-0000"; @@ -447,7 +452,14 @@ if ($action eq "blob") { my $t_hash = $3; my $t_name = $4; if ($t_type eq "blob") { - print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name) . "\n"; + print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name); + if (((oct $t_mode) & 0170000) == 0120000) { + open my $fd, "-|", "$gitbin/git-cat-file blob $t_hash"; + my $target = <$fd>; + close $fd; + print "\t -> $target"; + } + print "\n"; } elsif ($t_type eq "tree") { print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, $t_name) . "\n"; } @@ -614,7 +626,7 @@ if ($action eq "blob") { if ($op eq "+") { print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, - escapeHTML($file) . " [new]") . "\n" . + escapeHTML($file) . " [new " . file_type($mode) . "]") . "\n" . "
"; print "
\n" . "view " . @@ -623,7 +635,7 @@ if ($action eq "blob") { } elsif ($op eq "-") { print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, - escapeHTML($file) . " [removed]") . "\n" . + escapeHTML($file) . " [deleted " . file_type($mode) . "]") . "\n" . "
"; print "
\n" . "view " . @@ -638,8 +650,8 @@ if ($action eq "blob") { my $from_mode = $1; my $to_mode = $2; my $mode_chnge = ""; - if ($from_mode != $to_mode) { - $mode_chnge = " [chmod $mode]\n"; + if (((oct $from_mode) & 0170100) != ((oct $to_mode) & 0170100)) { + $mode_chnge = " [changed from " . file_type($from_mode) . " to " . file_type($to_mode) . "]\n"; } print "
\n"; if ($to_id ne $from_id) { @@ -670,7 +682,12 @@ if ($action eq "blob") { print "
$hash vs $hash_parent
\n"; print "
\n" . "
\n";
-	git_diff_html($hash_parent, $hash, $hash_parent, $hash);
+	print "blob:" .
+	      $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash_parent"}, $hash_parent) .
+	      " -> blob:" .
+	      $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash"}, $hash) .
+	      "\n";
+	git_diff_html($hash_parent, $hash_parent, $hash, $hash);
 	print "
\n" . "
"; git_footer_html(); @@ -704,13 +721,29 @@ if ($action eq "blob") { my $file = $5; if ($type eq "blob") { if ($op eq "+") { - git_diff_html("", $file, "", $id); + print "new " . file_type($mode) . ":" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $id) . + "\n"; + git_diff_html("", "/dev/null", $id, "b/$file"); } elsif ($op eq "-") { - git_diff_html($file, "", $id, ""); + print "deleted " . file_type($mode) . ":" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $id) . + "\n"; + git_diff_html($id, "a/$file", "", "/dev/null"); } elsif ($op eq "*") { $id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/; - if ($1 ne $2) { - git_diff_html($file, $file, $1, $2); + my $from_id = $1; + my $to_id = $2; + $mode =~ m/([0-7]+)->([0-7]+)/; + my $from_mode = $1; + my $to_mode = $2; + if ($from_id ne $to_id) { + print "" . + file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id"}, $from_id) . + " -> " . + file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, $to_id); + print "\n"; + git_diff_html($from_id, "a/$file", $to_id, "b/$file"); } } } -- cgit 1.2.3-korg From b87d78d60ce3798c8938ba1d3ed176b6ed9ba539 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:21:04 +0200 Subject: v107 --- gitweb.cgi | 537 ++++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 338 insertions(+), 199 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index fa7a0f590b..ec68636c24 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -5,39 +5,79 @@ # (C) 2005, Kay Sievers # (C) 2005, Christian Gierke # -# This file is licensed under the GPL v2, or a later version +# This program is licensed under the GPL v2, or a later version use strict; use warnings; use CGI qw(:standard :escapeHTML); use CGI::Carp qw(fatalsToBrowser); +use Fcntl ':mode'; my $cgi = new CGI; +my $version = "107"; +my $my_url = $cgi->url(); +my $my_uri = $cgi->url(-absolute => 1); +my $rss_link = ""; -# begin config +# absolute fs-path which will be prepended to the project path my $projectroot = "/pub/scm"; -$projectroot = "/home/kay/public_html/pub/scm"; -my $home_link = "/git"; -$home_link = "/~kay/git"; + +# location of the git-core binaries my $gitbin = "/usr/bin"; + +# location for temporary files needed for diffs my $gittmp = "/tmp/gitweb"; -my $logo_link = "/pub/software/scm/cogito"; -$logo_link = "/~kay/pub/software/scm/cogito"; -# end config -my $version = "089"; -my $my_url = $cgi->url(); -my $my_uri = $cgi->url(-absolute => 1); -my $rss_link = ""; +# target of the home link on top of all pages +my $home_link = $my_uri; +$home_link = "/git"; + +# handler to return the list of projects +sub get_projects_list { + my @list; + + # search in directory +# my $dir = $projectroot; +# opendir my $dh, $dir || return undef; +# while (my $dir = readdir($dh)) { +# if (-e "$projectroot/$dir/HEAD") { +# push @list, $dir; +# } +# } +# closedir($dh); + + # read from file + my $file = "index/index.txt"; + open my $fd , $file || return undef; + while (my $line = <$fd>) { + chomp $line; + if (-e "$projectroot/$line/HEAD") { + push @list, $line; + } + } + close $fd; + + @list = sort @list; + return \@list; +} +# input validation my $project = $cgi->param('p'); -if (defined($project)) { - if ($project =~ /(^|\/)(|\.|\.\.)($|\/)/) { - $project = ""; - die_error("", "Invalid project parameter."); +if (defined $project) { + if ($project =~ m/(^|\/)(|\.|\.\.)($|\/)/) { + undef $project; + die_error("", "Non-canonical project parameter."); + } + if ($project =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~]/) { + undef $project; + die_error("", "Invalid character in project parameter."); } if (!(-d "$projectroot/$project")) { - $project = ""; + undef $project; + die_error("", "No such directory."); + } + if (!(-e "$projectroot/$project/HEAD")) { + undef $project; die_error("", "No such project."); } $rss_link = ""; @@ -45,40 +85,57 @@ if (defined($project)) { } my $file_name = $cgi->param('f'); -if (defined($file_name) && $file_name =~ /(^|\/)(|\.|\.\.)($|\/)/) { - $file_name = ""; - die_error("", "Invalid file parameter."); +if (defined $file_name) { + if ($file_name =~ m/(^|\/)(|\.|\.\.)($|\/)/) { + undef $file_name; + die_error("", "Non-canonical file parameter."); + } + if ($file_name =~ m/[^a-zA-Z0-9_\.\/\-\+\#\~]/) { + undef $file_name; + die_error("", "Invalid character in file parameter."); + } } my $action = $cgi->param('a'); -if (defined($action) && $action =~ m/[^0-9a-zA-Z\.\-]+$/) { - $action = ""; - die_error("", "Invalid action parameter."); +if (defined $action) { + if ($action =~ m/[^0-9a-zA-Z\.\-]+/) { + undef $action; + die_error("", "Invalid action parameter."); + } +} else { + $action = "log"; } my $hash = $cgi->param('h'); -if (defined($hash) && !($hash =~ m/^[0-9a-fA-F]{40}$/)) { - $hash = ""; +if (defined $hash && !($hash =~ m/^[0-9a-fA-F]{40}$/)) { + undef $hash; die_error("", "Invalid hash parameter."); } my $hash_parent = $cgi->param('hp'); -if (defined($hash_parent) && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) { - $hash_parent = ""; +if (defined $hash_parent && !($hash_parent =~ m/^[0-9a-fA-F]{40}$/)) { + undef $hash_parent; die_error("", "Invalid parent hash parameter."); } my $time_back = $cgi->param('t'); -if (defined($time_back) && !($time_back =~ m/^[0-9]+$/)) { - $time_back = ""; - die_error("", "Invalid time parameter."); +if (defined $time_back) { + if ($time_back =~ m/^[^0-9]+$/) { + undef $time_back; + die_error("", "Invalid time parameter."); + } } -mkdir($gittmp, 0700); - sub git_header_html { my $status = shift || "200 OK"; + my $title = "git"; + if (defined $project) { + $title .= " - $project"; + if (defined $action) { + $title .= "/$action"; + } + } print $cgi->header(-type=>'text/html', -charset => 'utf-8', -status=> $status); print < @@ -86,7 +143,7 @@ sub git_header_html { -git - $project +$title $rss_link @@ -215,7 +233,7 @@ EOF sub git_footer_html { print "
\n"; if (defined $project) { - my $descr = git_description($project); + my $descr = git_read_description($project); if (defined $descr) { print "\n"; } @@ -236,11 +254,12 @@ sub die_error { print "$status - $error\n"; print "
\n"; git_footer_html(); - exit 0; + exit; } -sub git_head { +sub git_read_head { my $path = shift; + open my $fd, "$projectroot/$path/HEAD" || return undef; my $head = <$fd>; close $fd; @@ -252,8 +271,9 @@ sub git_head { } } -sub git_description { +sub git_read_description { my $path = shift; + open my $fd, "$projectroot/$path/description" || return undef; my $descr = <$fd>; close $fd; @@ -261,7 +281,7 @@ sub git_description { return $descr; } -sub git_commit { +sub git_read_commit { my $commit = shift; my %co; my @parents; @@ -440,7 +460,7 @@ sub date_str { } # git-logo (cached in browser for one day) -if (defined $action && $action eq "git-logo.png") { +sub git_logo() { print $cgi->header(-type => 'image/png', -expires => '+1d'); # cat git-logo.png | hexdump -e '16/1 " %02x" "\n"' | sed 's/ /\\x/g' print "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" . @@ -456,12 +476,39 @@ if (defined $action && $action eq "git-logo.png") { "\x99\x30\xb8\x93\x0a\x11\xb9\x45\x88\xc1\x8d\xa0\xa2\x44\x21\x06" . "\x27\x41\x82\x40\x85\xc1\x45\x89\x20\x70\x01\x00\xa4\x3d\x21\xc5" . "\x12\x1c\x9a\xfe\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82"; - exit; } -# project browser -if (!defined $project) { - my $projects = get_projects_list(); +sub git_project_list { + my $project_list = shift; + my @list; + + if (-d $project_list) { + # search in directory + my $dir = $project_list; + opendir my $dh, $dir || return undef; + while (my $dir = readdir($dh)) { + if (-e "$projectroot/$dir/HEAD") { + push @list, $dir; + } + } + closedir($dh); + } elsif (-e $project_list) { + # read from file + open my $fd , $project_list || return undef; + while (my $line = <$fd>) { + chomp $line; + if (-e "$projectroot/$line/HEAD") { + push @list, $line; + } + } + close $fd; + } + + if (!@list) { + die_error(undef, "No project found."); + } + @list = sort @list; + git_header_html(); print "
\n"; print "\n"; @@ -472,17 +519,17 @@ if (!defined $project) { "\n" . "\n" . "
"; - foreach my $proj (@$projects) { - my $head = git_head($proj); + foreach my $proj (@list) { + my $head = git_read_head($proj); if (!defined $head) { next; } $ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/$proj/objects"; - my %co = git_commit($head); + my %co = git_read_commit($head); if (!%co) { next; } - my $descr = git_description($proj) || ""; + my $descr = git_read_description($proj) || ""; my $owner = ""; my ($dev, $ino, $mode, $nlink, $st_uid, $st_gid, $rdev, $size) = stat("$projectroot/$proj"); my ($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwuid($st_uid); @@ -502,59 +549,123 @@ if (!defined $project) { print "\n"; } print "\n"; - undef %co; } print "
last change
" . $co{'age_string'} . "
\n" . "
\n" . "
\n"; git_footer_html(); - exit; } -# action dispatch -if ($action eq "blob") { - open my $fd, "-|", "$gitbin/git-cat-file blob $hash" || die_error("", "Open failed."); +sub git_get_hash_by_path { + my $base = shift; + my $path = shift; + + my $tree = $base; + my @parts = split '/', $path; + while (my $part = shift @parts) { + open my $fd, "-|", "$gitbin/git-ls-tree $tree" || die_error(undef, "Open git-ls-tree failed."); + my (@entries) = map { chomp; $_ } <$fd>; + close $fd || die_error(undef, "Reading tree failed."); + foreach my $line (@entries) { + #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' + $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; + my $t_mode = $1; + my $t_type = $2; + my $t_hash = $3; + my $t_name = $4; + if ($t_name eq $part) { + if (!(@parts)) { + return $t_hash; + } + if ($t_type eq "tree") { + $tree = $t_hash; + } + last; + } + } + } +} + +sub git_blob { + if (!defined $hash && defined $file_name) { + my $base = $hash_base || git_read_head($project); + $hash = git_get_hash_by_path($base, $file_name, "blob"); + } + open my $fd, "-|", "$gitbin/git-cat-file blob $hash" || die_error(undef, "Open failed."); + my $base = $file_name || ""; git_header_html(); - print "
\n"; - print "

\n"; - print "
$hash
\n"; - print "
\n";
+	if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
+		print "
view\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "diffs") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree"); + if (defined $file_name) { + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history"); + } + print "

\n" . + "
\n"; + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n"; + } else { + print "
\n" . + "

\n" . + "
$hash
\n"; + } + if (defined $file_name) { + print "
/$file_name
\n"; + } + print "
\n" .
 	my $nr;
 	while (my $line = <$fd>) {
 		$nr++;
 		printf "%4i\t%s", $nr, escapeHTML($line);;
 	}
 	close $fd || print "Reading blob failed.\n";
-	print "

\n"; + print "
\n"; print "
"; git_footer_html(); -} elsif ($action eq "tree") { +} + +sub git_tree { if (!defined $hash) { - $hash = git_head($project); + $hash = git_read_head($project); + if (defined $file_name) { + my $base = $hash_base || git_read_head($project); + $hash = git_get_hash_by_path($base, $file_name, "tree"); + } } - open my $fd, "-|", "$gitbin/git-ls-tree $hash" || die_error("", "Open failed."); + open my $fd, "-|", "$gitbin/git-ls-tree $hash" || die_error(undef, "Open git-ls-tree failed."); my (@entries) = map { chomp; $_ } <$fd>; - close $fd || die_error("", "Reading tree failed."); + close $fd || die_error(undef, "Reading tree failed."); git_header_html(); - my %co = git_commit($hash); - if (%co) { + my $base_key = ""; + my $file_key = ""; + my $base = ""; + if (defined $hash_base && (my %co = git_read_commit($hash_base))) { + $base_key = ";hb=$hash_base"; print "
view\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "diffs") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree") . "

\n" . "
\n"; print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "
\n"; } else { print "
\n"; print "

\n"; print "
$hash
\n"; } + if (defined $file_name) { + $base = "$file_name/"; + print "
/$file_name
\n"; + } else { + print "
/
\n"; + } print "
\n"; - print "
\n";
+	print "
\n";
 	foreach my $line (@entries) {
 		#'100644	blob	0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa	panic.c'
 		$line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/;
@@ -562,8 +673,9 @@ if ($action eq "blob") {
 		my $t_type = $2;
 		my $t_hash = $3;
 		my $t_name = $4;
+		$file_key = ";f=$base$t_name";
 		if ($t_type eq "blob") {
-			print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash"}, $t_name);
+			print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, $t_name);
 			if (S_ISLNK(oct $t_mode)) {
 				open my $fd, "-|", "$gitbin/git-cat-file blob $t_hash";
 				my $target = <$fd>;
@@ -572,16 +684,18 @@ if ($action eq "blob") {
 			}
 			print "\n";
 		} elsif ($t_type eq "tree") {
-			print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash"}, $t_name) . "\n";
+			print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) . "\n";
 		}
 	}
 	print "
\n"; - print "
"; + print "
"; git_footer_html(); -} elsif ($action eq "rss") { - open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_head($project) || die_error("", "Open failed."); +} + +sub git_rss { + open my $fd, "-|", "$gitbin/git-rev-list --max-count=20 " . git_read_head($project) || die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; - close $fd || die_error("", "Reading rev-list failed."); + close $fd || die_error(undef, "Reading rev-list failed."); print $cgi->header(-type => 'text/xml', -charset => 'utf-8'); print "\n". @@ -593,7 +707,7 @@ if ($action eq "blob") { "en\n"; foreach my $commit (@revlist) { - my %co = git_commit($commit); + my %co = git_read_commit($commit); my %ad = date_str($co{'author_epoch'}); print "\n" . "\t" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "\n" . @@ -605,12 +719,12 @@ if ($action eq "blob") { } print "\t\n" . "\n"; - undef %ad; - undef %co; } print ""; -} elsif ($action eq "log") { - my $head = git_head($project); +} + +sub git_log { + my $head = git_read_head($project); my $limit_option = ""; if (!defined $time_back) { $limit_option = "--max-count=10"; @@ -618,9 +732,9 @@ if ($action eq "blob") { my $date = time - $time_back*24*60*60; $limit_option = "--max-age=$date"; } - open my $fd, "-|", "$gitbin/git-rev-list $limit_option $head" || die_error("", "Open failed."); + open my $fd, "-|", "$gitbin/git-rev-list $limit_option $head" || die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; - close $fd || die_error("", "Reading rev-list failed."); + close $fd || die_error(undef, "Reading rev-list failed."); git_header_html(); print "
\n"; @@ -635,16 +749,16 @@ if ($action eq "blob") { "
\n"; if (!@revlist) { - my %co = git_commit($head); + my %co = git_read_commit($head); print "
Last change " . $co{'age_string'} . ".

\n"; } foreach my $commit (@revlist) { - my %co = git_commit($commit); + my %co = git_read_commit($commit); next if !%co; my %ad = date_str($co{'author_epoch'}); print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, "" . $co{'age_string'} . "" . escapeHTML($co{'title'})) . "\n" . "
\n"; print "
\n" . @@ -656,40 +770,53 @@ if ($action eq "blob") { "
\n" . "
\n"; my $comment = $co{'comment'}; + my $empty = 0; foreach my $line (@$comment) { - last if ($line =~ m/^(signed-off|acked)-by:/i); - print escapeHTML($line) . "
\n"; + if ($line =~ m/^(signed.off|acked).by/i) { + next; + } + if ($line eq "") { + if ($empty) { + next; + } + $empty = 1; + } else { + $empty = 0; + } + print escapeHTML($line) . "
\n"; } - print "
\n" . - "
\n"; - undef %ad; - undef %co; + if (!$empty) { + print "
\n"; + } + print "
\n"; } git_footer_html(); -} elsif ($action eq "commit") { - my %co = git_commit($hash); +} + +sub git_commit { + my %co = git_read_commit($hash); if (!%co) { - die_error("", "Unknown commit object."); + die_error(undef, "Unknown commit object."); } my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'}); my @difftree; if (defined $co{'parent'}) { - open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error("", "Open failed."); + open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error(undef, "Open failed."); @difftree = map { chomp; $_ } <$fd>; - close $fd || die_error("", "Reading diff-tree failed."); + close $fd || die_error(undef, "Reading diff-tree failed."); } else { # fake git-diff-tree output for initial revision - open my $fd, "-|", "$gitbin/git-ls-tree -r $hash" || die_error("", "Open failed."); + open my $fd, "-|", "$gitbin/git-ls-tree -r $hash" || die_error(undef, "Open failed."); @difftree = map { chomp; "+" . $_ } <$fd>; - close $fd || die_error("", "Reading ls-tree failed."); + close $fd || die_error(undef, "Reading ls-tree failed."); } git_header_html(); print "
view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "\n" . "

\n"; if (defined $co{'parent'}) { print "
\n" . @@ -697,7 +824,7 @@ if ($action eq "blob") { "
\n"; } else { print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "
\n"; } print "
\n" . @@ -715,7 +842,7 @@ if ($action eq "blob") { sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "
commit$hash
tree" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, $co{'tree'}) . "
parent" . @@ -725,17 +852,32 @@ if ($action eq "blob") { "\n"; print "
\n"; my $comment = $co{'comment'}; + my $empty = 0; + my $signed = 0; foreach my $line (@$comment) { - if ($line =~ m/(signed-off|acked)-by:/i) { + # print only one empty line + if ($line eq "") { + if ($empty || $signed) { + next; + } + $empty = 1; + } else { + $empty = 0; + } + if ($line =~ m/(signed.off|acked).by/i) { + $signed = 1; print "" . escapeHTML($line) . "
\n"; } else { + $signed = 0; print escapeHTML($line) . "
\n"; } } print "
\n"; + print "
\n"; if ($#difftree > 10) { - print "
" . ($#difftree + 1) . " files changed:
\n"; + print(($#difftree + 1) . " files changed:\n"); } + print "
\n"; foreach my $line (@difftree) { # '*100644->100644 blob 9f91a116d91926df3ba936a80f020a6ab1084d2b->bb90a0c3a91eb52020d0db0e8b4f94d30e02d596 net/ipv4/route.c' # '+100644 blob 4a83ab6cd565d21ab0385bac6643826b83c2fcd4 arch/arm/lib/bitops.h' @@ -754,21 +896,21 @@ if ($action eq "blob") { $mode_chng = sprintf(" with mode: %04o", (oct $mode) & 0777); } print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, escapeHTML($file) . " [new " . file_type($mode) . $mode_chng . "]") . "\n" . "
"; print "
\n" . "view " . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "file") . "
\n" . "
\n"; } elsif ($op eq "-") { print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, escapeHTML($file) . " [deleted " . file_type($mode) . "]") . "\n" . "
"; print "
\n" . "view " . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, "file") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "file") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "
\n" . "
\n"; } elsif ($op eq "*") { @@ -795,58 +937,82 @@ if ($action eq "blob") { } print "
\n"; if ($to_id ne $from_id) { - print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id"}, + print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, escapeHTML($file) . $mode_chnge) . "\n" . "
\n"; } else { - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, escapeHTML($file) . $mode_chnge) . "\n" . "\n"; } print "
\n" . "view "; if ($to_id ne $from_id) { - print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id"}, "diff") . " | "; + print $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"}, "diff") . " | "; } - print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, "file") . " | " . + print $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, "file") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash;f=$file"}, "history") . "
\n" . "
\n"; } } } git_footer_html(); -} elsif ($action eq "blobdiff") { +} + +sub git_blobdiff { mkdir($gittmp, 0700); git_header_html(); - print "
\n"; - print "

\n"; - print "
$hash vs $hash_parent
\n"; + if (defined $hash_base && (my %co = git_read_commit($hash_base))) { + print "
view\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "diffs") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree"); + if (defined $file_name) { + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history"); + } + print "

\n" . + "
\n"; + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + "
\n"; + } else { + print "
\n" . + "

\n" . + "
$hash vs $hash_parent
\n"; + } + if (defined $file_name) { + print "
\n" . + "/$file_name\n" . + "
\n"; + } print "
\n" . "
\n";
 	print "blob:" .
-	      $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash_parent"}, $hash_parent) .
+	      $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name"}, $hash_parent) .
 	      " -> blob:" .
-	      $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash"}, $hash) .
+	      $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name"}, $hash) .
 	      "\n";
-	git_diff_html($hash_parent, $hash_parent, $hash, $hash);
+	git_diff_html($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);
 	print "
\n" . - "
"; + ""; git_footer_html(); -} elsif ($action eq "commitdiff") { +} + +sub git_commitdiff { mkdir($gittmp, 0700); - my %co = git_commit($hash); + my %co = git_read_commit($hash); if (!%co) { - die_error("", "Unknown commit object."); + die_error(undef, "Unknown commit object."); } - open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error("", "Open failed."); + open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error(undef, "Open failed."); my (@difftree) = map { chomp; $_ } <$fd>; - close $fd || die_error("", "Reading diff-tree failed."); + close $fd || die_error(undef, "Reading diff-tree failed."); git_header_html(); print "
view\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$hash"}, "tree") . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "\n" . "

\n"; print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . @@ -864,12 +1030,12 @@ if ($action eq "blob") { if ($type eq "blob") { if ($op eq "+") { print "" . file_type($mode) . ":" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $id) . "(new)" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, $id) . "(new)" . "\n"; git_diff_html(undef, "/dev/null", $id, "b/$file"); } elsif ($op eq "-") { print "" . file_type($mode) . ":" . - $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id"}, $id) . "(deleted)" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, $id) . "(deleted)" . "\n"; git_diff_html($id, "a/$file", undef, "/dev/null"); } elsif ($op eq "*") { @@ -881,9 +1047,9 @@ if ($action eq "blob") { my $to_mode = $2; if ($from_id ne $to_id) { print "" . - file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id"}, $from_id) . + file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"}, $from_id) . " -> " . - file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id"}, $to_id); + file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"}, $to_id); print "\n"; git_diff_html($from_id, "a/$file", $to_id, "b/$file"); } @@ -893,16 +1059,29 @@ if ($action eq "blob") { print "
\n"; print "
"; git_footer_html(); -} elsif ($action eq "history") { +} + +sub git_history { if (!defined $hash) { - $hash = git_head($project); + $hash = git_read_head($project); + } + my %co = git_read_commit($hash); + if (!%co) { + die_error(undef, "Unknown commit object."); } git_header_html(); - print "
\n"; - print "

\n"; + print "
view\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . + "

\n" . + "
\n"; print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($file_name)) . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "
\n"; + print "
\n" . + "/$file_name
\n"; + print "
\n"; open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin $file_name"; my $commit; while (my $line = <$fd>) { @@ -916,7 +1095,7 @@ if ($action eq "blob") { if ($file ne $file_name || $type ne "blob") { next; } - my %co = git_commit($commit); + my %co = git_read_commit($commit); if (!%co) { next; } @@ -927,15 +1106,11 @@ if ($action eq "blob") { print "
\n" . "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$commit"}, "tree") . "

\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") . "

\n" . "
\n"; - undef %co; undef $commit; } } close $fd; git_footer_html(); -} else { - undef $action; - die_error("", "Unknown action."); } -- cgit 1.2.3-korg From eb28240b64396e8dd35c79dd0158bcd80021fcc4 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:21:34 +0200 Subject: v121 --- gitweb.cgi | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 546b239720..2be26bdbbe 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "118"; +my $version = "121"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -460,7 +460,7 @@ sub date_str { } # git-logo (cached in browser for one day) -sub git_logo() { +sub git_logo { print $cgi->header(-type => 'image/png', -expires => '+1d'); # cat git-logo.png | hexdump -e '16/1 " %02x" "\n"' | sed 's/ /\\x/g' print "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" . @@ -510,15 +510,14 @@ sub git_project_list { @list = sort @list; git_header_html(); - print "
\n"; + print "

\n"; print "\n"; print "\n" . "\n" . "\n" . "\n" . "\n" . - "\n" . - "
"; + "\n"; foreach my $proj (@list) { my $head = git_read_head($proj); if (!defined $head) { @@ -614,7 +613,7 @@ sub git_blob { if (defined $file_name) { print "
/$file_name
\n"; } - print "
\n" .
+	print "
\n";
 	my $nr;
 	while (my $line = <$fd>) {
 		$nr++;
@@ -710,7 +709,7 @@ sub git_rss {
 		my %co = git_read_commit($commit);
 		my %ad = date_str($co{'author_epoch'});
 		print "\n" .
-		      "\t" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'min'}) . " - " . escapeHTML($co{'title'}) . "\n" .
+		      "\t" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'minute'}) . " - " . escapeHTML($co{'title'}) . "\n" .
 		      "\t " . $my_url . "?p=$project;a=commit;h=$commit\n" .
 		      "\t";
 		my $comment = $co{'comment'};
@@ -763,8 +762,9 @@ sub git_log {
 		      "
\n"; print "
\n" . "
\n" . - "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . "
\n" . + "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . + "
\n" . "
\n" . "" . escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]
\n" . "
\n" . @@ -1105,8 +1105,10 @@ sub git_history { "
\n"; print "
\n" . "view " . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") . "

\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=" . $file}, "file") . + "

\n" . "
\n"; undef $commit; } -- cgit 1.2.3-korg From 42f7eb94a0016125523cc24dbabfbf4ad5f60a59 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:21:46 +0200 Subject: v125 --- gitweb.cgi | 113 ++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 66 insertions(+), 47 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 2be26bdbbe..534edeaa8f 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -14,7 +14,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "121"; +my $version = "125"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -200,11 +200,13 @@ div.list_head { div.list a { text-decoration:none; color:#000000; } div.list a:hover { color:#880000; } div.link { - margin:0px 15px; padding:0px 6px 8px; border:solid #d9d8d1; border-width:0px 1px 1px; + margin:0px 15px; padding:4px 6px 6px; border:solid #d9d8d1; border-width:0px 1px 1px; font-family:sans-serif; font-size:10px; } td { padding:5px 15px 0px 0px; font-size:12px; } th { padding-right:10px; font-size:12px; text-align:left; } +td.link { font-family:sans-serif; font-size:10px; } +td.pre { font-family:monospace; font-size:12px; white-space:pre; padding:2px 15px 0px 0px; } span.diff_info { color:#000099; background-color:#edece6; font-style:italic; } a.rss_logo { float:right; padding:3px 0px; width:35px; line-height:10px; border:1px solid; border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e; @@ -257,6 +259,16 @@ sub die_error { exit; } +sub git_get_type { + my $hash = shift; + + open my $fd, "-|", "$gitbin/git-cat-file -t $hash" || return; + my $type = <$fd>; + close $fd; + chomp $type; + return $type; +} + sub git_read_head { my $path = shift; @@ -312,7 +324,11 @@ sub git_read_commit { $co{'parent'} = $parents[0]; my (@comment) = map { chomp; $_ } <$fd>; $co{'comment'} = \@comment; - $co{'title'} = $comment[0]; + $comment[0] =~ m/^(.{0,60}[^ ]*)/; + $co{'title'} = $1; + if ($comment[0] ne $co{'title'}) { + $co{'title'} .= " [...]"; + } close $fd || return; if (!defined $co{'tree'}) { return undef @@ -564,7 +580,7 @@ sub git_get_hash_by_path { while (my $part = shift @parts) { open my $fd, "-|", "$gitbin/git-ls-tree $tree" || die_error(undef, "Open git-ls-tree failed."); my (@entries) = map { chomp; $_ } <$fd>; - close $fd || die_error(undef, "Reading tree failed."); + close $fd || return undef; foreach my $line (@entries) { #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; @@ -594,9 +610,9 @@ sub git_blob { my $base = $file_name || ""; git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { - print "
view\n" . + print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "diffs") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree"); if (defined $file_name) { print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history"); @@ -643,9 +659,9 @@ sub git_tree { my $base = ""; if (defined $hash_base && (my %co = git_read_commit($hash_base))) { $base_key = ";hb=$hash_base"; - print "
view\n" . + print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "diffs") . " | " . + $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree") . "

\n" . "
\n"; @@ -664,7 +680,7 @@ sub git_tree { print "
/
\n"; } print "
\n"; - print "
\n";
+	print "
ProjectDescriptionOwnerlast change
\n"; foreach my $line (@entries) { #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' $line =~ m/^([0-9]+)\t(.*)\t(.*)\t(.*)$/; @@ -673,21 +689,23 @@ sub git_tree { my $t_hash = $3; my $t_name = $4; $file_key = ";f=$base$t_name"; + print "\n" . + "\n"; if ($t_type eq "blob") { - print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, $t_name); - if (S_ISLNK(oct $t_mode)) { - open my $fd, "-|", "$gitbin/git-cat-file blob $t_hash"; - my $target = <$fd>; - close $fd; - print "\t -> $target"; - } - print "\n"; + print "\n"; + print "\n"; } elsif ($t_type eq "tree") { - print mode_str($t_mode). " " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) . "\n"; + print "\n"; } + print "\n"; } - print "\n"; - print ""; + print "
" . mode_str($t_mode) . "$t_name" . + $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key}, "file") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base" . $file_key}, "history") . + "" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key}, $t_name) . + "
\n" . + "
"; git_footer_html(); } @@ -737,7 +755,6 @@ sub git_log { git_header_html(); print "
\n"; - print "view "; print $cgi->a({-href => "$my_uri?p=$project;a=log"}, "last 10") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=1"}, "day") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=log;t=7"}, "week") . " | " . @@ -762,8 +779,8 @@ sub git_log { "
\n"; print "
\n" . "
\n" . - "view " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "diff") . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") . "
\n" . "
\n" . "" . escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]
\n" . @@ -772,7 +789,7 @@ sub git_log { my $comment = $co{'comment'}; my $empty = 0; foreach my $line (@$comment) { - if ($line =~ m/^(signed.off|acked).by/i) { + if ($line =~ m/^(signed[ \-]off[\-]by[ :]|acked[\-]by[ \:]|cc[ :])/i) { next; } if ($line eq "") { @@ -813,10 +830,12 @@ sub git_commit { close $fd || die_error(undef, "Reading ls-tree failed."); } git_header_html(); - print "
view\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "diffs") . " | \n" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "\n" . + print "
\n" . + $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit"); + if (defined $co{'parent'}) { + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff"); + } + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "\n" . "

\n"; if (defined $co{'parent'}) { print "
\n" . @@ -838,8 +857,7 @@ sub git_commit { } print "
committer" . escapeHTML($co{'committer'}) . "
" . $cd{'rfc2822'} . - sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "
" . $cd{'rfc2822'} . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "
commit$hash
tree" . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=" . $hash}, $co{'tree'}) . "
" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . @@ -1556,6 +1578,7 @@ sub git_log { if (!defined $page) { $page = 0; } + my $refs = read_info_ref(); git_header_html(); print "
\n"; print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . @@ -1598,13 +1621,17 @@ sub git_log { } for (my $i = ($page * 100); $i <= $#revlist; $i++) { my $commit = $revlist[$i]; + my $ref = ""; + if (defined $refs->{$commit}) { + $ref = " $refs->{$commit}"; + } my %co = git_read_commit($commit); next if !%co; my %ad = date_str($co{'author_epoch'}); print "
\n" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "title"}, - "$co{'age_string'}" . esc_html($co{'title'})) . "\n" . - "
\n"; + "$co{'age_string'}" . esc_html($co{'title'}) . $ref) . "\n"; + print "
\n"; print "
\n" . "
\n" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . @@ -1981,23 +2008,18 @@ sub git_commitdiff_plain { # try to figure out the next tag after this commit my $tagname; - my %taghash; - my $tags = git_read_refs("refs/tags"); - foreach my $entry (@$tags) { - my %tag = %$entry; - $taghash{$tag{'refid'}} = $tag{'name'}; - } + my $refs = read_info_ref(); open $fd, "-|", "$gitbin/git-rev-list HEAD"; - while (my $commit = <$fd>) { - chomp $commit; - if ($taghash{$commit}) { - $tagname = $taghash{$commit}; + chomp (my (@commits) = <$fd>); + close $fd; + foreach my $commit (@commits) { + if (defined $refs->{$commit}) { + $tagname = $refs->{$commit} } if ($commit eq $hash) { last; } } - close $fd; print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\""); my %co = git_read_commit($hash); @@ -2041,6 +2063,7 @@ sub git_history { if (!%co) { die_error(undef, "Unknown commit object."); } + my $refs = read_info_ref(); git_header_html(); print "
\n" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . @@ -2070,6 +2093,10 @@ sub git_history { if (!%co) { next; } + my $ref = ""; + if (defined $refs->{$commit}) { + $ref = " $refs->{$commit}"; + } if ($alternate) { print "
$co{'age_string_date'}" . esc_html(chop_str($co{'author_name'}, 15, 3)) . "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "" . - esc_html(chop_str($co{'title'}, 50)) . "") . "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") . @@ -2254,6 +2281,7 @@ sub git_shortlog { if (!defined $page) { $page = 0; } + my $refs = read_info_ref(); git_header_html(); print "
\n" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") . @@ -2312,6 +2340,9 @@ sub git_shortlog { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "" . esc_html($co{'title_short'}) . ""); } + if (defined $refs->{$commit}) { + print " $refs->{$commit}"; + } print "
" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . -- cgit 1.2.3-korg From 4cdd1f9031fefce45423de13ad987bbde45e363e Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 7 Dec 2005 09:47:34 +0100 Subject: v258 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 01920b003f..605e4b5015 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "257"; +my $version = "258"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; -- cgit 1.2.3-korg From 045e531a8f2ef75605ec839d66d80abe126647b4 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 7 Dec 2005 10:12:55 +0100 Subject: show multiple tags Signed-off-by: Kay Sievers --- gitweb.cgi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index 605e4b5015..ad8c6deea1 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -912,7 +912,11 @@ sub read_info_ref { open my $fd, "$projectroot/$project/info/refs" or return; while (my $line = <$fd>) { if ($line =~ m/^([0-9a-fA-F]{40})\t.*\/([^\^]+)/) { - $refs{$1} = $2; + if (defined $refs{$1}) { + $refs{$1} .= " / $2"; + } else { + $refs{$1} = $2; + } } } close $fd or return; -- cgit 1.2.3-korg From 70dd8acb9a9c0964efcea114e68fea47021fdd37 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 7 Dec 2005 10:13:19 +0100 Subject: v259 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index ad8c6deea1..49206b11d7 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "258"; +my $version = "259"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; -- cgit 1.2.3-korg From 4df11910716b25bc7720ee25950c6b81734a2674 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 7 Dec 2005 10:51:42 +0100 Subject: attach tag to the link Signed-off-by: Kay Sievers --- gitweb.cgi | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 49206b11d7..f56d303690 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -312,7 +312,7 @@ a.rss_logo { } a.rss_logo:hover { background-color:#ee5500; } span.tag { - padding:0px 4px; font-size:10px; + padding:0px 4px; font-size:10px; font-weight:normal; background-color:#ffffaa; border:1px solid; border-color:#ffffcc #ffee00 #ffee00 #ffffcc; } @@ -906,12 +906,13 @@ sub git_project_list { } sub read_info_ref { + my $type = shift || ""; my %refs; # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11 # c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{} open my $fd, "$projectroot/$project/info/refs" or return; while (my $line = <$fd>) { - if ($line =~ m/^([0-9a-fA-F]{40})\t.*\/([^\^]+)/) { + if ($line =~ m/^([0-9a-fA-F]{40})\t.*$type\/([^\^]+)/) { if (defined $refs{$1}) { $refs{$1} .= " / $2"; } else { @@ -1047,18 +1048,19 @@ sub git_summary { } $alternate ^= 1; if ($i-- > 0) { + my $ref = ""; + if (defined $refs->{$commit}) { + $ref = " $refs->{$commit}"; + } print "$co{'age_string'}" . esc_html(chop_str($co{'author_name'}, 10)) . ""; if (length($co{'title_short'}) < length($co{'title'})) { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"}, - "" . esc_html($co{'title_short'}) . ""); + "" . esc_html($co{'title_short'}) . "$ref"); } else { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, - "" . esc_html($co{'title'}) . ""); - } - if (defined $refs->{$commit}) { - print " $refs->{$commit}"; + "" . esc_html($co{'title'}) . "$ref"); } print "" . @@ -2012,7 +2014,7 @@ sub git_commitdiff_plain { # try to figure out the next tag after this commit my $tagname; - my $refs = read_info_ref(); + my $refs = read_info_ref("tags"); open $fd, "-|", "$gitbin/git-rev-list HEAD"; chomp (my (@commits) = <$fd>); close $fd; @@ -2110,7 +2112,7 @@ sub git_history { print "$co{'age_string_date'}" . esc_html(chop_str($co{'author_name'}, 15, 3)) . "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "" . - esc_html(chop_str($co{'title'}, 50)) . "") . "$ref" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") . " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") . @@ -2326,6 +2328,10 @@ sub git_shortlog { my $alternate = 0; for (my $i = ($page * 100); $i <= $#revlist; $i++) { my $commit = $revlist[$i]; + my $ref = ""; + if (defined $refs->{$commit}) { + $ref = " $refs->{$commit}"; + } my %co = git_read_commit($commit); my %ad = date_str($co{'author_epoch'}); if ($alternate) { @@ -2339,13 +2345,10 @@ sub git_shortlog { ""; if (length($co{'title_short'}) < length($co{'title'})) { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"}, - "" . esc_html($co{'title_short'}) . ""); + "" . esc_html($co{'title_short'}) . "$ref"); } else { print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, - "" . esc_html($co{'title_short'}) . ""); - } - if (defined $refs->{$commit}) { - print " $refs->{$commit}"; + "" . esc_html($co{'title_short'}) . "$ref"); } print "" . -- cgit 1.2.3-korg From 4e8c09a331ca3917c45dfe646213b604af19db95 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 7 Dec 2005 10:51:59 +0100 Subject: v260 --- gitweb.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb.cgi b/gitweb.cgi index f56d303690..9222ca0fe7 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -17,7 +17,7 @@ use Fcntl ':mode'; binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "259"; +my $version = "260"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; -- cgit 1.2.3-korg From edde3735d06e2581647308966a6b7a77d09a1427 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 7 Dec 2005 16:10:01 +0100 Subject: more tags Signed-off-by: Kay Sievers --- gitweb.cgi | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 9222ca0fe7..1f5a409bf1 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -1050,7 +1050,7 @@ sub git_summary { if ($i-- > 0) { my $ref = ""; if (defined $refs->{$commit}) { - $ref = " $refs->{$commit}"; + $ref = " " . esc_html($refs->{$commit}) . ""; } print "$co{'age_string'}" . esc_html(chop_str($co{'author_name'}, 10)) . "