X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FViewVCS.pm;h=3b4fa393ed3ff16436db04a0dc3259d62825edbf;hb=35b7adee1f01a7cce720d944e1666aa44717d024;hp=a5545bcd344aba5bda386ee2274dd081be740e3c;hpb=d03cb41b664aa6cd72fd87f7f88a54e80b976960;p=public-inbox.git diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm index a5545bcd..3b4fa393 100644 --- a/lib/PublicInbox/ViewVCS.pm +++ b/lib/PublicInbox/ViewVCS.pm @@ -136,8 +136,7 @@ sub show_commit_start { # ->psgi_qx callback chop(my $buf = do { local $/ = "\0"; <$fh> }); chomp $buf; my ($P, $p); - ($P, $p, @$ctx{qw(cmt_H cmt_T cmt_s cmt_f cmt_au cmt_co cmt_b)}) - = split(/\n/, $buf, 9); + ($P, $p, @{$ctx->{cmt_info}}) = split(/\n/, $buf, 9); return cmt_finalize($ctx) if !$P; @{$ctx->{-cmt_P}} = split(/ /, $P); @{$ctx->{-cmt_p}} = split(/ /, $p); # abbreviated @@ -157,8 +156,8 @@ sub cmt_finalize { my ($ctx) = @_; $ctx->{-linkify} //= PublicInbox::Linkify->new; my $upfx = $ctx->{-upfx} = '../../'; # from "/$INBOX/$OID/s/" + my ($H, $T, $s, $f, $au, $co, $bdy) = @{delete $ctx->{cmt_info}}; # try to keep author and committer dates lined up - my ($au, $co) = delete @$ctx{qw(cmt_au cmt_co)}; my $x = length($au) - length($co); if ($x > 0) { $x = ' ' x $x; @@ -175,46 +174,44 @@ sub cmt_finalize { href="$upfx?t=$t" title="list contemporary emails">$2) !e; - my $s = $ctx->{-linkify}->to_html(delete $ctx->{cmt_s}); - $ctx->{-title_html} = $s; + $ctx->{-title_html} = $s = $ctx->{-linkify}->to_html($s); my ($P, $p, $pt) = delete @$ctx{qw(-cmt_P -cmt_p -cmt_pt)}; $_ = qq().shift(@$p).' '.shift(@$pt) for @$P; if (@$P == 1) { $x = qq{ (patch)\n parent $P->[0]}; +href="$f.patch">patch)\n parent $P->[0]}; } elsif (@$P > 1) { - $x = qq(\n parents $P->[0]\n); + $x = qq(\n parents $P->[0]\n); shift @$P; $x .= qq( $_\n) for @$P; chop $x; } else { - $x = ' (root commit)'; + $x = ' (root commit)'; } PublicInbox::WwwStream::html_init($ctx); $ctx->zmore(< commit $ctx->{cmt_H}$x - tree $ctx->{cmt_T} +
   commit $H$x
+     tree $T
    author $au
 committer $co
 
 $s
 EOM
-	$x = delete $ctx->{cmt_b};
-	$ctx->zmore("\n", $ctx->{-linkify}->to_html($x)) if length($x);
-	undef $x;
+	$ctx->zmore("\n", $ctx->{-linkify}->to_html($bdy)) if length($bdy);
+	$bdy = '';
 	open my $fh, '<:utf8', "$ctx->{-tmp}/p" or
 		die "open $ctx->{-tmp}/p: $!";
 	if (-s $fh > $MAX_SIZE) {
 		$ctx->zmore("---\n patch is too large to show\n");
 	} else { # prepare flush_diff:
-		$ctx->{obuf} = \$x;
+		read($fh, $x, -s _);
+		$ctx->{obuf} = \$bdy;
 		$ctx->{-apfx} = $ctx->{-spfx} = $upfx;
-		read($fh, my $bdy, -s _);
-		$bdy =~ s/\r?\n/\n/gs;
-		$ctx->{-anchors} = {} if $bdy =~ /^diff --git /sm;
-		flush_diff($ctx, \$bdy); # undefs $bdy
-		$ctx->zmore($x);
-		undef $x;
+		$x =~ s/\r?\n/\n/gs;
+		$ctx->{-anchors} = {} if $x =~ /^diff --git /sm;
+		flush_diff($ctx, \$x); # undefs $x
+		$ctx->zmore($bdy);
+		undef $bdy;
 		# TODO: should there be another textarea which attempts to
 		# search for the exact email which was applied to make this
 		# commit?
@@ -241,7 +238,24 @@ id=related>
find related emails, including ancestors/descendants/conflicts
 EOM
 		}
 	}
-	$x = $ctx->zflush($ctx->_html_end);
+	chop($x = <
glossary
+--------
+Commit objects reference one tree, and zero or more parents.
+
+Single parent commits can typically generate a patch in
+unified diff format via `git format-patch'.
+
+Multiple parents means the commit is a merge.
+
+Root commits have no ancestor.  Note that it is
+possible to have multiple root commits when merging independent histories.
+
+Every commit references one top-level tree object.
+EOM + $x = $ctx->zflush($x, $ctx->_html_end); my $res_hdr = delete $ctx->{-res_hdr}; push @$res_hdr, 'Content-Length', length($x); delete($ctx->{env}->{'qspawn.wcb'})->([200, $res_hdr, [$x]]); @@ -401,7 +415,7 @@ sub solve_result { return stream_large_blob($ctx, $res) if defined $ctx->{fn}; return html_page($ctx, 200, <Too big to show, download available -"$oid $type $size bytes $raw_link
+blob $oid $size bytes $raw_link
EOM } @@ -420,7 +434,7 @@ EOM } $bin and return html_page($ctx, 200, - "
$oid $type $size bytes (binary)" .
+				"
blob $oid $size bytes (binary)" .
 				" $raw_link
".dbg_log($ctx)); # TODO: detect + convert to ensure validity @@ -436,7 +450,7 @@ EOM $$blob = ascii_html($$blob); } - my $x = "
$oid $type $size bytes $raw_link
" . + my $x = "
blob $oid $size bytes $raw_link
" . "
". "
";
 	$x .= sprintf("% ${pad}u\n", $_) for (1..$nl);