git: patch does not apply

15,131 views
Skip to first unread message

DP

unread,
Jan 26, 2011, 11:41:22 AM1/26/11
to msysGit
Hello!

I have a certain patch called my_pcc_branch.patch.

When I try to apply it, I get following message:

$ git apply --check my_pcc_branch.patch
warning: src/main/java/.../AbstractedPanel.java has type 100644,
expected 100755
error: patch failed: src/main/java/.../AbstractedPanel.java:13
error: src/main/java/.../AbstractedPanel.java: patch does not apply

What does it mean?

How can I fix this problem?

Notes:

1) I posted this question on StackOverflow and tried out several
things suggested there.

http://stackoverflow.com/questions/4770177/git-patch-does-not-apply

However, I don't have a working solution yet.

2) I'm using git 1.7.3.1.mysgit.0 under Windows 7. The author of the
patch uses Windows XP.

Thanks in advance

Dmitri

Johannes Sixt

unread,
Jan 26, 2011, 2:24:45 PM1/26/11
to DP, msy...@googlegroups.com
On Mittwoch, 26. Januar 2011, DP wrote:
> I have a certain patch called my_pcc_branch.patch.
>
> When I try to apply it, I get following message:
>
> $ git apply --check my_pcc_branch.patch
> warning: src/main/java/.../AbstractedPanel.java has type 100644,
> expected 100755

You can ignore this for the moment; it's just a warning and not the reason
that the patch does not apply.

> error: patch failed: src/main/java/.../AbstractedPanel.java:13
> error: src/main/java/.../AbstractedPanel.java: patch does not apply
>
> What does it mean?

It means that git-apply did not find identical context lines that are
specified in the patch.

> How can I fix this problem?

First try:

git apply -C1 ...

reduces the context around additions that are regarded as important.

Then try --ignore-space-change, --ignore-whitespace in addition.

If this does not help, use

git apply -v --check ...

to see what git-apply was looking for. Check whether this exact text is
present in the file. If it is not, you could edit the patch context to match
the actual program text (or vice versa) (disclaimer: if you do that, please
do not come back here to ask questions; you are expected to know what you are
doing ;-) --recount is your friend).

Lastly, ask your patch submitter to rebase the change to a commit that is
closer to what you have.

-- Hannes

Reply all
Reply to author
Forward
0 new messages