Solving the `NONE' problem
Tom Tromey
tromey@redhat.com
Tue Apr 1 21:25:00 GMT 2003
Today I thought of a way to solve the `NONE' problem we have with
cvsweb URLs. The idea is to run `co -p' on the ,v file and diff that
against /dev/null.
A first patch is appended. It isn't perfect, since it will fail if
the file name has shell metacharacters in it. We'd have to quote some
of the arguments to fix this.
Also, it doesn't generate output exactly like rcsdiff. The rcsdiff
header looks like this:
===================================================================
RCS file: /home/tromey/gnu/CVSROOT/automake/COPYING,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- automake/COPYING 1997/05/06 05:28:59 1.3
+++ automake/COPYING 1997/06/01 22:54:18 1.4
... whereas the NONE case looks like this:
/home/tromey/gnu/CVSROOT/automake/COPYING,v --> standard output
revision 1.1
--- automake/COPYING
+++ - Tue Apr 1 14:09:40 2003
I don't know whether this matters.
I don't have time to finish this right now. I just wanted to test it
since I thought of it when I woke up this morning. I've put it on my
to-do list, but if someone wants to clean it up, that would be cool.
Meanwhile, I was hoping someone could say whether the header
differences matter, or whether there's some diff option I overlooked
to change the output.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* cvsweb.cgi (doDiff): Run co directly when first revision is
NONE.
Index: cvsweb.cgi
===================================================================
RCS file: /cvs/sourceware/cgi-bin/cvsweb.cgi,v
retrieving revision 1.38
diff -u -r1.38 cvsweb.cgi
--- cvsweb.cgi 19 Sep 2001 02:46:17 -0000 1.38
+++ cvsweb.cgi 1 Apr 2003 21:20:53 -0000
@@ -1307,7 +1307,8 @@
}
# make sure the revisions a wellformed, for security
# reasons ..
- if (!($rev1 =~ /^[\d\.]+$/) || !($rev2 =~ /^[\d\.]+$/)) {
+ if (!($rev1 =~ /^[\d\.]+$/ || $rev1 eq 'NONE')
+ || !($rev2 =~ /^[\d\.]+$/)) {
&fatal("404 Not Found",
"Malformed query \"$ENV{'QUERY_STRING'}\"");
}
@@ -1361,7 +1362,15 @@
}
if (! open($fh, "-|")) { # child
open(STDERR, ">&STDOUT"); # Redirect stderr to stdout
- exec("rcsdiff",@difftype,"-r$rev1","-r$rev2",$fullname);
+ if ($rev1 eq "NONE") {
+ # Run special diff command.
+ # FIXME: quoting.
+ my $cmd = join(' ', ("co -p$rev2 $fullname | diff --label=$fullname",
+ @difftype, "/dev/null -"));
+ exec($cmd);
+ } else {
+ exec("rcsdiff",@difftype,"-r$rev1","-r$rev2",$fullname);
+ }
}
if ($human_readable) {
http_header();
More information about the Overseers
mailing list