git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Using git am -p 2 with binary patches

From
PGPico Geyer <pico@xiplink.com>
Date
May 31, 2010, 15:59 UTC
Message-ID
<4C03DCE1.2000201@xiplink.com>
Hi all.

I've been trying to apply a set of patches from one repository to a completely independent repository (no shared history). Since the paths are different, I'm applying the patches with git am -p 2 I noticed that whenever my patches contain binary files, git-am fails to apply the patch.

Here's a simple test case: mkdir gittmp cd gittmp git init mkdir subdir echo "abcdefghijklmnop" > blah.txt tar -czf subdir/binfile.tgz blah.txt git add subdir/binfile.tgz git commit -m "Added binary file" git format-patch --root HEAD git am -p 2 0001-Added-binary-file.patch

And the output that I get is:
Applying: Added binary file
fatal: git diff header lacks filename information when removing 2 leading pathname components (line 9)
Patch failed at 0001 Added binary file
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".

Is this a bug in git-am or git-apply? Or is there a good reason why this doesn't work?

I'm using the latest git version (1.7.1)

Thanks in advance. Pico

Message 1 of 1 in “Using git am -p 2 with binary patches”
  1. Pico GeyerMay 31, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.