diff options
author | Eric Wong <e@80x24.org> | 2019-01-19 21:57:26 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-01-20 04:24:54 +0000 |
commit | db62b87e5f844bba54f7323f42f9630208b13841 (patch) | |
tree | 8afb09fa079254dd600176ea967a779dcaf1f64a /lib/PublicInbox/SolverGit.pm | |
parent | f82593fc84a6773cd6fcb0633fdcca4cee92859f (diff) | |
download | public-inbox-db62b87e5f844bba54f7323f42f9630208b13841.tar.gz |
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.
Diffstat (limited to 'lib/PublicInbox/SolverGit.pm')
-rw-r--r-- | lib/PublicInbox/SolverGit.pm | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm index 13065348..8fde2329 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 } } |