Re: [BUG] Apply patches failed without any changes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Nov 17, 2024 at 08:40:06PM +0800, Ylarod wrote:

> ```
> Applying: Florida: string_frida_rpc
> Applying: Florida: frida_agent_so
> Applying: Florida: symbol_frida_agent_main
> .git/rebase-apply/patch:126: trailing whitespace.
> 
> error: patch failed: lib/agent/frida-agent.def:1
> error: lib/agent/frida-agent.def: patch does not apply
> error: patch failed: tests/labrats/agent.def:1
> error: tests/labrats/agent.def: patch does not apply
> Patch failed at 0003 Florida: symbol_frida_agent_main
> hint: Use 'git am --show-current-patch=diff' to see the failed patch
> hint: When you have resolved this problem, run "git am --continue".
> hint: If you prefer to skip this patch, run "git am --skip" instead.
> hint: To restore the original branch and stop patching, run "git am --abort".
> hint: Disable this message with "git config advice.mergeConflict false"
> ```

Your .def files have CRLF line endings:

  $ git show --oneline 357374cfbbcb '*/frida-agent.def' | cat -A
  357374cf Florida: symbol_frida_agent_main$
  diff --git a/lib/agent/frida-agent.def b/lib/agent/frida-agent.def$
  index 7634e3fd..dc297d6f 100644$
  --- a/lib/agent/frida-agent.def$
  +++ b/lib/agent/frida-agent.def$
  @@ -1,2 +1,2 @@$
   EXPORTS^M$
  -^Ifrida_agent_main^M$
  +^Imain^M$

The email format created by format-patch puts the diff inline in a
text/plain email part. And since emails use CRLF as the line terminator,
they are stripped when it is read back in by git-am. So it tries to
apply the change above _without_ the extra CR, and we fail to find the
context.

You can use "git am --keep-cr" to retain the literal line endings on the
diff. This would work for the commands you showed above, but I suspect
would be a problem if you were actually sending the emails to somebody
else (since the mail transport would probably normalize everything to
CRLF).

To robustly send them you'd either have to:

  - send a binary patch. I don't think there's an easy way to ask for
    this for a particular format-patch invocation. You'd probably have
    to mark them with .gitattributes which would also suppress diffs,
    etc.

  - store the files in the repository with regular LF endings. If it's
    important that they have CRLF in the working tree, you can use
    attributes to convert them on checkout. See "End-of-line conversion"
    in "git help attributes".

-Peff




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux