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

bug: when applying binary diffs, -p0 is ignored

From
CMColin McCabe <cmccabe@alumni.cmu.edu>
Date
Aug 24, 2012, 22:09 UTC
Message-ID
<CA+qbEUOw9zR1_kdXU=mB8_KADq2NRT_qxSvGT+SfS55dUM8j6A@mail.gmail.com>
I found a bug in git's handling of binary diff segments.

When applying binary diffs using -p0, the prefix (or --strip) argument is ignored.

For example, try this: git apply -p0 --binary <<'EOF'

diff --git a/init.tar.gz a/init.tar.gz
new file mode 100644
index 0000000000000000000000000000000000000000..
         386b94f511a17a8a3d62eb6cec14694cb9b9b51d
GIT binary patch
literal 118
zcmb2|=3qGT-8_JS`RzGFp(Y0bmIKvX{ySXzs`-OhSfm*K#a}SG%CY!eN_LjnjGuP-
zFH<V7m)|X1{OzyyaqIde8O2kg^q0P?b&0-p<;muDS-IC{I=+*S-L~Mn{_^zwEo=Tu
UurR>Dep|-nAGgFaXfQAU0L+LoA^-pY

literal 0
HcmV?d00001

EOF

It will create init.tar.gz, but in the root of the repository, not in a/

(Sorry if my mailer wraps the long index line)

cheers,
Colin McCabe
Next: Junio C Hamano
Message 1 of 2 in “bug: when applying binary diffs, -p0 is ignored”
  1. Colin McCabeAug 24, 2012
  2. Junio C HamanoAug 25, 2012

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.