1

I'm applying a patch to an svn working copy. In the patch file contains a new file.

Patch would normally return something like this:

can't find file to patch at input line 344
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/user-features/src/main/java/com/app2/util/SearchRelevanceHelper.java b/user-features/src/main/java/com/app2/util/SearchRelevanceHelper.java
|new file mode 100644
|index 0000000..c10b3ae
|--- /dev/null
|+++ b/user-features/src/main/java/com/yookos/util/SearchRelevanceHelper.java
--------------------------
File to patch:

How do I handle this?

drecute
  • 748
  • 4
  • 11
  • 29
  • Your patch file was generated by `Git`. `git help diff` says "*What the -p option produces is slightly different from the traditional diff format*". Maybe that is the reason `patch` cannot apply it... – axiac Dec 15 '14 at 10:53
  • 1
    The patch file was created using `git format-patch` – drecute Dec 15 '14 at 10:56
  • Excerpt from: [`man help format-patch`](http://git-scm.com/docs/git-format-patch#_discussion): "*The patch produced by `git format-patch` is in UNIX mailbox format...* ... *...and apply them with `git am`*". – axiac Dec 15 '14 at 11:04

1 Answers1

1

I tried your patch with the cygwin patch command.

afusilde@LFR408288 ~/testdir
$ cat newpatch
diff --git a/user-features/src/main/java/com/app2/util/SearchRelevanceHelper.java b/user-features/src/main/java/com/app2/util/SearchRelevanceHelper.java
new file mode 100644
index 0000000..c10b3ae
--- /dev/null
+++ b/user-features/src/main/java/com/yookos/util/SearchRelevanceHelper.java

afusilde@LFR408288 ~/testdir
$ mkdir test

afusilde@LFR408288 ~/testdir
$ cd test

afusilde@LFR408288 ~/testdir/test
$ patch < ../newpatch
patching file SearchRelevanceHelper.java

afusilde@LFR408288 ~/testdir/test
$ ls
SearchRelevanceHelper.java

No problem for me. Do you use a GNU patch command ?

Shengis
  • 176
  • 1
  • 12