git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Bug Report for git apply
@ 2019-04-11 19:16 Can Gemicioglu
  2019-04-11 20:17 ` SZEDER Gábor
  0 siblings, 1 reply; 2+ messages in thread
From: Can Gemicioglu @ 2019-04-11 19:16 UTC (permalink / raw)
  To: git

Hi,

I noticed a problem when trying to apply a patch file that contained many separate patches in a single file. Trying to apply this patch gave me a "No such file or directory" error for one of the files in the middle and after looking around I realised this file was also created earlier in the patch. I tested this myself with these steps and saw a similar error:

1. Create a new file and commit.
2. Move the file to a different folder and commit.
3. Create a single patch for these 2 commits by using git format-patch and concatenating the two resulting files (01.patch, 02.patch) into one (combined.patch).
4. Roll back to 2 commits earlier.

At that point if I try to use 'git apply combined.patch', it will throw the same no such file error. However, if I use 'git am combined.patch' instead it works. If I apply the first 2 patches separately instead, using 'git apply 0*' it also works but if I first try to check if it will work with 'git apply --check 0*' it actually throws the same error again.

I'm guessing there's something like a check to make sure the file exists that throws an error even if the file was going to be created by previous commits.

Tested on git version 2.21.0 on Ubuntu 18.04

Best,
Can Gemicioglu

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug Report for git apply
  2019-04-11 19:16 Bug Report for git apply Can Gemicioglu
@ 2019-04-11 20:17 ` SZEDER Gábor
  0 siblings, 0 replies; 2+ messages in thread
From: SZEDER Gábor @ 2019-04-11 20:17 UTC (permalink / raw)
  To: Can Gemicioglu; +Cc: git

On Thu, Apr 11, 2019 at 03:16:22PM -0400, Can Gemicioglu wrote:
> I noticed a problem when trying to apply a patch file that contained
> many separate patches in a single file.

To quote the first line of its manpage :) 'git apply' is meant to
"Apply a patch to files and/or to the index".  Note the singular "a
patch"; not multiple patches in the same or multiple files.

Use 'git am' instead, that is its job, and as you noted, it works.

> Trying to apply this patch gave me a "No such file or directory" error for one of the files in the middle and after looking around I realised this file was also created earlier in the patch. I tested this myself with these steps and saw a similar error:
> 
> 1. Create a new file and commit.
> 2. Move the file to a different folder and commit.
> 3. Create a single patch for these 2 commits by using git format-patch and concatenating the two resulting files (01.patch, 02.patch) into one (combined.patch).
> 4. Roll back to 2 commits earlier.
> 
> At that point if I try to use 'git apply combined.patch', it will
> throw the same no such file error. However, if I use 'git am
> combined.patch' instead it works. If I apply the first 2 patches
> separately instead, using 'git apply 0*' it also works but if I
> first try to check if it will work with 'git apply --check 0*' it
> actually throws the same error again.
> 
> I'm guessing there's something like a check to make sure the file exists that throws an error even if the file was going to be created by previous commits.
> 
> Tested on git version 2.21.0 on Ubuntu 18.04
> 
> Best,
> Can Gemicioglu

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-11 20:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-11 19:16 Bug Report for git apply Can Gemicioglu
2019-04-11 20:17 ` SZEDER Gábor

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).