Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git apply is making no changes to files

Tags:

git

patch

I have to apply a patch to my repo and am running

git apply --directory=$PWD xxxxx.patch

For reasons I won't go into, I cannot use git am in this instance, and I need to use the directory flag.

git tells me:

$> git apply --directory=$PWD xxxxx.patch
code1/xxxxx.patch:337: trailing whitespace.
         < one partial line of code >
warning: 1 line adds whitespace errors.

I have read that the whitespace warning is nothing serious and should not stop git from applying the patch. However, whatever the reason, git is not applying the patch. None of the current files in the repo are changing. Any idea what to do about this?

like image 545
bob.sacamento Avatar asked Aug 03 '17 16:08

bob.sacamento


1 Answers

I note the following boldfaced (my boldface) sentence in the git apply documentation:

Reads the supplied diff output (i.e. "a patch") and applies it to files. When running from a subdirectory in a repository, patched paths outside the directory are ignored. With the --index option ...

It seems in this case that git patch is deciding that the files are outside the directory. If run from the top level, it should stop deciding that (though of course $PWD itself will change too; any --directory option, if one is required, would need a different argument).

like image 86
torek Avatar answered Nov 03 '22 02:11

torek