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

git apply: git diff header lacks filename information for git diff --no-index patch

From
Imre Deak <imre.deak@gmail.com>
Date
Oct 2, 2008, 18:27 UTC
Message-ID
<500f3d130810021127j570bb540p901f6a73f58a6cb1@mail.gmail.com>
Hi,
I have the following problem:

$ echo -e '\x0' > a $ git diff --no-index --binary /dev/null a > patch $ rm a $ git apply patch fatal: git diff header lacks filename information (line 4) $ cat patch

diff --git a/dev/null b/a
new file mode 100644
index 0000000000000000000000000000000000000000..1f2a4f5ef3df7f7456d91c961da36fc58904f2f1
GIT binary patch
literal 2
JcmZSJ0ssIE01E&B

literal 0
HcmV?d00001

The same works for text based patches:

$ echo 1 > a
$ git diff --no-index /dev/null a > patch
$ rm a
$ git apply patch
$ ls
a
$ cat patch
diff --git a/dev/null b/a
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/a
@@ -0,0 +1 @@
+1

The binary patch lacks ---/+++ lines but still provides the name info
on the diff --git line which I think should suffice for git apply.

--Imre
Next: Jeff King
Message 1 of 10 in “git apply: git diff header lacks filename information for git diff --no-index patch”
  1. Imre DeakOct 2, 2008
  2. Jeff KingOct 4, 2008
  3. Jakub NarebskiOct 4, 2008
  4. Jeff KingOct 5, 2008
  5. Linus TorvaldsOct 4, 2008
  6. Linus TorvaldsOct 4, 2008
  7. Linus TorvaldsOct 4, 2008
  8. Jeff KingOct 5, 2008
  9. Jeff KingOct 5, 2008
  10. Jeff KingOct 5, 2008

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.