# git-apply fails on creating a new file, with both -p and --directory specified

2 messages from 2010-04-28 to 2010-04-29. Participants: Matthias Lehmann.
Thread: https://gitlist.dev/t/23629

## Matthias Lehmann, 2010-04-28 12:29

Subject: git-apply fails on creating a new file, with both -p and --directory specified
Message-ID: <201004281429.26579.mat@matlehmann.de>
URL: https://gitlist.dev/e/201004281429.26579.mat%40matlehmann.de

```
Hi all,

the subject of this mail may read familiar to some - there was a discussion in 
November last year (see 
http://kerneltrap.org/mailarchive/git/2009/11/23/16899/) concerning this 
problem.

Today I had this same issue with git 1.7.0.4. Reading the above mentioned 
discussion and seaching the net did not help me in finding a solution to the 
problem. 

I have to apply patches from one repository to another repository, which have 
a different layout (I am working on splitting one big repository into several 
smaller ones, while development still continues on the big repository).

So I did

big-repo$ git format-patche -o /tmp/foo 
small-repo$ git apply -p2 --directory=some/path --check /tmp/foo/*

and get

fatal: git diff header lacks filename information when removing 2 leading 
pathname components (line 37)

the patch looks like this:

35| diff --git a/xyz/bar.jpg b/xyz/bar.jpg
36| new file mode 100644
37| index 
0000000000000000000000000000000000000000..3dcce2e1f68586ed2089d86b1bf4e7e41c818d97
38| GIT binary patch
39| literal 8791



Since this problem was discussed before - is there a solution?
This is something like a showstopper for me right now, so I am very thankful 
for any hints.

Best regards,

Mat

```

## Matthias Lehmann, 2010-04-29 08:20

Subject: Re: git-apply fails on creating a new file, with both -p and --directory specified
Message-ID: <hrbfg2$t5m$1@dough.gmane.org>
URL: https://gitlist.dev/e/hrbfg2%24t5m%241%40dough.gmane.org
In-Reply-To: <201004281429.26579.mat@matlehmann.de>

```
Matthias Lehmann wrote:

> Hi all,
> 
> the subject of this mail may read familiar to some - there was a
> discussion in November last year (see
> http://kerneltrap.org/mailarchive/git/2009/11/23/16899/) concerning this
> problem.
> 
> Today I had this same issue with git 1.7.0.4. Reading the above mentioned
> discussion and seaching the net did not help me in finding a solution to
> the problem.
> 
> I have to apply patches from one repository to another repository, which
> have a different layout (I am working on splitting one big repository into
> several smaller ones, while development still continues on the big
> repository).
> 
> So I did
> 
> big-repo$ git format-patche -o /tmp/foo
> small-repo$ git apply -p2 --directory=some/path --check /tmp/foo/*
> 
> and get
> 
> fatal: git diff header lacks filename information when removing 2 leading
> pathname components (line 37)
> 
> the patch looks like this:
> 
> 35| diff --git a/xyz/bar.jpg b/xyz/bar.jpg
> 36| new file mode 100644
> 37| index
> 
0000000000000000000000000000000000000000..3dcce2e1f68586ed2089d86b1bf4e7e41c818d97
> 38| GIT binary patch
> 39| literal 8791
> 
> 
> 
> Since this problem was discussed before - is there a solution?
> This is something like a showstopper for me right now, so I am very
> thankful for any hints.
> 
> Best regards,
> 
> Mat

Is there anything I can do to get some feedback to this issue? I don't want 
to be impatient, it's just quite important to me. 

Since I have not much experience in reporting issues to a mailing list, it 
might well be, that I did something wrong - so please correct me and direct 
me to how I can be of better help.

Best regards,

Mat

```
