]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
solver: use git_quote on filenames for diagnostics
authorEric Wong <e@80x24.org>
Wed, 26 Mar 2025 03:34:59 +0000 (03:34 +0000)
committerEric Wong <e@80x24.org>
Thu, 27 Mar 2025 08:52:06 +0000 (08:52 +0000)
git_quote output makes more sense than relying on \Q..\E from
Perl or even Data::Dumper since these filenames are from git
output and more users are likely familiar with git-style quoting
than anything Perl-specific.

lib/PublicInbox/SolverGit.pm

index e30761e251ee70c6c9cb45fd7f3d6feafbec8f2f..3226101305c07b1cd2cc39752815ada5dc67d5ef 100644 (file)
@@ -472,15 +472,16 @@ sub parse_ls_files ($$) {
        my $di = $self->{-cur_di};
        my @ls = split(/\0/, $$bref);
        my ($line, @extra) = grep(/\t\Q$di->{path_b}\E\z/, @ls);
-       scalar(@extra) and die "BUG: extra files in index: <",
-                               join('> <', $line, @extra), ">";
-       $line // die "no \Q$di->{path_b}\E in <",join('> <', @ls), '>';
+       scalar(@extra) and die 'BUG? extra files in index:',
+                               (map { "\n\t".git_quote($_) } ($line, @extra));
+       $line // die 'BUG? no ', git_quote($di->{path_b}), ' in',
+                               (map { "\n\t".git_quote($_) } @ls);
        my ($info, $file) = split(/\t/, $line, 2);
        my ($mode_b, $oid_b_full, $stage) = split(/ /, $info);
-       $file eq $di->{path_b} or die
-"BUG: index mismatch: file=$file != path_b=$di->{path_b}";
+       $file eq $di->{path_b} or die "BUG? index mismatch: file=",
+               git_quote($file), ' != path_b=', git_quote($di->{path_b});
 
-       dbg($self, "index at:\n$mode_b $oid_b_full\t$file");
+       dbg($self, "index at:\n$mode_b $oid_b_full\t".git_quote($file));
        my $tmp_git = $self->{tmp_git} or die 'no git working tree';
        if ($self->{psgi_env}->{'pi-httpd.async'}) {
                async_check { git => $tmp_git }, $oid_b_full,