All of lore.kernel.org
 help / color / mirror / Atom feed
From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Can Gemicioglu <cgemici@ccs.neu.edu>
Cc: git@vger.kernel.org
Subject: Re: Bug Report for git apply
Date: Thu, 11 Apr 2019 22:17:18 +0200	[thread overview]
Message-ID: <20190411201718.GJ8796@szeder.dev> (raw)
In-Reply-To: <408662419.10955610.1555010182939.JavaMail.zimbra@zimbra.ccs.neu.edu>

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

      reply	other threads:[~2019-04-11 20:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11 19:16 Bug Report for git apply Can Gemicioglu
2019-04-11 20:17 ` SZEDER Gábor [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190411201718.GJ8796@szeder.dev \
    --to=szeder.dev@gmail.com \
    --cc=cgemici@ccs.neu.edu \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.