git am error: "ошибка: при поиске:"
Бег git am
Я получаю ошибку выше. Сравнение от руки не вижу никаких проблем. Может кто-нибудь указать мне, где ошибка?
$ git am 0012-Do-not-die-when-something-nasty-happen-in-the-comman.patch --reject
Applying: Do not die when something nasty happen in the command
Checking patch lib/Devel/DebugHooks/CmdProcessor.pm...
error: while searching for:
return 0 unless $cmd && exists $DB::commands->{ $cmd };
# The command also should return defined value to keep interaction
if( defined (my $result = $DB::commands->{ $cmd }( $args_str )) ) {
return $result unless ref $result;
# Allow commands to evaluate $expr at a debugged script context
error: patch failed: lib/Devel/DebugHooks/CmdProcessor.pm:14
Applying patch lib/Devel/DebugHooks/CmdProcessor.pm with 1 reject...
Rejected hunk #1.
Patch failed at 0001 Do not die when something nasty happen in the command
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
.rej:
$ cat CmdProcessor.pm.rej
diff a/lib/Devel/DebugHooks/CmdProcessor.pm b/lib/Devel/DebugHooks/CmdProcessor.pm (rejected hunks)
@@ -14,7 +14,10 @@ sub process {
return 0 unless $cmd && exists $DB::commands->{ $cmd };
# The command also should return defined value to keep interaction
- if( defined (my $result = $DB::commands->{ $cmd }( $args_str )) ) {
+ my $result = eval { $DB::commands->{ $cmd }( $args_str ) };
+ do{ print $DB::OUT "'$cmd' command died: $@"; return 1; } if $@;
+
+ if( defined $result ) {
return $result unless ref $result;
# Allow commands to evaluate $expr at a debugged script context
источник:
$ cat CmdProcessor.pm
package Devel::DebugHooks::CmdProcessor;
sub process {
my( $dbg ) = shift;
my( $cmd, $args_str ) = shift =~ m/^([\w.]+)(?:\s+(.*))?$/;
$args_str //= '';
return 0 unless $cmd and exists $DB::commands->{ $cmd };
# The command also should return defined value to keep interaction
if( defined (my $result = $DB::commands->{ $cmd }( $args_str )) ) {
return $result unless ref $result;
# Allow commands to evaluate $expr at a debugged script context
if( ref( $result ) eq 'HASH' ) {
return $result->{ code }->(
$args_str
,DB::eval( $result->{ expr } ) # FIX: it is not evaled at script context
);
}
return $result;
}
else {
return;
}
return 0;
}
1;
окончание строки в Unix.
Пытаясь бежать git apply
Вручную выдает следующую ошибку:
$ git apply CmdProcessor.pm.rej
fatal: patch fragment without header at line 2: @@ -14,7 +14,10 @@ sub process {
1 ответ
Решение
Git ищет строку
вернуть 0, если $ cmd && не существует $DB::commands->{ $cmd };
но ваш код содержит строку
вернуть 0, если не $ cmd и существует $DB::commands->{ $cmd };
(Я отметил разницу между && и и), откуда патч не применяется.
Вы можете найти хороший учебник по разрешению конфликтов в git здесь.