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

Re: Problem with git-apply?

From
Jakub Narebski <jnareb@gmail.com>
Date
Nov 4, 2006, 09:26 UTC
Message-ID
<eihmas$8sj$1@sea.gmane.org>
In-Reply-To
<20061104072349.GA19667@cubit>
Kevin Shanahan wrote:
Show 12 quoted lines
> I seem to be having problems using git-apply to apply any patch which
> creates a new file. Unfortunately it's been a few weeks since I last
> used git here locally, but this seems like some behaviour change since
> the last version I was using. I'm currently using version 1.4.3.3 from
> Debian Sid. This little test script demonstrates the problem I'm
> having:
> 
> #!/bin/sh
> 
> mkdir a b repo
> echo foo > b/foo
> diff -urN a b > test.diff
Which produces the following diff:
diff -urN a/foo b/foo
--- a/foo       1970-01-01 01:00:00.000000000 +0100
+++ b/foo       2006-11-04 10:05:04.000000000 +0100
@@ -0,0 +1 @@
+foo
 
> (
>     cd repo
>     echo bar > bar # need something to init the db
>     git init-db
>     git add .
>     git commit -a -m "Test Commit"
> 
>     git apply ../test.diff
>     git commit -a -m "Test Commit (file added)"
> )
> 
> Here, this outputs for me:
> 
> defaulting to local storage area
> Committing initial tree ee314a31b622b027c10981acaed7903a3607dbd4
> error: foo: No such file or directory
> nothing to commit

This I think is a bug, or rather misfeature in git-apply (or at least
inconsistency between GNU diff and git patch format). But if you change
from-file line from "--- a/foo" to "--- /dev/null" then git-apply happily
applies creation patch and creates file.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Previous: Kevin ShanahanNext: Kevin Shanahan
Message 4 of 11 in “Problem with git-apply?”
  1. Kevin ShanahanNov 4, 2006
  2. Shawn PearceNov 4, 2006
  3. Kevin ShanahanNov 4, 2006
  4. Jakub NarebskiNov 4, 2006
  5. Kevin ShanahanNov 4, 2006
  6. Junio C HamanoNov 4, 2006
  7. Junio C HamanoNov 4, 2006
  8. Junio C HamanoNov 4, 2006
  9. Kevin ShanahanNov 4, 2006
  10. Linus TorvaldsNov 4, 2006
  11. Junio C HamanoNov 4, 2006

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.