From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 9C0E721432 for ; Mon, 21 Jan 2019 20:52:58 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 22/37] solver: restore diagnostics and deal with CRLF Date: Mon, 21 Jan 2019 20:52:38 +0000 Message-Id: <20190121205253.10455-23-e@80x24.org> In-Reply-To: <20190121205253.10455-1-e@80x24.org> References: <20190121205253.10455-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Apparently Email::MIME returns quoted-printable text with CRLF. So use --ignore-whitespace with git-apply(1) and ensure we don't capture '\r' in pathnames from those emails. And restore "$@" dumping when we die while solving. --- lib/PublicInbox/SolverGit.pm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm index 1306534..8fde232 100644 --- a/lib/PublicInbox/SolverGit.pm +++ b/lib/PublicInbox/SolverGit.pm @@ -105,6 +105,11 @@ sub extract_diff ($$$$) { my ($path_a, $path_b) = ($1, $2); + # diff header lines won't have \r because git + # will quote them, but Email::MIME gives CRLF + # for quoted-printable: + $path_b =~ tr/\r//d; + # don't care for leading 'a/' and 'b/' my (undef, @a) = split(m{/}, git_unquote($path_a)); my (undef, @b) = split(m{/}, git_unquote($path_b)); @@ -248,8 +253,11 @@ sub do_apply_begin ($$$) { defined(my $err_fd = fileno($out)) or die "fileno(out): $!"; my $rdr = { 0 => fileno($tmp), 1 => $err_fd, 2 => $err_fd }; + + # we need --ignore-whitespace because some patches are CRLF my $cmd = [ qw(git -C), $wt_dir, - qw(apply --cached --whitespace=warn --verbose) ]; + qw(apply --cached --ignore-whitespace + --whitespace=warn --verbose) ]; spawn($cmd, undef, $rdr); } @@ -425,8 +433,12 @@ sub solve ($$$$) { }; while (1) { - my $ret = $cb->(); - return $ret if (ref($ret) || !defined($ret)); + my $ret = eval { $cb->() }; + unless (defined($ret)) { + print $out "E: $@\n" if $@; + return; + } + return $ret if ref($ret); # $ret == ''; so continue looping here } } -- EW