-# user_cb for SolverGit, called as: user_cb->($result_or_error, $uarg)
-sub solve_result {
- my ($res, $ctx) = @_;
- my ($log, $hints, $fn) = delete @$ctx{qw(lh hints fn)};
-
- unless (seek($log, 0, 0)) {
- warn "seek(log): $!";
- return html_page($ctx, 500, \'seek error');
+sub show_tree_result ($$) {
+ my ($bref, $ctx) = @_;
+ if (my $qsp_err = delete $ctx->{-qsp_err}) {
+ return html_page($ctx, 500, dbg_log($ctx) .
+ "git ls-tree -z error:$qsp_err");
+ }
+ my @ent = split(/\0/, $$bref);
+ my $qp = delete $ctx->{qp};
+ my $l = $ctx->{-linkify} //= PublicInbox::Linkify->new;
+ my $pfx = $ctx->{-path} // $qp->{b}; # {-path} is from RepoTree
+ $$bref = "<pre><a href=#tree>tree</a> $ctx->{tree_oid}";
+ # $REPO/tree/$path already sets {-upfx}
+ my $upfx = $ctx->{-upfx} //= '../../';
+ if (defined $pfx) {
+ $pfx =~ s!/+\z!!s;
+ if (my $t = $ctx->{-obj}) {
+ my $t = ascii_html($t);
+ $$bref .= <<EOM
+\n\$ git ls-tree -l $t # shows similar output on the CLI
+EOM
+ } elsif ($pfx eq '') {
+ $$bref .= " (root)\n";
+ } else {
+ my $x = ascii_html($pfx);
+ $pfx .= '/';
+ $$bref .= qq( <a href=#path>path</a>: $x</a>\n);
+ }
+ } else {
+ $pfx = '';
+ $$bref .= qq[ (<a href=#path>path</a> unknown)\n];
+ }
+ my ($x, $m, $t, $oid, $sz, $f, $n);
+ $$bref .= "\n size name";
+ for (@ent) {
+ ($x, $f) = split(/\t/, $_, 2);
+ undef $_;
+ ($m, $t, $oid, $sz) = split(/ +/, $x, 4);
+ $m = $GIT_MODE{$m} // '?';
+ utf8::decode($f);
+ $n = ascii_html($f);
+ if ($m eq 'g') { # gitlink submodule commit
+ $$bref .= "\ng\t\t$n @ <a\nhref=#g>commit</a>$oid";
+ next;
+ }
+ my $q = 'b='.ascii_html(uri_escape_path($pfx.$f));
+ if ($m eq 'd') { $n .= '/' }
+ elsif ($m eq 'x') { $n = "<b>$n</b>" }
+ elsif ($m eq 'l') { $n = "<i>$n</i>" }
+ $$bref .= qq(\n$m\t$sz\t<a\nhref="$upfx$oid/s/?$q">$n</a>);