I do not think that parameter does not have anything to do with your cwd. As the documentation says:
--directory=<root>::
Prepend <root> to all filenames. If a "-p" argument was also passed,
it is applied before prepending the new root. For example, a patch that talks about updating `a/git-gui.sh` to `b/git-gui.sh`
can be applied to the file in the working tree `modules/git-gui/git-gui.sh` by
running `git apply --directory=modules/git-gui`.
the parameter is just a fixed string that is used to modify the path that appears in the patch before it gets applied, and has nothing to do with your current (or previous for that matter) working directory.
Suppose you have a patch that tries to update "COPYING". Such a patch generated by Git would look like this:
diff --git a/COPYING b/COPYING
index 536e555..ee559b1 100644
--- a/COPYING
+++ b/COPYING
@@ -1,3 +1,4 @@
+GPL GPL GPL Note that the only valid version of the GPL as far as this project
is concerned is _this_ particular version of the license (ie v2, notFurther suppose that you have already rearranged your project so that that file appears in licenses/gpl directory, and your $(cwd) is licenses/ subdirectory of your working tree.
You would give --directory=licenses/gpl/ without passing any custom -p parameter. This internally turns the patch being applied into something like:
diff --git a/licenses/gpl/COPYING b/licenses/gpl/COPYING
index 536e555..ee559b1 100644
--- a/licenses/gpl/COPYING
+++ b/licenses/gpl/COPYING
@@ -1,3 +1,4 @@
+GPL GPL GPL Note that the only valid version of the GPL as far as this project
is concerned is _this_ particular version of the license (ie v2, notBecause the patch application in git is always relative to the top level of your working tree no matter where you are, this applies to the path you intended it to.
Here is a sample transcript to try it yourself.
$ (echo GPL GPL GPL; cat COPYING) >x && cat x >COPYING
$ git diff >P.diff
$ git checkout COPYING
$ mkdir -p licenses/gpl
$ git mv COPYING licenses/gpl
$ cd licenses
$ git apply -v --directory=licenses/gpl ../P.diff
Checking patch licenses/gpl/COPYING...
Applied patch licenses/gpl/COPYING cleanly.
$ git diff
diff --git a/licenses/gpl/COPYING b/licenses/gpl/COPYING
index 536e555..ee559b1 100644
--- a/licenses/gpl/COPYING
+++ b/licenses/gpl/COPYING
@@ -1,3 +1,4 @@
+GPL GPL GPL Note that the only valid version of the GPL as far as this project
is concerned is _this_ particular version of the license (ie v2, not