* GIT Web Interface
@ 2005-04-19 0:44 Kay Sievers
2005-04-19 0:52 ` Petr Baudis
0 siblings, 1 reply; 7+ messages in thread
From: Kay Sievers @ 2005-04-19 0:44 UTC (permalink / raw)
To: git
I'm hacking on a simple web interface, cause I missed the bkweb too much.
It can't do much more than browse through the source tree and show the
log now, but that should change... :)
http://ehlo.org/~kay/gitweb.pl?project=linux-2.6
How can I get the files touched with a changeset and the corresponding
diffs belonging to it?
Thanks,
Kay
--
#!/usr/bin/perl
# This file is licensed under the GPL v2, or a later version
# (C) 2005, Kay Sievers <kay.sievers@vrfy.org>
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $query = new CGI;
my $gitbin = "/home/kay/bin";
my $gitroot = "/home/kay/public_html";
my $project = $query->param("project") || "";
my $action = $query->param("action") || "";
my $hash = $query->param("hash") || "";
my $projectroot = "$gitroot/$project";
$ENV{'SHA1_FILE_DIRECTORY'} = "$projectroot/.git/objects";
sub header {
print $query->header();
print $query->start_html("gitweb");
print $query->h1($project);
}
sub footer {
print $query->end_html();
}
if ($project eq "") {
open my $fd, "-|", "ls", "-1", $gitroot;
my (@path) = map { chomp; $_ } <$fd>;
close $fd;
header();
print "projects:<br/>\n";
foreach my $line (@path) {
if (-e "$gitroot/$line/.git/HEAD") {
print $query->a({-href => "gitweb.pl?project=$line"}, $line) . "<br/>\n";
}
}
footer();
exit;
}
if ($action eq "") {
print $query->redirect("gitweb.pl?project=$project&action=show_log");
exit;
}
if ($action eq "show_file") {
header();
print "<pre>\n";
open my $fd, "-|", "$gitbin/cat-file", "blob", $hash;
my $nr;
while (my $line = <$fd>) {
$nr++;
print "$nr\t$line";
}
close $fd;
print "</pre>\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();
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 "B\t" . $query->a({-href => "gitweb.pl?project=$project&action=show_file&hash=$3"}, $4) . "<br/>\n";
} elsif ($t_type eq "tree") {
print "T\t" . $query->a({-href => "gitweb.pl?project=$project&action=show_tree&hash=$3"}, $4) . "<br/>\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();
foreach my $rev (reverse sort @revtree) {
$rev =~ m/^([0-9]+) ([0-9a-fA-F]+)/;
my $time = $1;
my $commit = $2;
open my $fd, "-|", "$gitbin/cat-file", "commit", $commit;
print "commit $commit<br/>\n";
while (my $line = <$fd>) {
if ($line =~ m/^tree (.*)$/) {
print $query->a({-href => "gitweb.pl?project=$project&action=show_tree&hash=$1"}, $line) . "<br/>\n";
} elsif ($line =~ m/^(author|committer) (.*)/) {
$line =~ m/^(.*) (.*>) ([0-9]+) (.*)$/;
my $type = $1;
my $name = $2;
my $time = $3;
my $timezone = $4;
$name =~ s/</</;
$name =~ s/>/>/;
$time = gmtime($time);
print "$type $name $time $timezone<br/>\n";
} else {
$line =~ s/</</;
$line =~ s/>/>/;
print "$line<br/>\n";
}
}
close $fd;
print "====================================<br/><br/>\n";
}
footer();
} else {
header();
print "unknown action\n";
footer();
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: GIT Web Interface
2005-04-19 0:44 GIT Web Interface Kay Sievers
@ 2005-04-19 0:52 ` Petr Baudis
2005-04-19 15:59 ` Kay Sievers
0 siblings, 1 reply; 7+ messages in thread
From: Petr Baudis @ 2005-04-19 0:52 UTC (permalink / raw)
To: Kay Sievers; +Cc: git
Dear diary, on Tue, Apr 19, 2005 at 02:44:15AM CEST, I got a letter
where Kay Sievers <kay.sievers@vrfy.org> told me that...
> I'm hacking on a simple web interface, cause I missed the bkweb too much.
> It can't do much more than browse through the source tree and show the
> log now, but that should change... :)
> http://ehlo.org/~kay/gitweb.pl?project=linux-2.6
Hmm, looks nice for a start. (But you have obsolete git-pasky tree there! ;-)
> How can I get the files touched with a changeset and the corresponding
> diffs belonging to it?
diff-tree to get the list of files, you can do the corresponding diffs
e.g. by doing git diff -r tree1:tree2. Preferably make a patch for it
first to make it possible to diff individual files this way.
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: GIT Web Interface
2005-04-19 0:52 ` Petr Baudis
@ 2005-04-19 15:59 ` Kay Sievers
2005-04-19 16:52 ` Greg KH
0 siblings, 1 reply; 7+ messages in thread
From: Kay Sievers @ 2005-04-19 15:59 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
On Tue, 2005-04-19 at 02:52 +0200, Petr Baudis wrote:
> Dear diary, on Tue, Apr 19, 2005 at 02:44:15AM CEST, I got a letter
> where Kay Sievers <kay.sievers@vrfy.org> told me that...
> > I'm hacking on a simple web interface, cause I missed the bkweb too much.
> > It can't do much more than browse through the source tree and show the
> > log now, but that should change... :)
> > http://ehlo.org/~kay/gitweb.pl?project=linux-2.6
>
> Hmm, looks nice for a start. (But you have obsolete git-pasky tree there! ;-)
Yeah, it's fresh now. :)
> > How can I get the files touched with a changeset and the corresponding
> > diffs belonging to it?
>
> diff-tree to get the list of files, you can do the corresponding diffs
> e.g. by doing git diff -r tree1:tree2. Preferably make a patch for it
> first to make it possible to diff individual files this way.
Ah, nice! Got it working.
Thanks,
Kay
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: GIT Web Interface
2005-04-19 15:59 ` Kay Sievers
@ 2005-04-19 16:52 ` Greg KH
2005-04-19 17:19 ` Stéphane Fillod
2005-04-19 17:32 ` Kay Sievers
0 siblings, 2 replies; 7+ messages in thread
From: Greg KH @ 2005-04-19 16:52 UTC (permalink / raw)
To: Kay Sievers; +Cc: Petr Baudis, git
On Tue, Apr 19, 2005 at 05:59:45PM +0200, Kay Sievers wrote:
> On Tue, 2005-04-19 at 02:52 +0200, Petr Baudis wrote:
> > Dear diary, on Tue, Apr 19, 2005 at 02:44:15AM CEST, I got a letter
> > where Kay Sievers <kay.sievers@vrfy.org> told me that...
> > > I'm hacking on a simple web interface, cause I missed the bkweb too much.
> > > It can't do much more than browse through the source tree and show the
> > > log now, but that should change... :)
> > > http://ehlo.org/~kay/gitweb.pl?project=linux-2.6
> >
> > Hmm, looks nice for a start. (But you have obsolete git-pasky tree there! ;-)
>
> Yeah, it's fresh now. :)
>
> > > How can I get the files touched with a changeset and the corresponding
> > > diffs belonging to it?
> >
> > diff-tree to get the list of files, you can do the corresponding diffs
> > e.g. by doing git diff -r tree1:tree2. Preferably make a patch for it
> > first to make it possible to diff individual files this way.
>
> Ah, nice! Got it working.
Looks good, care to post the updated version?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: GIT Web Interface
2005-04-19 16:52 ` Greg KH
@ 2005-04-19 17:19 ` Stéphane Fillod
2005-04-19 17:32 ` Kay Sievers
1 sibling, 0 replies; 7+ messages in thread
From: Stéphane Fillod @ 2005-04-19 17:19 UTC (permalink / raw)
To: git
Greg KH <greg <at> kroah.com> writes:
[...]
> Looks good, care to post the updated version?
http://ehlo.org/~kay/
What about a git repo of gitweb?
gitweb2.pl is nice with the browse function. BTW, but there's a '1' artefact
right after the browse link in action=show_tree :-)
Kay, your script is really nice, good job!
Here are some random ideas:
* make *any* hash clickable instead of the (show xx) links.
Applicable in show_log, show_diff
* in show_diff, keep a back link to cset
* provide a download link in show_file (as well as show_cset/show_diff ?)
* obfuscate against spam the mail adresses in show_log?
* use of colors in show_log (commiter, author, ..)
* perhaps borrow some ideas from other SCM web interfaces besides BK
* kindly ask kernel.org to host your script one day?
All the best,
--
Stephane
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: GIT Web Interface
2005-04-19 16:52 ` Greg KH
2005-04-19 17:19 ` Stéphane Fillod
@ 2005-04-19 17:32 ` Kay Sievers
2005-04-19 17:41 ` Greg KH
1 sibling, 1 reply; 7+ messages in thread
From: Kay Sievers @ 2005-04-19 17:32 UTC (permalink / raw)
To: Greg KH; +Cc: Petr Baudis, git
On Tue, Apr 19, 2005 at 09:52:48AM -0700, Greg KH wrote:
> On Tue, Apr 19, 2005 at 05:59:45PM +0200, Kay Sievers wrote:
> > On Tue, 2005-04-19 at 02:52 +0200, Petr Baudis wrote:
> > > Dear diary, on Tue, Apr 19, 2005 at 02:44:15AM CEST, I got a letter
> > > where Kay Sievers <kay.sievers@vrfy.org> told me that...
> > > > I'm hacking on a simple web interface, cause I missed the bkweb too much.
> > > > It can't do much more than browse through the source tree and show the
> > > > log now, but that should change... :)
> > > > http://ehlo.org/~kay/gitweb.pl?project=linux-2.6
> > >
> > > Hmm, looks nice for a start. (But you have obsolete git-pasky tree there! ;-)
> >
> > Yeah, it's fresh now. :)
> >
> > > > How can I get the files touched with a changeset and the corresponding
> > > > diffs belonging to it?
> > >
> > > diff-tree to get the list of files, you can do the corresponding diffs
> > > e.g. by doing git diff -r tree1:tree2. Preferably make a patch for it
> > > first to make it possible to diff individual files this way.
> >
> > Ah, nice! Got it working.
>
> Looks good, care to post the updated version?
Sure, but expect it to change dramatically tonight. :)
Thanks,
Kay
--
#!/usr/bin/perl
# This file is licensed under the GPL v2, or a later version
# (C) 2005, Kay Sievers <kay.sievers@vrfy.org>
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $query = new CGI;
my $myself = "gitweb.pl";
my $gitbin = "/home/kay/bin";
my $gitroot = "/home/kay/public_html";
my $gittmp = "/tmp";
my $project = $query->param("project") || "";
my $action = $query->param("action") || "";
my $hash = $query->param("hash") || "";
my $parent = $query->param("parent") || "";
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;
sub header {
print $query->header();
print $query->start_html("gitweb");
if ($project ne "") {
print $query->h1($project);
print $query->a({-href => "$myself?project=$project&action=show_tree"}, "Browse Project") . "<br/>\n";
print $query->a({-href => "$myself?project=$project&action=show_log"}, "Show Log") . "<br/>\n";
print "<br/><br/>\n";
}
}
sub footer {
print $query->end_html();
}
if ($project eq "") {
open my $fd, "-|", "ls", "-1", $gitroot;
my (@path) = map { chomp; $_ } <$fd>;
close $fd;
header();
print "Projects:<br/><br/>\n";
foreach my $line (@path) {
if (-e "$gitroot/$line/.git/HEAD") {
print $query->a({-href => "$myself?project=$line"}, $line) . "<br/>\n";
}
}
footer();
exit;
}
if ($action eq "") {
print $query->redirect("$myself?project=$project&action=show_log");
exit;
}
if ($action eq "show_file") {
header();
print "<pre>\n";
open my $fd, "-|", "$gitbin/cat-file", "blob", $hash;
my $nr;
while (my $line = <$fd>) {
$nr++;
print "$nr\t$line";
}
close $fd;
print "</pre>\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 "<pre>\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" . $query->a({-href => "$myself?project=$project&action=show_file&hash=$3"}, $4) . "\n";
} elsif ($t_type eq "tree") {
print "DIR\t" . $query->a({-href => "$myself?project=$project&action=show_tree&hash=$3"}, $4) . "\n";
}
}
print "</pre>\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();
foreach my $rev (reverse sort @revtree) {
$rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/;
my $time = $1;
my $commit = $2;
my $parent = $3;
open my $fd, "-|", "$gitbin/cat-file", "commit", $commit;
print "commit $commit " . $query->a({-href => "$myself?project=$project&action=show_cset&hash=$commit&parent=$parent"}, "(show cset)") . "<br/>\n";
while (my $line = <$fd>) {
if ($line =~ m/^tree (.*)$/) {
print "$line " . $query->a({-href => "$myself?project=$project&action=show_tree&hash=$1"}, "(show tree)") . "<br/>\n";
} elsif ($line =~ m/^(author|committer) (.*)/) {
$line =~ m/^(.*) (.*>) ([0-9]+) (.*)$/;
my $type = $1;
my $name = $2;
my $time = $3;
my $timezone = $4;
$name =~ s/</</;
$name =~ s/>/>/;
$time = gmtime($time);
print "$type $name $time $timezone<br/>\n";
} else {
$line =~ s/</</;
$line =~ s/>/>/;
print "$line<br/>\n";
}
}
close $fd;
print "====================================<br/><br/>\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 "<pre>\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" . $query->a({-href => "$myself?project=$project&action=show_file&hash=$id"}, $file) . "\n";
} elsif ($op eq "-") {
print "DEL\t" . $query->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" . $query->a({-href => "$myself?project=$project&action=show_diff&hash=$old&parent=$new"}, $file) . "\n";
}
}
}
print "</pre>\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 "<pre>\n";
open my $fd, "-|", "/usr/bin/diff", "-L", "$hash", "-L", "$parent", "-u", "-p", "$gittmp/$hash", "$gittmp/$parent";
while (my $line = <$fd>) {
$line =~ s/</</;
$line =~ s/>/>/;
print $line;
}
close $fd;
unlink("$gittmp/$hash");
unlink("$gittmp/$parent");
print "</pre>\n";
footer();
} else {
header();
print "unknown action\n";
footer();
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: GIT Web Interface
2005-04-19 17:32 ` Kay Sievers
@ 2005-04-19 17:41 ` Greg KH
0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2005-04-19 17:41 UTC (permalink / raw)
To: Kay Sievers; +Cc: Petr Baudis, git
On Tue, Apr 19, 2005 at 07:32:42PM +0200, Kay Sievers wrote:
> On Tue, Apr 19, 2005 at 09:52:48AM -0700, Greg KH wrote:
> > On Tue, Apr 19, 2005 at 05:59:45PM +0200, Kay Sievers wrote:
> > > On Tue, 2005-04-19 at 02:52 +0200, Petr Baudis wrote:
> > > > Dear diary, on Tue, Apr 19, 2005 at 02:44:15AM CEST, I got a letter
> > > > where Kay Sievers <kay.sievers@vrfy.org> told me that...
> > > > > I'm hacking on a simple web interface, cause I missed the bkweb too much.
> > > > > It can't do much more than browse through the source tree and show the
> > > > > log now, but that should change... :)
> > > > > http://ehlo.org/~kay/gitweb.pl?project=linux-2.6
> > > >
> > > > Hmm, looks nice for a start. (But you have obsolete git-pasky tree there! ;-)
> > >
> > > Yeah, it's fresh now. :)
> > >
> > > > > How can I get the files touched with a changeset and the corresponding
> > > > > diffs belonging to it?
> > > >
> > > > diff-tree to get the list of files, you can do the corresponding diffs
> > > > e.g. by doing git diff -r tree1:tree2. Preferably make a patch for it
> > > > first to make it possible to diff individual files this way.
> > >
> > > Ah, nice! Got it working.
> >
> > Looks good, care to post the updated version?
>
> Sure, but expect it to change dramatically tonight. :)
Ok, how about putting a link to it somewhere then, so you don't have to
be bothered with people like me asking for the latest copy? :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-04-19 17:38 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-19 0:44 GIT Web Interface Kay Sievers
2005-04-19 0:52 ` Petr Baudis
2005-04-19 15:59 ` Kay Sievers
2005-04-19 16:52 ` Greg KH
2005-04-19 17:19 ` Stéphane Fillod
2005-04-19 17:32 ` Kay Sievers
2005-04-19 17:41 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).